mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-26 00:40:38 +00:00
hfp fix indicator status query
This commit is contained in:
parent
5d5e77a91a
commit
cbcc10bb1b
@ -172,7 +172,7 @@ typedef struct hfp_connection {
|
|||||||
hfp_state_t state;
|
hfp_state_t state;
|
||||||
|
|
||||||
uint32_t line_size;
|
uint32_t line_size;
|
||||||
uint8_t line_buffer[20];
|
uint8_t line_buffer[200];
|
||||||
|
|
||||||
bd_addr_t remote_addr;
|
bd_addr_t remote_addr;
|
||||||
uint16_t con_handle;
|
uint16_t con_handle;
|
||||||
|
26
src/hfp_hf.c
26
src/hfp_hf.c
@ -197,8 +197,8 @@ static void hfp_run_for_context(hfp_connection_t * connection){
|
|||||||
if (!err) connection->state = HFP_W4_RETRIEVE_INDICATORS;
|
if (!err) connection->state = HFP_W4_RETRIEVE_INDICATORS;
|
||||||
break;
|
break;
|
||||||
case HFP_RETRIEVE_INDICATORS_STATUS:
|
case HFP_RETRIEVE_INDICATORS_STATUS:
|
||||||
err = hfp_hs_retrieve_indicators_cmd(connection->rfcomm_cid);
|
err = hfp_hs_retrieve_indicators_status_cmd(connection->rfcomm_cid);
|
||||||
if (!err) connection->state = HFP_W4_EXCHANGE_SUPPORTED_FEATURES;
|
if (!err) connection->state = HFP_W4_RETRIEVE_INDICATORS_STATUS;
|
||||||
break;
|
break;
|
||||||
case HFP_ENABLE_INDICATORS_STATUS_UPDATE:
|
case HFP_ENABLE_INDICATORS_STATUS_UPDATE:
|
||||||
if (connection->remote_indicators_update_enabled == 0){
|
if (connection->remote_indicators_update_enabled == 0){
|
||||||
@ -283,6 +283,16 @@ void hfp_parse_indicators(hfp_connection_t * context, uint8_t *packet, uint16_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void hfp_parse_indicators_status(hfp_connection_t * context, uint8_t *packet, uint16_t size){
|
||||||
|
int index = 0;
|
||||||
|
char * token = strtok((char*)&packet[0], ",");
|
||||||
|
while (token){
|
||||||
|
printf("Indicator %d status: %d \n", index, atoi(token));
|
||||||
|
index++;
|
||||||
|
token = strtok(NULL, ",");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
hfp_connection_t * handle_message(hfp_connection_t * context, uint8_t *packet, uint16_t size){
|
hfp_connection_t * handle_message(hfp_connection_t * context, uint8_t *packet, uint16_t size){
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
if (context->wait_ok){
|
if (context->wait_ok){
|
||||||
@ -342,23 +352,17 @@ hfp_connection_t * handle_message(hfp_connection_t * context, uint8_t *packet, u
|
|||||||
// printf("Parsed %s, expected ("service",(0,1)),("call",(0,1)),("callsetup",(0,3)),("callheld",(0,2)),("signal",(0,5)),("roam",(0,1)),("battchg",(0,5))\n", HFP_Indicator);
|
// printf("Parsed %s, expected ("service",(0,1)),("call",(0,1)),("callsetup",(0,3)),("callheld",(0,2)),("signal",(0,5)),("roam",(0,1)),("battchg",(0,5))\n", HFP_Indicator);
|
||||||
|
|
||||||
offset = strlen(HFP_Indicator) + 1;
|
offset = strlen(HFP_Indicator) + 1;
|
||||||
char * token = strtok((char*)&packet[offset], ",");
|
|
||||||
int pos = 0;
|
|
||||||
switch (context->state){
|
switch (context->state){
|
||||||
case HFP_W4_RETRIEVE_INDICATORS:
|
case HFP_W4_RETRIEVE_INDICATORS:
|
||||||
hfp_parse_indicators(context, &packet[offset], size-offset);
|
hfp_parse_indicators(context, &packet[offset], size-offset);
|
||||||
context->remote_indicators_status = 0;
|
context->remote_indicators_status = 0;
|
||||||
context->state = HFP_RETRIEVE_INDICATORS_STATUS;
|
context->state = HFP_RETRIEVE_INDICATORS_STATUS;
|
||||||
break;
|
break;
|
||||||
case HFP_W4_RETRIEVE_INDICATORS_STATUS:
|
case HFP_W4_RETRIEVE_INDICATORS_STATUS:{
|
||||||
while (token){
|
hfp_parse_indicators_status(context, &packet[offset], size-offset);
|
||||||
printf("%s\n", token);
|
|
||||||
store_bit(context->remote_indicators_status, pos, atoi(token));
|
|
||||||
pos++;
|
|
||||||
token = strtok(NULL, ",");
|
|
||||||
}
|
|
||||||
context->state = HFP_ENABLE_INDICATORS_STATUS_UPDATE;
|
context->state = HFP_ENABLE_INDICATORS_STATUS_UPDATE;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user