CosmicSDK class
This page describes the CosmicSDK C++ class and its generic public methods. For each specific protocol APIs, please refer to the corresponding sections.
- group CosmicSDK C++ blocking API
High-level blocking C++ interface to Binho devices.
This module provides the main blocking C++ API used to connect to a Binho host adapter, configure it, and perform different operations to interact with downstream devices over different interfaces and protocols such as I2C, I3C, SPI, UART and GPIOs.
-
class CosmicSDK
- #include <CosmicSDK.hpp>
This class provides a blocking C++ interface. This means that each method call will wait for the operation to complete before returning. The returned values are passed directly back to the caller through a return value and output parameters.
Public Types
-
using NotificationCallback = std::function<void(const Notification&)>
Type definition for notification callback functions.
Public Functions
-
CosmicSDK(int timeout = -1)
Construct a new Cosmic SDK object.
- Parameters:
timeout – Timeout in milliseconds for operations. Use -1 for no timeout
-
inline void onNotification(NotificationCallback callback)
Registers a callback to be invoked when an asynchronous notification is received.
- Parameters:
callback – Function that will receive a const reference to a Notification object.
-
bool connect(const std::string &devicePath = "")
Connects to a Binho Host Adapter device, such as Pulsar or Supernova. If no device path is provided, it will attempt to connect to the first available device.
- Parameters:
devicePath – The path to the device (e.g., COM3 on Windows or /dev/ttyUSB0 on Linux). If empty, connects to the first available device.
- Returns:
True if the connection was successful, false otherwise.
-
bool connectWithSerialNumber(const std::string &serial)
Connects to a Binho Host Adapter device using its serial number.
- Parameters:
serial – The serial number of the device to connect to.
- Returns:
True if the connection was successful, false otherwise.
-
void disconnect()
Disconnects from the currently connected Binho Host Adapter device.
-
uint16_t getUsbString(std::vector<uint8_t> &outData, uint8_t subCmd)
Gets the Usb String object.
- Parameters:
outData – The data received from the device
subCmd – The sub-command to be sent to the device
- Returns:
The status code of the operation
-
uint16_t getDeviceInfo(DeviceInfo &info)
Gets the device information.
- Parameters:
info – The device information object to be filled with data
- Returns:
The status code of the operation
-
uint16_t enterBootMode()
Puts the device into boot mode. Once the device process the request, it immediately jumps into the bootloader. After the user has flashed the device with a firmware, a new connection needs to be done to continue using the device.
- Returns:
SUCCESS or SDK_ERROR_DISCONNECT if the device is not connected
Public Static Functions
-
static inline std::string getVersion()
Gets the CosmicSDK library version string.
Returns a string containing the version number of the linked CosmicSDK library. This allows verification at startup that the linked library matches what they were built against.
- Returns:
A version string in the format “MAJOR.MINOR.PATCH”, e.g. “1.2.3”
-
struct DeviceInfo
- #include <CosmicSDK.hpp>
Structure to hold device information.
-
using NotificationCallback = std::function<void(const Notification&)>
-
class CosmicSDK