Code: Select all
struct __attribute__((__packed__))long_packet_s
{
esp_gatt_if_t gatt_if;
uint8_t* payload;
uint8_t length;
uint16_t conn_id;
uint8_t op_code;
uint8_t message_id;
interface_select_e interface;
};
Code: Select all
long_packet_s message_struct;
message_struct.gatt_if = gatts_if;
message_struct.conn_id = conn_id;
message_struct.message_id = message_id;
message_struct.op_code = op_code;
data_buf[0] = GET_FW_VERSION;
data_buf[1] = 1;
data_buf[2] = strlen(device_info.FW_version) >> 8;
data_buf[3] = strlen(device_info.FW_version) & 0x00FF;
printf("strlen(device_info.FW_version)=%u \n",strlen(device_info.FW_version));
memcpy((data_buf+4),(uint8_t*)(device_info.FW_version),strlen(device_info.FW_version));
message_struct.payload = data_buf;
message_struct.length = strlen(device_info.FW_version)+4;
for(int i = 0; i<= 4+strlen(device_info.FW_version);i++){
printf("global_message.payload[%i]=%u\n",i,message_struct.payload[i]);
}
xQueueSend(ble_parser_queue,(void*)&message_struct, 10);
And then in my queue task:
Code: Select all
static void BLE_queue_parser_task(void *argument)
{
long_packet_s data_received;
for(;;)
{
if (xQueueReceive(ble_parser_queue, &data_received, 10) == pdTRUE) {
printf("local message length = %u \n",data_received.length);
for(int i = 0; i <10;i++){
printf("local payload[%i]=%u\n",i,data_received.payload[i]);
}
}
}
}
Code: Select all
strlen(device_info.FW_version)=5
global_message.payload[0]=2
global_message.payload[1]=1
global_message.payload[2]=0
global_message.payload[3]=5
global_message.payload[4]=49
global_message.payload[5]=46
global_message.payload[6]=48
global_message.payload[7]=48
global_message.payload[8]=48
global_message.payload[9]=0
local message length = 9
local payload[0]=233
local payload[1]=124
local payload[2]=16
local payload[3]=128
local payload[4]=96
local payload[5]=194
local payload[6]=252
local payload[7]=63
local payload[8]=128
local payload[9]=219