[update] update gatt_msg_rsp code
This commit is contained in:
+11
-23
@@ -30,12 +30,9 @@ struct gp_timer_t gpt = {0};
|
||||
#define BLE_CHAR3_HANDLE 0x0024 // send instruction
|
||||
#define BLE_CHAR4_CONFIG_HANDLE 0x0028 // notify enable: 0100=enable; 0000=disable
|
||||
|
||||
#define RET_INFO_BUF_SIZE 52
|
||||
|
||||
#define CIS_BUFF_PREFIX 3
|
||||
#define CIS_DATA_LEN 50
|
||||
static uint16_t CIS_length = 10;
|
||||
static char CIS_data[CIS_DATA_LEN];
|
||||
static uint16_t recv_regular_data_len = 0;
|
||||
static char recv_regular_data[CIS_DATA_LEN];
|
||||
|
||||
static void mem_event_callback();
|
||||
static void mem_connect_device(uint8_t addrType, uint8_t *peerAddr);
|
||||
@@ -68,7 +65,7 @@ static EventTableEntry EVENT_TABLE[] = { //
|
||||
{0, NULL}
|
||||
};
|
||||
|
||||
static void mem_read_data_and_return()
|
||||
static void gatt_msg_rsp()
|
||||
{
|
||||
/*
|
||||
* CIS data formate:
|
||||
@@ -92,24 +89,15 @@ static void mem_read_data_and_return()
|
||||
*
|
||||
*/
|
||||
|
||||
// add prefix and suffix to sync communication
|
||||
uint16_t ret_length;
|
||||
#define MSG_RSP_LEN (recv_regular_data_len+3)
|
||||
char msg_rsp[CIS_DATA_LEN] = {0};
|
||||
|
||||
if (CIS_length < 22) {
|
||||
ret_length = 20;
|
||||
} else {
|
||||
ret_length = CIS_length - CIS_BUFF_PREFIX;
|
||||
}
|
||||
msg_rsp[0] = 4;
|
||||
msg_rsp[1] = 0;
|
||||
msg_rsp[2] = recv_regular_data_len;
|
||||
memcpy(msg_rsp+3, recv_regular_data, recv_regular_data_len);
|
||||
UART_write(uart_handle, msg_rsp, MSG_RSP_LEN);
|
||||
|
||||
CIS_data[0] = 4;
|
||||
CIS_data[1] = 0;
|
||||
CIS_data[2] = ret_length;
|
||||
CIS_data[CIS_length++] = 0;
|
||||
CIS_data[CIS_length++] = 0;
|
||||
|
||||
UART_write(uart_handle, CIS_data, ret_length + CIS_BUFF_PREFIX);
|
||||
|
||||
memset(CIS_data, 0, CIS_DATA_LEN);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -175,7 +163,7 @@ static void mem_event_callback() {
|
||||
|
||||
if(flag_mask(EVT_MEM_RETURN_DATA)){
|
||||
flag_disable(EVT_MEM_RETURN_DATA);
|
||||
mem_read_data_and_return();
|
||||
gatt_msg_rsp();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+3
-4
@@ -894,10 +894,8 @@ static void SimpleBLECentral_processGATTMsg(gattMsgEvent_t *pMsg)
|
||||
UART_write(uart_handle, "e1", 3);
|
||||
} else {
|
||||
// After a successful read, display the read value
|
||||
// CIS_length = CIS_BUFF_PREFIX + pMsg->msg.readRsp.len;
|
||||
uint8_t recv_len = pMsg->msg.readRsp.pValue[0];
|
||||
CIS_length = CIS_BUFF_PREFIX + recv_len;
|
||||
memcpy(CIS_data + CIS_BUFF_PREFIX, &pMsg->msg.readRsp.pValue[1] , recv_len);
|
||||
recv_regular_data_len = pMsg->msg.readRsp.pValue[0];
|
||||
memcpy(recv_regular_data, &pMsg->msg.readRsp.pValue[1], recv_regular_data_len);
|
||||
flag_enable(EVT_MEM_RETURN_DATA);
|
||||
}
|
||||
|
||||
@@ -1468,6 +1466,7 @@ static void SimepleBLECentral_getDeviceinfo(uint8_t i, uint8_t *pEvtData, uint8_
|
||||
|
||||
static void SimepleBLECentral_respDeviceinfo(uint8_t i, uint8_t *pEvtData, uint8_t dataLen)
|
||||
{
|
||||
#define RET_INFO_BUF_SIZE 52
|
||||
uint8_t ret_info_buf[RET_INFO_BUF_SIZE]={0};
|
||||
|
||||
struct scan_packet_hdr_t scan_packet_hdr;
|
||||
|
||||
Reference in New Issue
Block a user