21#ifndef LIBS_USB_HOTPLUGAGENT_H_
22#define LIBS_USB_HOTPLUGAGENT_H_
26#include <ola/thread/PeriodicThread.h>
31#include "libs/usb/LibUsbAdaptor.h"
32#include "libs/usb/LibUsbThread.h"
33#include "libs/usb/Types.h"
117 #ifdef HAVE_LIBUSB_HOTPLUG_API
128 void HotPlugEvent(
struct libusb_device *dev,
129 libusb_hotplug_event event);
133 typedef std::map<USBDeviceID, struct libusb_device*> DeviceMap;
135 std::auto_ptr<NotificationCallback>
const m_notification_cb;
136 const int m_debug_level;
138 libusb_context *m_context;
139 std::auto_ptr<ola::usb::LibUsbThread> m_usb_thread;
140 std::auto_ptr<ola::usb::AsyncronousLibUsbAdaptor> m_usb_adaptor;
141 std::auto_ptr<ola::thread::PeriodicThread> m_scanner_thread;
144 bool m_suppress_hotplug_events;
153 bool HotplugSupported();
154 bool ScanUSBDevices();
A 2 argument callback which can be called multiple times.
Definition Callback.h:1895
A LibUsbAdaptor for use with Asyncronous widgets.
Definition LibUsbAdaptor.h:564
Detects when USB devices are added or removed.
Definition HotplugAgent.h:45
bool Stop()
Stop the HotplugAgent.
Definition HotplugAgent.cpp:144
bool Start()
Start the hotplug agent.
Definition HotplugAgent.cpp:110
HotplugAgent(NotificationCallback *notification_cb, int debug_level)
Create a new HotplugAgent.
Definition HotplugAgent.cpp:60
ola::Callback2< void, EventType, struct libusb_device * > NotificationCallback
Called when a USB device has been added or removed.
Definition HotplugAgent.h:61
void HaltNotifications()
Prevent any further notifications from occurring.
Definition HotplugAgent.cpp:129
EventType
Definition HotplugAgent.h:47
@ DEVICE_REMOVED
The device ws removed.
Definition HotplugAgent.h:49
@ DEVICE_ADDED
The device was added.
Definition HotplugAgent.h:48
~HotplugAgent()
Destructor.
Definition HotplugAgent.cpp:69
AsyncronousLibUsbAdaptor * GetUSBAdaptor() const
Get the AsyncronousLibUsbAdaptor to use.
Definition HotplugAgent.cpp:75
bool Init()
Initialize the hotplug agent.
Definition HotplugAgent.cpp:79
The namespace containing all OLA symbols.
Definition Credentials.cpp:44