Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ (ble): Add CoreGattServerEventHandler #490

Conversation

YannLocatelli
Copy link
Member

Need #486 #489

@codecov
Copy link

codecov bot commented Feb 9, 2022

Codecov Report

Merging #490 (49d79af) into develop (c2d810a) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##           develop      #490   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           83        87    +4     
  Lines         1351      1395   +44     
=========================================
+ Hits          1351      1395   +44     
Impacted Files Coverage Δ
libs/BLEKit/include/CoreGattServerEventHandler.h 100.00% <100.00%> (ø)
libs/BLEKit/include/internal/BLEService.h 100.00% <100.00%> (ø)
libs/BLEKit/source/CoreGattServerEventHandler.cpp 100.00% <100.00%> (ø)
include/interface/drivers/LED.h 100.00% <0.00%> (ø)
drivers/CoreLED/include/CoreLED.h 100.00% <0.00%> (ø)
drivers/CoreLED/include/RGB.h 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c2d810a...49d79af. Read the comment docs.

@github-actions
Copy link

github-actions bot commented Feb 9, 2022

File comparision analysis report

🔖 Info

Target Flash Used (%) Flash Available (%) Static RAM (%)
bootloader 137588 (52%) 124556 (47%) 29360 (5%)
os 74772 (4%) 1489900 (95%) 12328 (2%)
Click to show memory sections
| -          |      Hex |     Bytes |  KiB |
|------------|---------:|----------:|-----:|
| Flash      | 0x200000 | 2 097 152 | 2048 |
| SRAM       |  0x80000 |   524 288 |  512 |
| Bootloader |  0x40000 |   262 144 |  256 |
| Header     |   0x1000 |     4 096 |    4 |
| OS         | 0x17E000 | 1 564 672 | 1528 |
| Tail       |   0x1000 |     4 096 |    4 |
| Scratch    |  0x40000 |   262 144 |  256 |

📝 Summary

Click to show summary
  • ✔️ - existing target
  • ✨ - new target
  • ⚰️ - deleted target
  • ✅ - files are the same
  • ❌ - files are different
Target Status .bin .map Total Flash (base/head) Total Flash Δ Static RAM (base/head) Static RAM Δ
LekaOS ✔️ 74772 (3%) ø 12328 (2%) ø
bootloader ✔️ 137588 (6%) ø 29360 (5%) ø
certs_emc_ble_bt_lcd_led_motors ✔️ 249184 (11%) ø 29240 (5%) ø
certs_emc_ble_led_motors ✔️ 174568 (8%) ø 24952 (4%) ø
certs_emc_bt_lcd_qspi_rfid_touch_wifi ✔️ 148840 (7%) ø 22528 (4%) ø
certs_emc_lcd_led_motors ✔️ 91928 (4%) ø 16168 (3%) ø
hardware_motors_test_reduction_and_wheels ✔️ 177960 (8%) ø 24360 (4%) ø
spike_lk_ble ✔️ 169340 (8%)
169532 (8%)
📈
192 (0%)
23160 (4%) ø
spike_lk_bluetooth ✔️ 73256 (3%) ø 11448 (2%) ø
spike_lk_cg_animations ✔️ 141112 (6%) ø 24464 (4%) ø
spike_lk_coreled ✔️ 76164 (3%)
75764 (3%)
📉
-400 (0%)
13688 (2%)
13664 (2%)
📉
-24 (0%)
spike_lk_event_queue ✔️ 74736 (3%)
73452 (3%)
📉
-1284 (-1%)
12072 (2%)
11776 (2%)
📉
-296 (-2%)
spike_lk_file_reception ✔️ 324516 (15%) ø 27520 (5%) ø
spike_lk_flash_memory ✔️ 63880 (3%) ø 11448 (2%) ø
spike_lk_lcd ✔️ 136976 (6%) ø 24024 (4%) ø
spike_lk_led ✔️ 65744 (3%) ø 13392 (2%) ø
spike_lk_log_kit ✔️ 68528 (3%) ø 11912 (2%) ø
spike_lk_motors ✔️ 62528 (2%) ø 11488 (2%) ø
spike_lk_rfid ✔️ 73072 (3%) ø 11448 (2%) ø
spike_lk_sensors_battery ✔️ 63072 (3%) ø 11984 (2%) ø
spike_lk_sensors_light ✔️ 60056 (2%) ø 11440 (2%) ø
spike_lk_sensors_microphone ✔️ 72496 (3%) ø 11504 (2%) ø
spike_lk_sensors_temperature_humidity ✔️ 66968 (3%) ø 11424 (2%) ø
spike_lk_sensors_touch ✔️ 68600 (3%) ø 11432 (2%) ø
spike_lk_ticker_timeout ✔️ 69052 (3%) ø 11632 (2%) ø
spike_lk_update_process_app_base ✔️ 121348 (5%) ø 15288 (2%) ø
spike_lk_update_process_app_update ✔️ 77632 (3%) ø 12352 (2%) ø
spike_lk_wifi ✔️ 116392 (5%) ø 14808 (2%) ø
spike_mbed_blinky ✔️ 57968 (2%) ø 11400 (2%) ø
spike_mbed_watchdog_ticker_vs_thread ✔️ 63208 (3%) ø 12448 (2%) ø
spike_stl_cxxsupport ✔️ 58456 (2%) ø 11400 (2%) ø

🗺️ Map files diff output

Click to show diff list
spike_lk_ble (click to expand)
--- build_artifacts/base_ref-build-enable_log_debug-OFF/spike_lk_ble-map.txt	2022-02-22 20:58:00.905022002 +0000
+++ build_artifacts/head_ref-build-enable_log_debug-OFF/spike_lk_ble-map.txt	2022-02-22 20:58:01.169023508 +0000
@@ -1,16 +1,16 @@
 | Module                 |           .text |       .data |          .bss |
 |------------------------|-----------------|-------------|---------------|
-| [fill]                 |       322(+322) |     11(+11) |       70(+70) |
+| [fill]                 |       342(+342) |     11(+11) |       70(+70) |
 | [lib]/BLEKit.a         |       798(+798) |       0(+0) |         0(+0) |
-| [lib]/CoreEventQueue.a |       204(+204) |       0(+0) |         0(+0) |
+| [lib]/CoreEventQueue.a |       376(+376) |       0(+0) |         0(+0) |
 | [lib]/c.a              |   26128(+26128) | 2472(+2472) |       58(+58) |
 | [lib]/gcc.a            |     7084(+7084) |       0(+0) |         0(+0) |
 | [lib]/mbed-os-static.a | 115844(+115844) |   689(+689) | 19084(+19084) |
 | [lib]/misc             |       188(+188) |       4(+4) |       28(+28) |
 | [lib]/nosys.a          |         32(+32) |       0(+0) |         0(+0) |
 | [lib]/stdc++.a         |     4116(+4116) |       8(+8) |       28(+28) |
 | main.cpp.obj           |       360(+360) |       0(+0) |     420(+420) |
-| Subtotals              | 155076(+155076) | 3184(+3184) | 19688(+19688) |
+| Subtotals              | 155268(+155268) | 3184(+3184) | 19688(+19688) |
 Total Static RAM memory (data + bss): 22872(+22872) bytes
-Total Flash memory (text + data): 158260(+158260) bytes
+Total Flash memory (text + data): 158452(+158452) bytes
 
Flash used: 169532&nbsp;(8%) / total: 2097152
SRAM used: 23160&nbsp;(4%) / total: 524288
spike_lk_coreled (click to expand)
--- build_artifacts/base_ref-build-enable_log_debug-OFF/spike_lk_coreled-map.txt	2022-02-22 20:58:02.265029763 +0000
+++ build_artifacts/head_ref-build-enable_log_debug-OFF/spike_lk_coreled-map.txt	2022-02-22 20:58:02.449030813 +0000
@@ -1,16 +1,16 @@
 | Module                 |         .text |       .data |          .bss |
 |------------------------|---------------|-------------|---------------|
-| [fill]                 |     126(+126) |       8(+8) |       26(+26) |
+| [fill]                 |     106(+106) |       8(+8) |       26(+26) |
 | [lib]/CoreSPI.a        |       28(+28) |       0(+0) |         0(+0) |
 | [lib]/HelloWorld.a     |       94(+94) |       0(+0) |         0(+0) |
 | [lib]/c.a              | 26028(+26028) | 2472(+2472) |       58(+58) |
 | [lib]/gcc.a            |   6924(+6924) |       0(+0) |         0(+0) |
 | [lib]/mbed-os-static.a | 26306(+26306) |   444(+444) |   9946(+9946) |
 | [lib]/misc             |     188(+188) |       4(+4) |       28(+28) |
 | [lib]/nosys.a          |       32(+32) |       0(+0) |         0(+0) |
 | [lib]/stdc++.a         |   5356(+5356) |       8(+8) |       44(+44) |
-| main.cpp.obj           |   2026(+2026) |       0(+0) |     362(+362) |
-| Subtotals              | 67108(+67108) | 2936(+2936) | 10464(+10464) |
-Total Static RAM memory (data + bss): 13400(+13400) bytes
-Total Flash memory (text + data): 70044(+70044) bytes
+| main.cpp.obj           |   1662(+1662) |       0(+0) |     338(+338) |
+| Subtotals              | 66724(+66724) | 2936(+2936) | 10440(+10440) |
+Total Static RAM memory (data + bss): 13376(+13376) bytes
+Total Flash memory (text + data): 69660(+69660) bytes
 
Flash used: 75764&nbsp;(3%) / total: 2097152
SRAM used: 13664&nbsp;(2%) / total: 524288
spike_lk_event_queue (click to expand)
--- build_artifacts/base_ref-build-enable_log_debug-OFF/spike_lk_event_queue-map.txt	2022-02-22 20:58:02.685032160 +0000
+++ build_artifacts/head_ref-build-enable_log_debug-OFF/spike_lk_event_queue-map.txt	2022-02-22 20:58:02.865033188 +0000
@@ -1,15 +1,15 @@
 | Module                 |         .text |       .data |        .bss |
 |------------------------|---------------|-------------|-------------|
-| [fill]                 |     106(+106) |       8(+8) |     20(+20) |
-| [lib]/CoreEventQueue.a |       76(+76) |       0(+0) |       0(+0) |
+| [fill]                 |     120(+120) |       8(+8) |     24(+24) |
+| [lib]/CoreEventQueue.a |     280(+280) |       0(+0) |       0(+0) |
 | [lib]/c.a              | 26028(+26028) | 2472(+2472) |     58(+58) |
 | [lib]/gcc.a            |   7084(+7084) |       0(+0) |       0(+0) |
 | [lib]/mbed-os-static.a | 27350(+27350) |   444(+444) | 8098(+8098) |
 | [lib]/misc             |     188(+188) |       4(+4) |     28(+28) |
 | [lib]/nosys.a          |       32(+32) |       0(+0) |       0(+0) |
-| [lib]/stdc++.a         |   4760(+4760) |       8(+8) |     44(+44) |
-| main.cpp.obj           |   1516(+1516) |       0(+0) |   600(+600) |
-| Subtotals              | 67140(+67140) | 2936(+2936) | 8848(+8848) |
-Total Static RAM memory (data + bss): 11784(+11784) bytes
-Total Flash memory (text + data): 70076(+70076) bytes
+| [lib]/stdc++.a         |   4116(+4116) |       8(+8) |     28(+28) |
+| main.cpp.obj           |     982(+982) |       0(+0) |   316(+316) |
+| Subtotals              | 66180(+66180) | 2936(+2936) | 8552(+8552) |
+Total Static RAM memory (data + bss): 11488(+11488) bytes
+Total Flash memory (text + data): 69116(+69116) bytes
 
Flash used: 73452&nbsp;(3%) / total: 2097152
SRAM used: 11776&nbsp;(2%) / total: 524288

@github-actions
Copy link

github-actions bot commented Feb 9, 2022

File comparision analysis report

🔖 Info

Target Flash Used (%) Flash Available (%) Static RAM (%)
bootloader 137588 (52%) 124556 (47%) 29360 (5%)
os 88648 (5%) 1476024 (94%) 18352 (3%)
Click to show memory sections
| -          |      Hex |     Bytes |  KiB |
|------------|---------:|----------:|-----:|
| Flash      | 0x200000 | 2 097 152 | 2048 |
| SRAM       |  0x80000 |   524 288 |  512 |
| Bootloader |  0x40000 |   262 144 |  256 |
| Header     |   0x1000 |     4 096 |    4 |
| OS         | 0x17E000 | 1 564 672 | 1528 |
| Tail       |   0x1000 |     4 096 |    4 |
| Scratch    |  0x40000 |   262 144 |  256 |

📝 Summary

Click to show summary
  • ✔️ - existing target
  • ✨ - new target
  • ⚰️ - deleted target
  • ✅ - files are the same
  • ❌ - files are different
Target Status .bin .map Total Flash (base/head) Total Flash Δ Static RAM (base/head) Static RAM Δ
LekaOS ✔️ 88648 (4%) ø 18352 (3%) ø
bootloader ✔️ 137588 (6%) ø 29360 (5%) ø
certs_emc_ble_bt_lcd_led_motors ✔️ 256728 (12%) ø 35272 (6%) ø
certs_emc_ble_led_motors ✔️ 191600 (9%) ø 30976 (5%) ø
certs_emc_bt_lcd_qspi_rfid_touch_wifi ✔️ 165248 (7%) ø 28680 (5%) ø
certs_emc_lcd_led_motors ✔️ 91928 (4%) ø 16168 (3%) ø
hardware_motors_test_reduction_and_wheels ✔️ 194032 (9%) ø 30384 (5%) ø
spike_lk_ble ✔️ 178608 (8%)
178736 (8%)
📈
128 (0%)
29112 (5%) ø
spike_lk_bluetooth ✔️ 91192 (4%) ø 17472 (3%) ø
spike_lk_cg_animations ✔️ 149384 (7%) ø 30464 (5%) ø
spike_lk_coreled ✔️ 88556 (4%)
88140 (4%)
📉
-416 (0%)
19632 (3%)
19608 (3%)
📉
-24 (0%)
spike_lk_event_queue ✔️ 84664 (4%)
83384 (3%)
📉
-1280 (-1%)
18136 (3%)
17728 (3%)
📉
-408 (-2%)
spike_lk_file_reception ✔️ 329452 (15%) ø 33480 (6%) ø
spike_lk_flash_memory ✔️ 87352 (4%) ø 17512 (3%) ø
spike_lk_lcd ✔️ 149792 (7%) ø 30096 (5%) ø
spike_lk_led ✔️ 88808 (4%) ø 19400 (3%) ø
spike_lk_log_kit ✔️ 92000 (4%) ø 18168 (3%) ø
spike_lk_motors ✔️ 86576 (4%) ø 17552 (3%) ø
spike_lk_rfid ✔️ 91008 (4%) ø 17472 (3%) ø
spike_lk_sensors_battery ✔️ 86744 (4%) ø 18056 (3%) ø
spike_lk_sensors_light ✔️ 84584 (4%) ø 17512 (3%) ø
spike_lk_sensors_microphone ✔️ 85336 (4%) ø 17512 (3%) ø
spike_lk_sensors_temperature_humidity ✔️ 90896 (4%) ø 17496 (3%) ø
spike_lk_sensors_touch ✔️ 92248 (4%) ø 17632 (3%) ø
spike_lk_ticker_timeout ✔️ 83224 (3%) ø 17592 (3%) ø
spike_lk_update_process_app_base ✔️ 143764 (6%) ø 21352 (4%) ø
spike_lk_update_process_app_update ✔️ 100968 (4%) ø 18472 (3%) ø
spike_lk_wifi ✔️ 131280 (6%) ø 20832 (3%) ø
spike_mbed_blinky ✔️ 57968 (2%) ø 11400 (2%) ø
spike_mbed_watchdog_ticker_vs_thread ✔️ 84688 (4%) ø 18448 (3%) ø
spike_stl_cxxsupport ✔️ 84000 (4%) ø 17536 (3%) ø

🗺️ Map files diff output

Click to show diff list
spike_lk_ble (click to expand)
--- build_artifacts/base_ref-build-enable_log_debug-ON/spike_lk_ble-map.txt	2022-02-22 20:58:01.584001309 +0000
+++ build_artifacts/head_ref-build-enable_log_debug-ON/spike_lk_ble-map.txt	2022-02-22 20:58:01.844025069 +0000
@@ -1,18 +1,18 @@
 | Module                  |           .text |       .data |          .bss |
 |-------------------------|-----------------|-------------|---------------|
-| [fill]                  |       346(+346) |     11(+11) |       74(+74) |
+| [fill]                  |       320(+320) |     11(+11) |       74(+74) |
 | [lib]/BLEKit.a          |       798(+798) |       0(+0) |         0(+0) |
-| [lib]/CoreEventQueue.a  |       172(+172) |       0(+0) |         0(+0) |
+| [lib]/CoreEventQueue.a  |       326(+326) |       0(+0) |         0(+0) |
 | [lib]/CriticalSection.a |           8(+8) |       0(+0) |         0(+0) |
 | [lib]/c.a               |   26152(+26152) | 2472(+2472) |       58(+58) |
 | [lib]/gcc.a             |     7148(+7148) |       0(+0) |         0(+0) |
 | [lib]/m.a               |       360(+360) |       0(+0) |         0(+0) |
 | [lib]/mbed-os-static.a  | 119384(+119384) |   689(+689) | 19120(+19120) |
 | [lib]/misc              |       188(+188) |       4(+4) |       28(+28) |
 | [lib]/nosys.a           |         32(+32) |       0(+0) |         0(+0) |
 | [lib]/stdc++.a          |     5424(+5424) |       8(+8) |       44(+44) |
 | main.cpp.obj            |     2504(+2504) |       0(+0) |   6316(+6316) |
-| Subtotals               | 162516(+162516) | 3184(+3184) | 25640(+25640) |
+| Subtotals               | 162644(+162644) | 3184(+3184) | 25640(+25640) |
 Total Static RAM memory (data + bss): 28824(+28824) bytes
-Total Flash memory (text + data): 165700(+165700) bytes
+Total Flash memory (text + data): 165828(+165828) bytes
 
Flash used: 178736&nbsp;(8%) / total: 2097152
SRAM used: 29112&nbsp;(5%) / total: 524288
spike_lk_coreled (click to expand)
--- build_artifacts/base_ref-build-enable_log_debug-ON/spike_lk_coreled-map.txt	2022-02-22 20:58:03.004131075 +0000
+++ build_artifacts/head_ref-build-enable_log_debug-ON/spike_lk_coreled-map.txt	2022-02-22 20:58:03.184147524 +0000
@@ -1,18 +1,18 @@
 | Module                  |         .text |       .data |          .bss |
 |-------------------------|---------------|-------------|---------------|
-| [fill]                  |     134(+134) |       8(+8) |       30(+30) |
+| [fill]                  |     114(+114) |       8(+8) |       30(+30) |
 | [lib]/CoreSPI.a         |       28(+28) |       0(+0) |         0(+0) |
 | [lib]/CriticalSection.a |         8(+8) |       0(+0) |         0(+0) |
 | [lib]/HelloWorld.a      |       94(+94) |       0(+0) |         0(+0) |
 | [lib]/c.a               | 26052(+26052) | 2472(+2472) |       58(+58) |
 | [lib]/gcc.a             |   7148(+7148) |       0(+0) |         0(+0) |
 | [lib]/m.a               |     360(+360) |       0(+0) |         0(+0) |
 | [lib]/mbed-os-static.a  | 33996(+33996) |   444(+444) |   9990(+9990) |
 | [lib]/misc              |     188(+188) |       4(+4) |       28(+28) |
 | [lib]/nosys.a           |       32(+32) |       0(+0) |         0(+0) |
 | [lib]/stdc++.a          |   5864(+5864) |       8(+8) |       44(+44) |
-| main.cpp.obj            |   4004(+4004) |       0(+0) |   6258(+6258) |
-| Subtotals               | 77908(+77908) | 2936(+2936) | 16408(+16408) |
-Total Static RAM memory (data + bss): 19344(+19344) bytes
-Total Flash memory (text + data): 80844(+80844) bytes
+| main.cpp.obj            |   3640(+3640) |       0(+0) |   6234(+6234) |
+| Subtotals               | 77524(+77524) | 2936(+2936) | 16384(+16384) |
+Total Static RAM memory (data + bss): 19320(+19320) bytes
+Total Flash memory (text + data): 80460(+80460) bytes
 
Flash used: 88140&nbsp;(4%) / total: 2097152
SRAM used: 19608&nbsp;(3%) / total: 524288
spike_lk_event_queue (click to expand)
--- build_artifacts/base_ref-build-enable_log_debug-ON/spike_lk_event_queue-map.txt	2022-02-22 20:58:03.424169457 +0000
+++ build_artifacts/head_ref-build-enable_log_debug-ON/spike_lk_event_queue-map.txt	2022-02-22 20:58:03.604185906 +0000
@@ -1,17 +1,17 @@
 | Module                  |         .text |       .data |          .bss |
 |-------------------------|---------------|-------------|---------------|
-| [fill]                  |     150(+150) |       8(+8) |       20(+20) |
-| [lib]/CoreEventQueue.a  |       44(+44) |       0(+0) |         0(+0) |
+| [fill]                  |     168(+168) |       8(+8) |       24(+24) |
+| [lib]/CoreEventQueue.a  |     248(+248) |       0(+0) |         0(+0) |
 | [lib]/CriticalSection.a |         8(+8) |       0(+0) |         0(+0) |
 | [lib]/c.a               | 26052(+26052) | 2472(+2472) |       58(+58) |
 | [lib]/gcc.a             |   7148(+7148) |       0(+0) |         0(+0) |
 | [lib]/m.a               |     360(+360) |       0(+0) |         0(+0) |
 | [lib]/mbed-os-static.a  | 30906(+30906) |   444(+444) |   8138(+8138) |
 | [lib]/misc              |     188(+188) |       4(+4) |       28(+28) |
 | [lib]/nosys.a           |       32(+32) |       0(+0) |         0(+0) |
 | [lib]/stdc++.a          |   5424(+5424) |       8(+8) |       44(+44) |
-| main.cpp.obj            |   4908(+4908) |       0(+0) |   6624(+6624) |
-| Subtotals               | 75220(+75220) | 2936(+2936) | 14912(+14912) |
-Total Static RAM memory (data + bss): 17848(+17848) bytes
-Total Flash memory (text + data): 78156(+78156) bytes
+| main.cpp.obj            |   3662(+3662) |       0(+0) |   6212(+6212) |
+| Subtotals               | 74196(+74196) | 2936(+2936) | 14504(+14504) |
+Total Static RAM memory (data + bss): 17440(+17440) bytes
+Total Flash memory (text + data): 77132(+77132) bytes
 
Flash used: 83384&nbsp;(3%) / total: 2097152
SRAM used: 17728&nbsp;(3%) / total: 524288

@YannLocatelli YannLocatelli force-pushed the yann/feature/ble/gatt/add-core-gatt-server-event-handler branch from 3626803 to e975d48 Compare February 11, 2022 12:27
Copy link
Member

@ladislas ladislas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed! 👍 j'ai été un peu extensif, j'espère que c'est compréhensible :)

Comment on lines 15 to 16
using updateServiceFunction =
std::function<void(GattAttribute::Handle_t characteristic_updated, const uint8_t *data, uint16_t n_data_bytes)>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je suis pas super fan que cet alias soit dans le global namespace leka, elle peut être mise dans l'interface ou la class?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je la renommerai pour bien faire comprendre que c'est un type

Suggested change
using updateServiceFunction =
std::function<void(GattAttribute::Handle_t characteristic_updated, const uint8_t *data, uint16_t n_data_bytes)>;
using update_service_function_t =
std::function<void(GattAttribute::Handle_t handle, const uint8_t *data, uint16_t size)>;

et elle dit service alors qu'elle est utilisée dans updateData --> peut être qu'il faut harmoniser les noms utilisés pour simplifier la compréhension

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

et elle peut pas prendre un span plutôt qu'un * et un size?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est déplacé

--

L'idée du span est intéressant mais il y a un bémol dans l'usage: parfois uint8_t *data pointe vers une variable de type uint8_t ou bool, donc pas nécessairement un type array

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est pas très grave si c'est pas un array, si c'est juste une variable, tu peux faire passer std::span{&i, 1}

exemple: https://gcc.godbolt.org/z/nhPY7jKj7

include/interface/drivers/BLEService.h Outdated Show resolved Hide resolved
Comment on lines 23 to 24
BLEService(const UUID &uuid, std::span<GattCharacteristic *> characteristics, unsigned characteristics_count)
: GattService(uuid, characteristics.data(), characteristics_count) {};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

est-ce qu'on se mettrait pas const UUID &uuid, std::span<GattCharacteristic *> characteristics, unsigned characteristics_count dans une struct?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

à minima

Suggested change
BLEService(const UUID &uuid, std::span<GattCharacteristic *> characteristics, unsigned characteristics_count)
: GattService(uuid, characteristics.data(), characteristics_count) {};
BLEService(const UUID &uuid, std::span<GattCharacteristic *> characteristics)
: GattService(uuid, characteristics.data(), std::size(characteristics) {};

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Le characteristics_count a été retiré

include/interface/drivers/BLEService.h Outdated Show resolved Hide resolved
Comment on lines 26 to 27
virtual void onDataWritten(const GattWriteCallbackParams &params) = 0;
virtual void updateData(updateServiceFunction &update) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je pense que tu as même pas besoin de virtual ici, à moins de vouloir savoir avec quoi elles sont appelées et encore.

tu peux juste avoir ta struct de base qui implémente rien (ça donnera un linker error si tu essaye de l'utiliser) et ta classe qui implémente un service qui elle donnera l'implementation concrète

comme ici https://gcc.godbolt.org/z/zbhafPs5o

Comment on lines 82 to 95
const UUID uuid {0x0001};
static const uint8_t serivce_1_characteristics_count {1};
static const uint8_t serivce_2_characteristics_count {2};
static const uint8_t services_count {2};
uint8_t characteristic_value {};
ReadOnlyGattCharacteristic<uint8_t> writable_characteristic {0x1234, &characteristic_value};
std::array<GattCharacteristic *, serivce_1_characteristics_count> service_1_characteristic_table {
&writable_characteristic};
std::array<GattCharacteristic *, serivce_2_characteristics_count> service_2_characteristic_table {
&writable_characteristic, &writable_characteristic};
mock::BLEService mock_service_1 =
mock::BLEService(uuid, service_1_characteristic_table, serivce_1_characteristics_count);
mock::BLEService mock_service_2 =
mock::BLEService(uuid, service_2_characteristic_table, serivce_2_characteristics_count);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est très dur à lire et à suivre.

il faut mettre un peu plus d'auto et std::to_array et raccourcir le nom des variables.

Suggested change
const UUID uuid {0x0001};
static const uint8_t serivce_1_characteristics_count {1};
static const uint8_t serivce_2_characteristics_count {2};
static const uint8_t services_count {2};
uint8_t characteristic_value {};
ReadOnlyGattCharacteristic<uint8_t> writable_characteristic {0x1234, &characteristic_value};
std::array<GattCharacteristic *, serivce_1_characteristics_count> service_1_characteristic_table {
&writable_characteristic};
std::array<GattCharacteristic *, serivce_2_characteristics_count> service_2_characteristic_table {
&writable_characteristic, &writable_characteristic};
mock::BLEService mock_service_1 =
mock::BLEService(uuid, service_1_characteristic_table, serivce_1_characteristics_count);
mock::BLEService mock_service_2 =
mock::BLEService(uuid, service_2_characteristic_table, serivce_2_characteristics_count);
ReadOnlyGattCharacteristic<uint8_t> charac {0x1234, 0};
auto s1_charac_table = std::to_array<GattCharacteristic *>({&charac}); // ? One characteristic
auto s2_charac_table = std::to_array<GattCharacteristic *>({&charac, &charac}); // ? Two characteristics
const UUID s1_uuid {0x0001};
auto s1 = mock::BLEService(s1_uuid, s1_charac_table, std::size(s1_charac_table);
const UUID s2_uuid {0x0002};
auto s1 = mock::BLEService(s2_uuid, s2_charac_table, std::size(s2_charac_table);

libs/BLEKit/tests/CoreGattServerEventHandler_test.cpp Outdated Show resolved Hide resolved
libs/BLEKit/tests/CoreGattServerEventHandler_test.cpp Outdated Show resolved Hide resolved
libs/BLEKit/tests/CoreGattServerEventHandler_test.cpp Outdated Show resolved Hide resolved
libs/BLEKit/tests/CoreGattServerEventHandler_test.cpp Outdated Show resolved Hide resolved
@YannLocatelli YannLocatelli force-pushed the yann/feature/ble/gatt/add-core-gatt-server-event-handler branch from e9807d0 to 63242a0 Compare February 21, 2022 17:38
@YannLocatelli YannLocatelli force-pushed the yann/feature/ble/gatt/add-core-gatt-server-event-handler branch from 63242a0 to f800cd6 Compare February 21, 2022 17:41
Copy link
Member

@ladislas ladislas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c'est beaucoup plus clair, merci @YannLocatelli ! 👍

j'ai encore fait quelques retours, en particulier, j'avais du mal à voir comment BLEService allait ensuite s'intégrer avec le reste, du coup j'ai fait un exemple ici

https://gcc.godbolt.org/z/xv6dxcv1M

je continue sur slack, parce que ça m'a donné d'autres idées.

#include "ble/gatt/GattCharacteristic.h"
#include "ble/gatt/GattService.h"

namespace leka::interface {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dans la mesure où on propose une implémentation de certaines fonctions, ce n'est pas "vraiment" une interface.

je le mettrai juste dans leka

je vois aussi qu'il est dans internal, c'est qu'il n'aura pas de visibilité public?

dans ce cas là il faudrait qu'il soit dans leka::ble::internal mais le ble risque de faire des bugs avec le ble de mbed...
ou alors le mettre dans include

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah oui, c'est le fait d'avoir retiré les virtual qui fait qu'on a perdu le caractère de interface

Ce qui me gène, c'est que c'est un modèle et qu'il ne devrait pas donner l'idée qu'il puisse être utilisé autre qu'en tant que modèle. C'est aussi dans ce sens que va le internal...

Mais si on regarde dans le futur avec les dernières suggestions, dans la PR #485, on est amené à instancié un array avec du interface::BLEService *

libs/BLEKit/include/internal/BLEService.h Outdated Show resolved Hide resolved
Comment on lines 27 to 30
virtual void onDataWritten(const GattWriteCallbackParams &params) = 0;

virtual void registerUpdateDataFunction(update_data_function_t const &function) = 0;
virtual void updateData() = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j'ai toujours du mal avec les noms. Je trouve que onDataWritten il est pas assez spécifique parce qu'en pratique on écrit dans les deux sens : soit quelqu'un nous écrit et on lit (ce qui l'usage là) soit on "écrit" pour update dans le server.

je pense à un truc comme ça:

Suggested change
virtual void onDataWritten(const GattWriteCallbackParams &params) = 0;
virtual void registerUpdateDataFunction(update_data_function_t const &function) = 0;
virtual void updateData() = 0;
using data_received_handle_t = GattWriteCallbackParams;
using data_to_send_handle_t = std::tuple<GattAttribute::Handle_t, const uint8_t *, uint16_t>
virtual void onDataReceived(const data_received_handle_t &handle) = 0;
virtual void onDataReadyToSend(std::function<void(const data_to_send_handle_t &)> callback) = 0;

j'avais du mal à comprendre après comment tout ça allait s'orchestrer entre ce que fait le service et le gattserver, du coup j'ai créé un exemple pour m'aider

https://gcc.godbolt.org/z/xv6dxcv1M

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

En relisant, c'est celui dans l'event handler qu'on ne peut pas le changer.

Ici comme le Service a été dissocié de l'event handler, on peut aujourd'hui lui donner le nom qu'on souhaite


Je vais me répéter mais la PR #485 permet de voir ce à quoi va ressembler un système qui utilise le server et des (un) services

Et actuellement il fait que du "setup" et n'est pas utilisé "on run": définir l'event handler pour le BLE, définir quels services vont être utilisés, définir comment écrire sur le serveur

libs/BLEKit/source/CoreGattServerEventHandler.cpp Outdated Show resolved Hide resolved
libs/BLEKit/tests/CoreGattServerEventHandler_test.cpp Outdated Show resolved Hide resolved
libs/BLEKit/tests/CoreGattServerEventHandler_test.cpp Outdated Show resolved Hide resolved
@sonarcloud
Copy link

sonarcloud bot commented Feb 22, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@ladislas ladislas closed this in 7964c71 Feb 24, 2022
@ladislas ladislas deleted the yann/feature/ble/gatt/add-core-gatt-server-event-handler branch February 25, 2022 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants