/** * @file app_ble_proto.h * @brief BLE frame protocol frontend (over the rdtss write/notify * characteristics): frame reassembly and CLI request/response * transport. OTA frame types are reserved but not handled in * this project (no flash OTA here). * * Frame format (little endian): * [0] SOF = 0xCA * [1] TYPE * [2] SEQ * [3:4] LEN (payload length, LE) * [5..] PAYLOAD * [end-2..end] CRC16-CCITT (init 0xFFFF, poly 0x1021), LE, over TYPE..PAYLOAD * * All functions run in the BLE schedule task context only. */ #ifndef __APP_BLE_PROTO_H__ #define __APP_BLE_PROTO_H__ #ifdef __cplusplus extern "C" { #endif #include /* Frame types */ #define BLE_FRAME_CLI_REQ 0x01 /* phone -> device: one command line */ #define BLE_FRAME_CLI_RSP 0x02 /* device -> phone: response text chunk */ #define BLE_FRAME_CLI_RSP_END 0x03 /* device -> phone: {status u8} */ #define BLE_FRAME_OTA_BEGIN 0x10 /* reserved (not supported here) */ #define BLE_FRAME_OTA_DATA 0x11 /* reserved */ #define BLE_FRAME_OTA_END 0x12 /* reserved */ #define BLE_FRAME_OTA_RSP 0x1F /* reserved */ /** * @brief Reset the protocol state machine. */ void app_ble_proto_init(void); /** * @brief Feed a received BLE write chunk into the frame reassembler. * Called from the rdtss write indication handler (BLE task context). */ void app_ble_proto_rx_bytes(const uint8_t* data, uint16_t len); /** * @brief BLE disconnect hook: drop half-received frame and uplink buffer. */ void app_ble_proto_on_disconnect(void); #ifdef __cplusplus } #endif #endif /* __APP_BLE_PROTO_H__ */