mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 04:20:20 +00:00
hfp: capitalize defines
This commit is contained in:
parent
17c0eace3b
commit
e2898183f0
@ -183,7 +183,7 @@ static hfp_connection_t * create_hfp_connection_context(){
|
||||
context->state = HFP_IDLE;
|
||||
context->line_size = 0;
|
||||
|
||||
context->negotiated_codec = HFP_Codec_CVSD;
|
||||
context->negotiated_codec = HFP_CODEC_CVSD;
|
||||
context->remote_supported_features = 0;
|
||||
context->remote_indicators_update_enabled = 0;
|
||||
context->remote_indicators_nr = 0;
|
||||
|
21
src/hfp.h
21
src/hfp.h
@ -52,8 +52,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HFP_Default_HF_Supported_Features 0x0000
|
||||
#define HFP_Default_AG_Supported_Features 0x0009
|
||||
#define HFP_DEFAULT_HF_SUPPORTED_FEATURES 0x0000
|
||||
#define HFP_DEFAULT_AG_SUPPORTED_FEATURES 0x0009
|
||||
|
||||
#define HFP_MAX_NUM_CODECS 20
|
||||
#define HFP_MAX_NUM_INDICATORS 20
|
||||
@ -86,16 +86,17 @@ extern "C" {
|
||||
11: eSCO S4 (and T2) Settings Supported
|
||||
12-31: Reserved for future definition
|
||||
*/
|
||||
#define HFP_Supported_Features "+BRSF"
|
||||
#define HFP_Available_Codecs "+BAC"
|
||||
#define HFP_Indicator "+CIND"
|
||||
#define HFP_Enable_Indicator_Status_Update "+CMER"
|
||||
#define HFP_Support_Call_Hold_And_Multiparty_Services "+CHLD"
|
||||
#define HFP_Generic_Status_Indicator "+BIND"
|
||||
#define HFP_SUPPORTED_FEATURES "+BRSF"
|
||||
#define HFP_AVAILABLE_CODECS "+BAC"
|
||||
#define HFP_INDICATOR "+CIND"
|
||||
#define HFP_ENABLE_INDICATOR_STATUS_UPDATE "+CMER"
|
||||
#define HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES "+CHLD"
|
||||
#define HFP_GENERIC_STATUS_INDICATOR "+BIND"
|
||||
#define HFP_OK "OK"
|
||||
|
||||
#define HFP_Codec_CVSD 0x01
|
||||
#define HFP_Codec_mSBC 0x02
|
||||
// Codecs
|
||||
#define HFP_CODEC_CVSD 0x01
|
||||
#define HFP_CODEC_MSBC 0x02
|
||||
|
||||
|
||||
typedef enum {
|
||||
|
@ -62,7 +62,7 @@
|
||||
#include "hfp_ag.h"
|
||||
|
||||
static const char default_hfp_ag_service_name[] = "Voice gateway";
|
||||
static uint16_t hfp_supported_features = HFP_Default_HF_Supported_Features;
|
||||
static uint16_t hfp_supported_features = HFP_DEFAULT_HF_SUPPORTED_FEATURES;
|
||||
static uint8_t hfp_codecs_nr = 0;
|
||||
static uint8_t hfp_codecs[HFP_MAX_NUM_CODECS];
|
||||
|
||||
|
36
src/hfp_hf.c
36
src/hfp_hf.c
@ -63,7 +63,7 @@
|
||||
|
||||
|
||||
static const char default_hfp_hf_service_name[] = "Hands-Free unit";
|
||||
static uint16_t hfp_supported_features = HFP_Default_HF_Supported_Features;
|
||||
static uint16_t hfp_supported_features = HFP_DEFAULT_HF_SUPPORTED_FEATURES;
|
||||
static uint8_t hfp_codecs_nr = 0;
|
||||
static uint8_t hfp_codecs[HFP_MAX_NUM_CODECS];
|
||||
|
||||
@ -119,14 +119,14 @@ static int store_bit(uint32_t bitmap, int position, uint8_t value){
|
||||
|
||||
int hfp_hs_exchange_supported_features_cmd(uint16_t cid){
|
||||
char buffer[20];
|
||||
sprintf(buffer, "AT%s=%d\r\n", HFP_Supported_Features, hfp_supported_features);
|
||||
sprintf(buffer, "AT%s=%d\r\n", HFP_SUPPORTED_FEATURES, hfp_supported_features);
|
||||
// printf("exchange_supported_features %s\n", buffer);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
|
||||
int hfp_hs_retrieve_codec_cmd(uint16_t cid){
|
||||
char buffer[30];
|
||||
int buffer_offset = snprintf(buffer, sizeof(buffer), "AT%s=", HFP_Available_Codecs);
|
||||
int buffer_offset = snprintf(buffer, sizeof(buffer), "AT%s=", HFP_AVAILABLE_CODECS);
|
||||
join(buffer+buffer_offset, sizeof(buffer)-buffer_offset, hfp_codecs, hfp_codecs_nr);
|
||||
// printf("retrieve_codec %s\n", buffer);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
@ -135,21 +135,21 @@ int hfp_hs_retrieve_codec_cmd(uint16_t cid){
|
||||
|
||||
int hfp_hs_retrieve_indicators_cmd(uint16_t cid){
|
||||
char buffer[20];
|
||||
sprintf(buffer, "AT%s=?\r\n", HFP_Indicator);
|
||||
sprintf(buffer, "AT%s=?\r\n", HFP_INDICATOR);
|
||||
// printf("retrieve_indicators %s\n", buffer);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
|
||||
int hfp_hs_retrieve_indicators_status_cmd(uint16_t cid){
|
||||
char buffer[20];
|
||||
sprintf(buffer, "AT%s?\r\n", HFP_Indicator);
|
||||
sprintf(buffer, "AT%s?\r\n", HFP_INDICATOR);
|
||||
// printf("retrieve_indicators_status %s\n", buffer);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
|
||||
int hfp_hs_toggle_indicator_status_update_cmd(uint16_t cid, uint8_t activate){
|
||||
char buffer[20];
|
||||
sprintf(buffer, "AT%s=3,0,0,%d\r\n", HFP_Enable_Indicator_Status_Update, activate);
|
||||
sprintf(buffer, "AT%s=3,0,0,%d\r\n", HFP_ENABLE_INDICATOR_STATUS_UPDATE, activate);
|
||||
// printf("toggle_indicator_status_update %s\n", buffer);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
@ -157,7 +157,7 @@ int hfp_hs_toggle_indicator_status_update_cmd(uint16_t cid, uint8_t activate){
|
||||
|
||||
int hfp_hs_retrieve_can_hold_call_cmd(uint16_t cid){
|
||||
char buffer[20];
|
||||
sprintf(buffer, "AT%s=?\r\n", HFP_Support_Call_Hold_And_Multiparty_Services);
|
||||
sprintf(buffer, "AT%s=?\r\n", HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES);
|
||||
// printf("retrieve_can_hold_call %s\n", buffer);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
@ -165,7 +165,7 @@ int hfp_hs_retrieve_can_hold_call_cmd(uint16_t cid){
|
||||
|
||||
int hfp_hs_list_supported_generic_status_indicators_cmd(uint16_t cid){
|
||||
char buffer[30];
|
||||
int buffer_offset = snprintf(buffer, sizeof(buffer), "AT%s=", HFP_Generic_Status_Indicator);
|
||||
int buffer_offset = snprintf(buffer, sizeof(buffer), "AT%s=", HFP_GENERIC_STATUS_INDICATOR);
|
||||
join(buffer+buffer_offset, sizeof(buffer)-buffer_offset, hfp_indicators, hfp_indicators_nr);
|
||||
// printf("list_supported_generic_status_indicators %s\n", buffer);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
@ -173,14 +173,14 @@ int hfp_hs_list_supported_generic_status_indicators_cmd(uint16_t cid){
|
||||
|
||||
int hfp_hs_retrieve_supported_generic_status_indicators_cmd(uint16_t cid){
|
||||
char buffer[20];
|
||||
sprintf(buffer, "AT%s=?\r\rn", HFP_Generic_Status_Indicator);
|
||||
sprintf(buffer, "AT%s=?\r\rn", HFP_GENERIC_STATUS_INDICATOR);
|
||||
// printf("retrieve_supported_generic_status_indicators %s\n", buffer);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
|
||||
int hfp_hs_list_initital_supported_generic_status_indicators_cmd(uint16_t cid){
|
||||
char buffer[20];
|
||||
sprintf(buffer, "AT%s?\r\n", HFP_Generic_Status_Indicator);
|
||||
sprintf(buffer, "AT%s?\r\n", HFP_GENERIC_STATUS_INDICATOR);
|
||||
// printf("list_initital_supported_generic_status_indicators %s\n", buffer);
|
||||
return send_str_over_rfcomm(cid, buffer);
|
||||
}
|
||||
@ -378,8 +378,8 @@ hfp_connection_t * handle_message(hfp_connection_t * context, uint8_t *packet, u
|
||||
}
|
||||
}
|
||||
|
||||
if (strncmp((char *)packet, HFP_Supported_Features, strlen(HFP_Supported_Features)) == 0){
|
||||
offset = strlen(HFP_Supported_Features) + 1; // +1 for =
|
||||
if (strncmp((char *)packet, HFP_SUPPORTED_FEATURES, strlen(HFP_SUPPORTED_FEATURES)) == 0){
|
||||
offset = strlen(HFP_SUPPORTED_FEATURES) + 1; // +1 for =
|
||||
context->remote_supported_features = atoi((char*)&packet[offset]);
|
||||
int i = 0;
|
||||
for (i=0; i<16; i++){
|
||||
@ -392,8 +392,8 @@ hfp_connection_t * handle_message(hfp_connection_t * context, uint8_t *packet, u
|
||||
return context;
|
||||
}
|
||||
|
||||
if (strncmp((char *)packet, HFP_Indicator, strlen(HFP_Indicator)) == 0){
|
||||
offset = strlen(HFP_Indicator) + 1;
|
||||
if (strncmp((char *)packet, HFP_INDICATOR, strlen(HFP_INDICATOR)) == 0){
|
||||
offset = strlen(HFP_INDICATOR) + 1;
|
||||
switch (context->state){
|
||||
case HFP_W4_RETRIEVE_INDICATORS:
|
||||
hfp_parse_indicators(context, &packet[offset], size-offset);
|
||||
@ -411,21 +411,21 @@ hfp_connection_t * handle_message(hfp_connection_t * context, uint8_t *packet, u
|
||||
return context;
|
||||
}
|
||||
|
||||
if (strncmp((char *)packet, HFP_Support_Call_Hold_And_Multiparty_Services, strlen(HFP_Support_Call_Hold_And_Multiparty_Services)) == 0){
|
||||
offset = strlen(HFP_Support_Call_Hold_And_Multiparty_Services) + 1; // +1 for =
|
||||
if (strncmp((char *)packet, HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES, strlen(HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES)) == 0){
|
||||
offset = strlen(HFP_SUPPORT_CALL_HOLD_AND_MULTIPARTY_SERVICES) + 1; // +1 for =
|
||||
hfp_parse_comma_separated_tuple(context, &packet[offset], size-offset);
|
||||
context->state = HFP_LIST_GENERIC_STATUS_INDICATORS;
|
||||
context->wait_ok = 1;
|
||||
return context;
|
||||
}
|
||||
|
||||
if (strncmp((char *)packet, HFP_Generic_Status_Indicator, strlen(HFP_Generic_Status_Indicator)) == 0){
|
||||
if (strncmp((char *)packet, HFP_GENERIC_STATUS_INDICATOR, strlen(HFP_GENERIC_STATUS_INDICATOR)) == 0){
|
||||
// https://www.bluetooth.org/en-us/specification/assigned-numbers/hands-free-profile
|
||||
/* HF Indicators
|
||||
* 0x01 Enhanced Safety, on/off
|
||||
* 0x02 Battery Level, 0-100
|
||||
*/
|
||||
offset = strlen(HFP_Generic_Status_Indicator) + 1; // +1 for =
|
||||
offset = strlen(HFP_GENERIC_STATUS_INDICATOR) + 1; // +1 for =
|
||||
|
||||
switch (context->state){
|
||||
case HFP_W4_RETRIEVE_GENERIC_STATUS_INDICATORS:
|
||||
|
@ -126,13 +126,13 @@ void packet_handler(uint8_t * event, uint16_t event_size){
|
||||
|
||||
int btstack_main(int argc, const char * argv[]){
|
||||
// init L2CAP
|
||||
uint8_t codecs[1] = {HFP_Codec_CVSD};
|
||||
uint8_t codecs[1] = {HFP_CODEC_CVSD};
|
||||
uint16_t indicators[1] = {0x01};
|
||||
|
||||
l2cap_init();
|
||||
rfcomm_init();
|
||||
|
||||
// hfp_hf_init(rfcomm_channel_nr, HFP_Default_HF_Supported_Features, codecs, sizeof(codecs), indicators, sizeof(indicators)/sizeof(uint16_t), 1);
|
||||
// hfp_hf_init(rfcomm_channel_nr, HFP_DEFAULT_HF_SUPPORTED_FEATURES, codecs, sizeof(codecs), indicators, sizeof(indicators)/sizeof(uint16_t), 1);
|
||||
hfp_hf_init(rfcomm_channel_nr, 182, codecs, sizeof(codecs), indicators, sizeof(indicators)/sizeof(uint16_t), 1);
|
||||
|
||||
hfp_register_packet_handler(packet_handler);
|
||||
|
Loading…
x
Reference in New Issue
Block a user