Airoha M0 BLE API  1.0.5.4
ab_cmd.h
1 #ifndef __AB_VCMD_HH
2 #define __AB_VCMD_HH
3 #include <stdint.h>
4 #include <stdbool.h>
5 /*--------------------------------------------------------------------------------------------*/
6 /* Type Define */
7 /*--------------------------------------------------------------------------------------------*/
8 typedef struct
9 {
10  uint16_t op;
11  uint8_t len;
12  uint8_t *param;
13 }AB_CMD;
14 
15 typedef struct
16 {
17  uint16_t rlen;
18  uint8_t *param;
19 }AB_RESP;
20 
21 typedef struct
22 {
23  bool (*rxcb)(uint8_t* buf, uint16_t len);
24  bool (*handlers)(AB_CMD *cmd, AB_RESP *resp);
25  void (*txcb)(uint8_t* buf, uint16_t len);
26 }AB_CMD_DECODER;
27 
28 typedef bool (*AB_CMD_HANDLER)(AB_CMD *cmd, AB_RESP *resp);
29 
30 /*--------------------------------------------------------------------------------------------*/
31 /* Define */
32 /*--------------------------------------------------------------------------------------------*/
33 #include "ab_cmd_opcode.h"
34 #define AB_HANDLER_MAX 3
35 /*--------------------------------------------------------------------------------------------*/
36 /* Public */
37 /*--------------------------------------------------------------------------------------------*/
38 
39 void AB_CmdTransport(uint8_t* rbuf, uint16_t rlen, void (*txcb)(uint8_t* tbuf, uint16_t tlen));
40 bool AB_CmdSetDecoder(AB_CMD_DECODER *decoder);
41 bool AB_CmdSetHandler(uint8_t index, AB_CMD_HANDLER handler);
42 
43 #endif