Skip to content

Commit 81ff13f

Browse files
Merge pull request #2 from OpenEarable/codex/led-state-readback
Specify LED configuration readback and notifications
2 parents 514a2e7 + 3178b09 commit 81ff13f

5 files changed

Lines changed: 33 additions & 13 deletions

File tree

‎generated/c/include/led_protocol.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
#define LED_BLE_SERVICE_UUID "81040a2e-4819-11ee-be56-0242ac120002"
77
#define LED_BLE_RGB_CHARACTERISTIC_UUID "81040e7a-4819-11ee-be56-0242ac120002"
8-
#define LED_BLE_RGB_CHARACTERISTIC_PROPERTIES (PROTOCOL_BLE_PROPERTY_WRITE)
8+
#define LED_BLE_RGB_CHARACTERISTIC_PROPERTIES (PROTOCOL_BLE_PROPERTY_READ | PROTOCOL_BLE_PROPERTY_WRITE | PROTOCOL_BLE_PROPERTY_NOTIFY)
99
#define LED_BLE_STATE_CHARACTERISTIC_UUID "81040e7b-4819-11ee-be56-0242ac120002"
10-
#define LED_BLE_STATE_CHARACTERISTIC_PROPERTIES (PROTOCOL_BLE_PROPERTY_WRITE)
10+
#define LED_BLE_STATE_CHARACTERISTIC_PROPERTIES (PROTOCOL_BLE_PROPERTY_READ | PROTOCOL_BLE_PROPERTY_WRITE | PROTOCOL_BLE_PROPERTY_NOTIFY)
1111

1212
#ifdef __cplusplus
1313
extern "C" {

‎generated/c/include/zephyr/led_ble.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
#define LED_ZEPHYR_SERVICE_UUID BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x81040a2e, 0x4819, 0x11ee, 0xbe56, 0x0242ac120002))
99

1010
#define LED_ZEPHYR_RGB_CHARACTERISTIC_UUID BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x81040e7a, 0x4819, 0x11ee, 0xbe56, 0x0242ac120002))
11-
#define LED_ZEPHYR_RGB_CHARACTERISTIC_PROPERTIES (BT_GATT_CHRC_WRITE)
12-
#define LED_ZEPHYR_RGB_CHARACTERISTIC_PERMISSIONS (BT_GATT_PERM_WRITE)
11+
#define LED_ZEPHYR_RGB_CHARACTERISTIC_PROPERTIES (BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE | BT_GATT_CHRC_NOTIFY)
12+
#define LED_ZEPHYR_RGB_CHARACTERISTIC_PERMISSIONS (BT_GATT_PERM_READ | BT_GATT_PERM_WRITE)
1313

1414
#define LED_ZEPHYR_STATE_CHARACTERISTIC_UUID BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x81040e7b, 0x4819, 0x11ee, 0xbe56, 0x0242ac120002))
15-
#define LED_ZEPHYR_STATE_CHARACTERISTIC_PROPERTIES (BT_GATT_CHRC_WRITE)
16-
#define LED_ZEPHYR_STATE_CHARACTERISTIC_PERMISSIONS (BT_GATT_PERM_WRITE)
15+
#define LED_ZEPHYR_STATE_CHARACTERISTIC_PROPERTIES (BT_GATT_CHRC_READ | BT_GATT_CHRC_WRITE | BT_GATT_CHRC_NOTIFY)
16+
#define LED_ZEPHYR_STATE_CHARACTERISTIC_PERMISSIONS (BT_GATT_PERM_READ | BT_GATT_PERM_WRITE)

‎generated/dart/lib/src/led_protocol.dart‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ abstract final class LedBleUuids {
1616
name: 'rgb',
1717
uuid: rgbCharacteristicUuid,
1818
properties: {
19+
ProtocolBleCharacteristicProperty.read,
1920
ProtocolBleCharacteristicProperty.write,
21+
ProtocolBleCharacteristicProperty.notify,
2022
},
2123
);
2224

@@ -29,7 +31,9 @@ abstract final class LedBleUuids {
2931
name: 'state',
3032
uuid: stateCharacteristicUuid,
3133
properties: {
34+
ProtocolBleCharacteristicProperty.read,
3235
ProtocolBleCharacteristicProperty.write,
36+
ProtocolBleCharacteristicProperty.notify,
3337
},
3438
);
3539

‎schemas/led/README.md‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ Service UUID: `81040a2e-4819-11ee-be56-0242ac120002`.
99

1010
| Characteristic | UUID | Operations | Payload size |
1111
|---|---|---|---|
12-
| RGB | `81040e7a-4819-11ee-be56-0242ac120002` | Write | 3 bytes |
13-
| State | `81040e7b-4819-11ee-be56-0242ac120002` | Write | 1 byte |
12+
| RGB | `81040e7a-4819-11ee-be56-0242ac120002` | Read, write, notify | 3 bytes |
13+
| State | `81040e7b-4819-11ee-be56-0242ac120002` | Read, write, notify | 1 byte |
1414

1515
Send the payload directly to its characteristic, without a message ID, length
16-
prefix, or version byte. Neither characteristic supports reads or notifications.
16+
prefix, or version byte. Firmware 2.3.x adds reads and notifications using the
17+
same payloads and UUIDs. Older firmware is write-only: clients must check the
18+
discovered characteristic properties before reading or subscribing.
1719

1820
## RGB color
1921

@@ -41,8 +43,9 @@ Write a single byte to State:
4143
| `00` | Automatic state indication; firmware chooses colors and animations |
4244
| `01` | Custom mode; display the stored RGB color |
4345

44-
Use only these two values. The firmware callback currently does not reject
45-
other numeric values, but they have no defined protocol meaning.
46+
Use only these two values. The firmware callback does not reject
47+
other numeric values on older versions; firmware 2.3.x rejects them with
48+
ATT Value Not Allowed and preserves the current mode.
4649

4750
To show blue:
4851

@@ -58,6 +61,19 @@ that are not exactly three bytes, State payloads that are not exactly one byte,
5861
and writes with a nonzero offset. Successful writes have no separate response
5962
payload.
6063

64+
## Readback and notifications
65+
66+
Read RGB to retrieve the stored custom color, including while automatic mode
67+
is active. Read State to retrieve the configured indication mode. These are
68+
configuration values, not the instantaneous color of a pulse or a DFU override.
69+
At boot the custom color is black and the indication mode is automatic.
70+
71+
Subscribe using each characteristic’s CCC descriptor, then read its current
72+
value. After a successful write, firmware notifies the accepted value to
73+
subscribers. Rejected writes leave the configuration unchanged and produce no
74+
notification. A successful write while unsubscribed remains valid. Settings
75+
are volatile and reset at reboot, as before.
76+
6177
## Generated bindings
6278

6379
[`protocol.yml`](protocol.yml) defines both messages and their BLE metadata.

‎schemas/led/protocol.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ transport:
88
characteristics:
99
- name: rgb
1010
uuid: 81040e7a-4819-11ee-be56-0242ac120002
11-
properties: [write]
11+
properties: [read, write, notify]
1212
- name: state
1313
uuid: 81040e7b-4819-11ee-be56-0242ac120002
14-
properties: [write]
14+
properties: [read, write, notify]
1515

1616
messages:
1717
rgb:

0 commit comments

Comments
 (0)