Skip to content

Commit

Permalink
Merge branch 'master' into development/actions-macos-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
pwielders authored Nov 18, 2024
2 parents 448a90d + 515bea5 commit fcc3b46
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 3 deletions.
125 changes: 125 additions & 0 deletions interfaces/IUSBHub.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#pragma once

#include "Module.h"

// @stubgen:include <com/IIteratorType.h>

namespace Thunder {

namespace Exchange {

// @json
struct EXTERNAL IUSBHub : virtual public Core::IUnknown {

enum { ID = ID_USB_HUB };

~IUSBHub() override = default;

enum Speed : uint8_t {
SPEED_LOW = 1,
SPEED_FULL = 2,
SPEED_HIGH = 3,
SPEED_SUPER = 4
};

enum Flags : uint8_t {
FLAGS_AVAILABLE = 1,
FLAGS_SWITCHABLE = 2
};

enum Status : uint8_t {
STATUS_ACTIVE = 0x01,
STATUS_NO_DEVICE_CONNECTED = 0x02,
STATUS_SELF_POWERED = 0x03
};

struct ProductMetadata {
uint8_t languageId /* @brief language id present on the device */;
string serialNumber /* @brief unicode string representing the serial number of the device */;
string manufacturer /* @brief unicode string representing the manufacturer of the device */;
string product /* @brief unicode string representing the product */;
};

struct DeviceMetadata {
string deviceName /* @brief Name of the USB device */;
uint32_t parentId /* @brief Parent Node ID of the device */;
Status status /* @brief current device status */;
uint8_t deviceLevel /* @brief device level */;
uint8_t portNumber /* @brief port number of USB on which the device is attached */;
uint8_t protocol /* @brief Protocol supported by the device */;
Speed busSpeed /* @brief Speed of the device */;
string serialNumber /* @brief Serial number of the device */;
Flags flags /* @brief Flags of the device */;
uint16_t vendorId /* @brief the vendor Id assigned to this device */;
uint16_t productId /* @brief the product Id assigned to this device */;
uint8_t deviceClass /* @brief USB class of the device as per USB specificiation */ ;
uint8_t deviceSubclass /* @brief USB sub class of the device as per USB specificiation */;
string devicePath /* @brief the path to be used for the USB device ex: /dev/sdX */;
uint32_t features /* @brief Features supported by the device - reserved */;
uint8_t numLanguageIds /* @brief number of language ids present on the device */;
ProductMetadata productInfo1;
ProductMetadata productInfo2;
ProductMetadata productInfo3;
ProductMetadata productInfo4;
};

using IStringIterator = RPC::IIteratorType<string, RPC::ID_STRINGITERATOR>;

// @event
struct EXTERNAL INotification : virtual public Core::IUnknown {
enum { ID = ID_USB_HUB_NOTIFICATION };

~INotification() override = default;

// @brief Device Plugged in on the bus notification
// @param device: USB information of the plugged in device
virtual void Announce(const DeviceMetadata& device) = 0;

// @brief Device removed from the bus notification
// @param device: USB information of the plugged in device
virtual void Revoke(const DeviceMetadata& device) = 0;
};

struct EXTERNAL IDevice : virtual public Core::IUnknown {

enum { ID = ID_USB_DEVICE };

~IDevice() override = default;
};

/** Register notification interface */
virtual Core::hresult Register(INotification *notification) = 0;

/** Unregister notification interface */
virtual Core::hresult Unregister(const INotification *notification) = 0;

// @brief Get a string array defning al devices hooked up to this hub.
// @param iterator : List of USB devices (deviceName).
virtual Core::hresult Devices(IStringIterator*& iterator /* @out */) const = 0;

// @brief Get a string array defining all devices hooked up to this hub cmpliant to the given VendorId/ProductId
// @param iterator : List of USB devices (deviceName).
virtual Core::hresult VendorDevices(const uint16_t vendorId, const uint16_t productId, IStringIterator*& iterator /* @out */) const = 0;

/** Gets the device metadata of a connected USB Devices.*/
// @brief Get the metadata information about the name passed in the paramater.
// @param deviceName: Name of the device
// @param device: all the metadata of the requested deviceName device.
virtual Core::hresult Device(const string& deviceName, struct DeviceMetadata& device /* @out */ ) const = 0;

// @brief Acquire the respective driver for the device */
// @param deviceName: Name of the device
// @param device: interface to access the device.
/* @json:omit */
virtual Core::hresult Acquire(const string& deviceName /* @in */, IDevice*& device /* @out */ ) const = 0;

// @brief Relinquish the respective driver for the device */
// @param device: Device to be released
/* @json:omit */
virtual Core::hresult Relinquish(const IDevice*& device /* @out */) const = 0;
};

} // namespace Exchange

} // namespace Thunder

9 changes: 6 additions & 3 deletions interfaces/Ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,14 @@ namespace Exchange {
ID_DNS_SERVER = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x4E0,
ID_DNS_ZONE = ID_DNS_SERVER + 1,
ID_DNS_RECORD = ID_DNS_SERVER + 2,

ID_TESTAUTOMATIONMEMORY = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x4F0,

ID_USB_HUB = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x4F0,
ID_USB_HUB_NOTIFICATION = ID_USB_HUB + 1,
ID_USB_DEVICE = ID_USB_HUB + 2,

ID_TESTAUTOMATIONMEMORY = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x9F0,
ID_TESTAUTOMATIONCOMRPC = ID_TESTAUTOMATIONMEMORY + 1,
ID_TESTAUTOMATIONCOMRPCINTERNAL = ID_TESTAUTOMATIONMEMORY + 2

};
}
}

0 comments on commit fcc3b46

Please sign in to comment.