Skip to content

Commit f625f57

Browse files
authored
docs: add an example for streaming feature (#99)
1 parent ac64530 commit f625f57

3 files changed

Lines changed: 57 additions & 1 deletion

File tree

BadgeBLE.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,9 @@ Returns:
231231
- Parameters out of range: `0xff`.
232232
- `speed_ms` or `brightness_level` is out of allowed range: `0x02`.
233233
- Success: `0x00`.
234+
235+
#### Example
236+
237+
There were some examples created for a better understanding of this next-gen protocol. This requires expect and bluez to be installed.
238+
239+
Put the badge in Bluetooth mode, or enable the always-on BLE. Identify the badge’s MAC address. Put it in the script. Then, in the project root directory, for example, run `./example/streaming.sh` to test the streaming feature.

example/streaming.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/expect -f
2+
3+
set device "5C:53:10:B8:3D:8F"
4+
set timeout 10
5+
6+
spawn bluetoothctl
7+
expect "Agent registered"
8+
9+
# 1. Scan
10+
# This should be run only once externally,
11+
# as bluetoothctl would remember the last connected device.
12+
# So comment the 2 lines below would speed up process.
13+
send -- "scan on\r"
14+
expect "$device"
15+
16+
# 2. Connect
17+
send -- "connect $device\r"
18+
expect "Connection successful"
19+
20+
# 3. Select attribute (characteristic 0xf057)
21+
send -- "gatt.select-attribute 0000f057-0000-1000-8000-00805f9b34fb\r"
22+
23+
# 4. Enter streaming mode
24+
# (0x02 = streaming_setting, 0x00 = enter streaming mode)
25+
send -- "gatt.write '02 00'\r"
26+
expect "Attempting to write"
27+
sleep 1
28+
29+
# 5. Write bitmap content to the badge
30+
# this will draw 2 first lines on the screen
31+
send -- "gatt.write '03 0xff 0xff 0xff 0xff'\r"
32+
expect "Attempting to write"
33+
sleep 5
34+
35+
# Write an entire screen with increment values
36+
send -- "gatt.write '03 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 \
37+
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 \
38+
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 \
39+
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88'\r"
40+
expect "Attempting to write"
41+
sleep 5
42+
43+
# 6. Exit streaming mode (if needed)
44+
# (0x02 = streaming_setting, 0x01 = leave streaming mode)
45+
send -- "gatt.write '02 01'\r"
46+
expect "Attempting to write"
47+
sleep 1
48+
49+
send -- "exit\r"
50+
expect eof

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ uint8_t stream_bitmap(uint8_t *params, uint16_t len)
295295
return -1;
296296
}
297297

298-
tmos_memcpy(fb, params, min(LED_COLS, len));
298+
tmos_memcpy(fb, params, min(LED_COLS * 2, len));
299299
return 0;
300300
}
301301

0 commit comments

Comments
 (0)