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 9d58337 commit 52d467c
Show file tree
Hide file tree
Showing 8 changed files with 160 additions and 355 deletions.
7 changes: 0 additions & 7 deletions definitions/Definitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
#include <interfaces/ITextToSpeech.h>
#include <interfaces/ITimeSync.h>
#include <interfaces/ITimeZone.h>
#include <interfaces/IVoiceHandler.h>
#include <interfaces/IVolumeControl.h>
#include <interfaces/IWebDriver.h>
#include <interfaces/IWebPA.h>
Expand Down Expand Up @@ -154,12 +153,6 @@ ENUM_CONVERSION_BEGIN(Exchange::IStream::state)
{ Exchange::IStream::state::Error, _TXT(_T("Error")) },
ENUM_CONVERSION_END(Exchange::IStream::state)

ENUM_CONVERSION_BEGIN(Exchange::IVoiceProducer::IProfile::codec)
{ Exchange::IVoiceProducer::IProfile::codec::UNDEFINED, _TXT(_T("undefined")) },
{ Exchange::IVoiceProducer::IProfile::codec::PCM, _TXT(_T("pcm")) },
{ Exchange::IVoiceProducer::IProfile::codec::ADPCM, _TXT(_T("adpcm")) },
ENUM_CONVERSION_END(Exchange::IVoiceProducer::IProfile::codec)

ENUM_CONVERSION_BEGIN(Exchange::IPower::PCState)
{ Exchange::IPower::On, _TXT(_T("on")) },
{ Exchange::IPower::ActiveStandby, _TXT(_T("active")) },
Expand Down
1 change: 0 additions & 1 deletion definitions/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <interfaces/IExternal.h>
#include <interfaces/IValuePoint.h>
#include <interfaces/IStream.h>
#include <interfaces/IVoiceHandler.h>
#include <interfaces/IPower.h>
#include <interfaces/json/ExternalMetadata.h>
#include <interfaces/IDeviceInfo.h>
Expand Down
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_NOT_SUPPORTED 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_ILLEGAL_STATE The RCU device currently is not assigned
// @retval ERROR_NOT_SUPPORTED The device does not support voice input
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.

5 changes: 3 additions & 2 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
1 change: 0 additions & 1 deletion interfaces/Interfaces.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@
<ClInclude Include="ITimeSync.h" />
<ClInclude Include="ITimeZone.h" />
<ClInclude Include="IValuePoint.h" />
<ClInclude Include="IVoiceHandler.h" />
<ClInclude Include="IWebDriver.h" />
<ClInclude Include="IWebServer.h" />
<ClInclude Include="IWifiControl.h" />
Expand Down
3 changes: 0 additions & 3 deletions interfaces/Interfaces.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,6 @@
<ClInclude Include="ITimeSync.h">
<Filter>Interface Files</Filter>
</ClInclude>
<ClInclude Include="IVoiceHandler.h">
<Filter>Interface Files</Filter>
</ClInclude>
<ClInclude Include="IWebDriver.h">
<Filter>Interface Files</Filter>
</ClInclude>
Expand Down
Loading

0 comments on commit 52d467c

Please sign in to comment.