Bluetooth Low Energy
The Bluetooth Low Energy component is called BLE
. It handles bluetooth services of a device. The Bluetooth Low Energy component uses BLE
as RPC namespace and provides the methods:
BLE.GetConfig
to obtain the component's configurationBLE.SetConfig
to update the component's configurationBLE.GetStatus
to obtain the component's status
It uses the key ble
when enumerated in objects including multiple component payloads, like Shelly.GetStatus
.
Observer
To support Shelly Bluetooth peripheral devices, the BLE component can act as a perpetual BT LE Observer. When enabled via the observer.enable
configuration flag, the device will run a constant passive Bluetooth LE scan and relay received advertisement packets to Shelly Cloud service, to enable scene triggers.
Enabling the observer relay functionality might impact BLE advertisement scanner in scripts. A requested interval and window for scanning in scripting might get adjusted to allow for the coexistence of both functionalities.
Methods
BLE.SetConfig
Properties:
Property | Type | Description |
---|---|---|
| object | Configuration that the method takes |
Find more about the config properties in config section
BLE.GetConfig
Find the BLE.GetConfig response properties in config section
BLE.GetStatus
Find more about the status response properties in status section
Configuration
The configuration of the Bluetooth Low Energy component shows whether the bluetooth connection is enabled.
Property | Type | Description | ||||||
---|---|---|---|---|---|---|---|---|
| boolean | True if bluetooth is enabled, false otherwise | ||||||
| object | Configuration of the rpc service
| ||||||
| object | Configuration of the BT LE observer
|
Currently only rpc service is implemented, but a global enable
flag is maintained for possible other future BLE functionality implementation. If either of the enable
flags is set to false
the device is not advertised. Changing the configuration requires restart.
Status
The status of the BLE component contains information about the bluetooth on/off state and does not own any status properties.
Examples
BLE.GetStatus example
- BLE.GetStatus HTTP GET Request
- BLE.GetStatus Curl Request
- BLE.GetStatus Mos Request
http://192.168.33.1/rpc/BLE.GetStatus
curl -X POST -d '{"id":1,"method":"BLE.GetStatus"}' http://${SHELLY}/rpc
mos --port ${PORT} call BLE.GetStatus
Response
- BLE.GetStatus HTTP GET Response
- BLE.GetStatus Curl Response
- BLE.GetStatus Mos Response
{}
{
"id": 1,
"src": "shellyplus1pm-441793ce3f08",
"params": {}
}
{}
BLE.GetConfig example
- BLE.GetConfig HTTP GET Request
- BLE.GetConfig Curl Request
- BLE.GetConfig Mos Request
http://192.168.33.1/rpc/BLE.GetConfig
curl -X POST -d '{"id":1,"method":"BLE.GetConfig"}' http://${SHELLY}/rpc
mos --port ${PORT} call BLE.GetConfig
Response
- BLE.GetConfig HTTP GET Response
- BLE.GetConfig Curl Response
- BLE.GetConfig Mos Response
{
"enable": true,
"rpc": {
"enable": true
}
}
{
"id": 1,
"src": "shellyplus1pm-441793ce3f08",
"params": {
"enable": true,
"rpc": {
"enable": true
}
}
}
{
"enable": true,
"rpc": {
"enable": true
}
}
BLE.SetConfig example
- BLE.SetConfig HTTP GET Request
- BLE.SetConfig Curl Request
- BLE.SetConfig Mos Request
http://192.168.33.1/rpc/BLE.SetConfig?config={"enable":true,"rpc":{"enable":true}}
curl -X POST -d '{"id":1,"method":"BLE.SetConfig","params":{"config":{"enable":true,"rpc":{"enable":true}}}}' http://${SHELLY}/rpc
mos --port ${PORT} call BLE.SetConfig '{"config":{"enable":true,"rpc":{"enable":true}}}'
Response
- BLE.SetConfig HTTP GET Response
- BLE.SetConfig Curl Response
- BLE.SetConfig Mos Response
{
"restart_required": true
}
{
"id": 1,
"src": "shellyplus1pm-441793ce3f08",
"params": {
"restart_required": true
}
}
{
"restart_required": true
}