tt_hal_radio: Add name and description getters
This commit is contained in:
parent
d3bf7ff7c5
commit
b50900a826
@ -82,6 +82,21 @@ RadioHandle tt_hal_radio_alloc(DeviceId radioId);
|
||||
*/
|
||||
void tt_hal_radio_free(RadioHandle handle);
|
||||
|
||||
/**
|
||||
* Get the name for the radio driver object.
|
||||
* @param[in] handle the radio driver handle
|
||||
* @return the name of the radio
|
||||
*/
|
||||
const char* const tt_hal_radio_get_name(RadioHandle handle);
|
||||
|
||||
/**
|
||||
* Get the description for the radio driver object.
|
||||
* @param[in] handle the radio driver handle
|
||||
* @return the description for the radio
|
||||
*/
|
||||
const char* const tt_hal_radio_get_desc(RadioHandle handle);
|
||||
|
||||
|
||||
/**
|
||||
* Get the state for the radio driver object.
|
||||
* @param[in] handle the radio driver handle
|
||||
|
||||
@ -18,7 +18,12 @@ static tt::hal::radio::RadioDevice::TransmissionState toCpp(RadioTxState state);
|
||||
|
||||
struct DeviceWrapper {
|
||||
std::shared_ptr<tt::hal::radio::RadioDevice> device;
|
||||
DeviceWrapper(std::shared_ptr<tt::hal::radio::RadioDevice> device) : device(device) {}
|
||||
std::string name;
|
||||
std::string description;
|
||||
DeviceWrapper(std::shared_ptr<tt::hal::radio::RadioDevice> device)
|
||||
: device(device)
|
||||
, name(device->getName())
|
||||
, description(device->getDescription()) {}
|
||||
};
|
||||
|
||||
static std::shared_ptr<tt::hal::radio::RadioDevice> findValidRadioDevice(tt::hal::Device::Id id) {
|
||||
@ -41,6 +46,16 @@ extern "C" {
|
||||
delete wrapper;
|
||||
}
|
||||
|
||||
const char* const tt_hal_radio_get_name(RadioHandle handle) {
|
||||
auto wrapper = static_cast<DeviceWrapper*>(handle);
|
||||
return wrapper->name.c_str();
|
||||
}
|
||||
|
||||
const char* const tt_hal_radio_get_desc(RadioHandle handle) {
|
||||
auto wrapper = static_cast<DeviceWrapper*>(handle);
|
||||
return wrapper->description.c_str();
|
||||
}
|
||||
|
||||
RadioState tt_hal_radio_get_state(RadioHandle handle) {
|
||||
auto wrapper = static_cast<DeviceWrapper*>(handle);
|
||||
return fromCpp(wrapper->device->getState());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user