Skip to content

Commit

Permalink
Move BluetoothRemoteControl to C++ IDL
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaszm committed Nov 26, 2024
1 parent 49a109e commit d794d90
Show file tree
Hide file tree
Showing 4 changed files with 161 additions and 345 deletions.
157 changes: 157 additions & 0 deletions interfaces/IBluetoothRemoteControl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2024 Metrological
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

#include "Module.h"

namespace Thunder {

namespace Exchange {

// @json 1.0.0 @text:legacy_lowercase
struct EXTERNAL IBluetoothRemoteControl : virtual public Core::IUnknown {

enum { ID = ID_BLUETOOTHREMOTECONTROL };

struct unitmetadata {
string name /* @brief Name of the unit */;
Core::OptionalType<string> model /* @brief Model name */;
Core::OptionalType<string> serial /* @brief Serial number */;
Core::OptionalType<string> firmware /* @brief Fimrware version */;
Core::OptionalType<string> software /* @brief Software versione */;
Core::OptionalType<string> manufacturer /* @brief Vendor/manufacturer name */;
};

enum codectype : uint8_t {
PCM /* @text:pcm */,
IMA_ADPCM /* @text:ima-adpcm */
};

struct audioprofile {
// Samples are always little endian signed integers
codectype codec /* @brief Compression method (pcm: uncompressed) */;
uint8_t channels /* @brief Number of audio channels (e.g. 1) */;
uint8_t resolution /* @brief Sample resultion in bits (e.g. 16) */;
uint32_t sampleRate /* @brief Sample rate in hertz (e.g. 16000) */;
};

// @event
struct INotification : virtual public Core::IUnknown {

enum { ID = ID_BLUETOOTHREMOTECONTROL_NOTIFICATION };

// @statuslistener
// @brief Signals battery level change
// @param level Battery level in percent (e.g. 75)
virtual void BatteryLevelChange(const uint8_t level) = 0;
};

// @event
struct IAudioTransmissionCallback : virtual public Core::IUnknown {

enum { ID = ID_BLUETOOTHREMOTECONTROL_CALLBACK };

enum transmissionstate : uint8_t {
STOPPED,
STARTED
};

// @statuslistener
// @text audiotransmission
// @brief Signals beginning end of audio transmission
// @param state New state of the voice transmission
// @param profile Details of the audio format used in the voice transmission
virtual void StateChanged(const transmissionstate state) = 0;

// @text audioframe
// @brief Provides audio frame data
// @description Format of the data can be retrieved with AudioProfile call
// @param seq Frame number in current transmission (e.g. 1)
// @param size Size of the raw data frame in bytes (e.g. 400)
// @param data Raw audio data
virtual void Data(const uint16_t seq, const uint16_t size, const uint8_t data[] /* @length:size @encode:base64 */) = 0;
};

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

// Note: Installing a callback and registering for a JSON-RPC notification is mutually exclusive.
virtual Core::hresult Callback(IAudioTransmissionCallback* const callback) = 0;

// @brief Assigns a Bluetooth device
// @param address: Address of the Bluetooth device to assign
// @retval ERROR_UNKNOWN_KEY Device address value is invalid
// @retval ERROR_ALREADY_CONNECTED A RCU device is already assigned
virtual Core::hresult Assign(const string& address) = 0;

// @brief Revokes a Bluetooth sink device from audio playback
// @retval ERROR_ALREADY_RELEASED No device is currently assigned as RCU
virtual Core::hresult Revoke() = 0;

// @property
// @alt-deprecated:address
// @brief Bluetooth address
// @retval ERROR_ILLEGAL_STATE The RCU device currently is not assigned
virtual Core::hresult Device(string& address /* @out */) const = 0;

// @property
// @brief Device metadata
// @alt-deprecated:info
// @retval ERROR_ILLEGAL_STATE The RCU device currently is not assigned
virtual Core::hresult Metadata(unitmetadata& info /* @out */) const = 0;

// @property
// @brief Battery level
// @retval ERROR_UNAVAILABLE The device is not connected or does not support battery information
// @retval ERROR_ILLEGAL_STATE The RCU device currently is not assigned
virtual Core::hresult BatteryLevel(uint8_t& level /* @out */) const = 0;

// @property
// @brief Toggle voice control
// @retval ERROR_UNAVAILABLE The device does not support voice input
// @retval ERROR_ILLEGAL_STATE The RCU device currently is not assigned
virtual Core::hresult VoiceControl(bool& value /* @out */) const = 0;
virtual Core::hresult VoiceControl(const bool value) = 0;

// @property
// @brief Details of audio format
// @retval ERROR_UNAVAILABLE The device does not support voice input
// @retval ERROR_ILLEGAL_STATE The RCU device currently is not assigned
virtual Core::hresult AudioProfile(audioprofile& profile /* @out */) const = 0;
};

namespace JSONRPC {

// @json 1.0.0 @text:legacy_lowercase
struct IBluetoothRemoteControlLegacy {

virtual ~IBluetoothRemoteControlLegacy() = default;

// @property @deprecated
// @brief Name of the RCU device
// @retval ERROR_ILLEGAL_STATE The RCU device is not assigned
virtual Core::hresult Name(string& name /* @out */) const = 0;
};

}

} // namespace Exchange

}
66 changes: 0 additions & 66 deletions interfaces/IVoiceHandler.h

This file was deleted.

8 changes: 4 additions & 4 deletions interfaces/Ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ namespace Exchange {
ID_GUIDE = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x0F0,
ID_GUIDE_NOTIFICATION = ID_GUIDE + 1,

ID_VOICEHANDLER = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x100,
ID_VOICEPRODUCER = ID_VOICEHANDLER + 1,
ID_BLUETOOTHREMOTECONTROL = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x100,
ID_BLUETOOTHREMOTECONTROL_CALLBACK = ID_BLUETOOTHREMOTECONTROL + 1,
ID_BLUETOOTHREMOTECONTROL_NOTIFICATION = ID_BLUETOOTHREMOTECONTROL + 2,

ID_WEBDRIVER = RPC::IDS::ID_EXTERNAL_INTERFACE_OFFSET + 0x110,

Expand Down Expand Up @@ -369,11 +370,10 @@ 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_TESTAUTOMATIONCOMRPC = ID_TESTAUTOMATIONMEMORY + 1,
ID_TESTAUTOMATIONCOMRPCINTERNAL = ID_TESTAUTOMATIONMEMORY + 2

};
}
}
Loading

0 comments on commit d794d90

Please sign in to comment.