ACwing FC firmware
STM32WB55: attitude IEKF, altitude Kalman filter, flight core, protocol v2
Loading...
Searching...
No Matches
ble_tlm_svc.c File Reference

"ACwing telemetry" GATT service + TX thread on STM32_WPAN (see ble_tlm_svc.h). More...

#include "ble_tlm_svc.h"
#include "app_config.h"
Include dependency graph for ble_tlm_svc.c:

Go to the source code of this file.

Functions

void ble_tlm_svc_init (void)
 After SVCCTL_Init() and before advertising starts (APP_BLE_Init_3)
 
void ble_tlm_on_connect (uint16_t conn_handle)
 
void ble_tlm_on_disconnect (void)
 

Detailed Description

"ACwing telemetry" GATT service + TX thread on STM32_WPAN (see ble_tlm_svc.h).

Protocol v2 (HANDOVER_FW.md ยง2): CMD writes are only recorded (app_link.c), the TX thread drains the two priority queues of tlm_ble.c.

Event flow HCI user-event thread (stack) -> TlmSvc_EventHandler(): only flags and counters, never an ACI call, never blocks BleTxThread (ours) -> every APP_BLE_FLUSH_MS, or when woken: connection parameters, then queued bytes as notifications of up to ATT_MTU-3 bytes

ACI calls from this thread are safe: in the FreeRTOS version of app_ble.c, BLE_StatusNot() takes MtxHciId around every HCI command (HCI_TL_CmdBusy / HCI_TL_CmdAvailable), so commands from different threads are serialised.

Flow control: aci_gatt_update_char_value() returns BLE_STATUS_INSUFFICIENT_RESOURCES when the TX pool is full (the link is slower than the data). The chunk is NOT consumed: we wait for ACI_GATT_TX_POOL_AVAILABLE (or the next tick) and retry. If the link stays slower than the production for long, the ring fills and TelemetryTask drops whole frames (STATUS.ble_drop): the stream stays consistent.

Definition in file ble_tlm_svc.c.

Function Documentation

◆ ble_tlm_svc_init()

void ble_tlm_svc_init ( void  )

After SVCCTL_Init() and before advertising starts (APP_BLE_Init_3)

Definition at line 243 of file ble_tlm_svc.c.

◆ ble_tlm_on_connect()

void ble_tlm_on_connect ( uint16_t  conn_handle)

Definition at line 244 of file ble_tlm_svc.c.

◆ ble_tlm_on_disconnect()

void ble_tlm_on_disconnect ( void  )

Definition at line 245 of file ble_tlm_svc.c.