mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-30 15:32:41 +00:00
Merge branch 'master' into ble-api-cleanup
This commit is contained in:
commit
eda0480f01
@ -18,6 +18,10 @@ apis = [
|
|||||||
|
|
||||||
["src/classic/bnep.h", "BNEP", "bnep"],
|
["src/classic/bnep.h", "BNEP", "bnep"],
|
||||||
["src/classic/btstack_link_key_db.h","Link Key DB","lkDb"],
|
["src/classic/btstack_link_key_db.h","Link Key DB","lkDb"],
|
||||||
|
["src/classic/hsp_hs.h","HSP Headset","hspHS"],
|
||||||
|
["src/classic/hsp_ag.h","HSP Audio Gateway","hspAG"],
|
||||||
|
["src/classic/hfp_hf.h","HFP Hands-Free","hfpHF"],
|
||||||
|
["src/classic/hfp_ag.h","HFP Audio Gateway","hfpAG"],
|
||||||
["src/classic/pan.h", "PAN", "pan"],
|
["src/classic/pan.h", "PAN", "pan"],
|
||||||
["src/classic/rfcomm.h", "RFCOMM", "rfcomm"],
|
["src/classic/rfcomm.h", "RFCOMM", "rfcomm"],
|
||||||
["src/classic/sdp_client.h", "SDP Client", "sdpClient"],
|
["src/classic/sdp_client.h", "SDP Client", "sdpClient"],
|
||||||
|
@ -200,8 +200,8 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
|
|||||||
break;
|
break;
|
||||||
case HSP_SUBEVENT_AG_INDICATION:
|
case HSP_SUBEVENT_AG_INDICATION:
|
||||||
memset(hs_cmd_buffer, 0, sizeof(hs_cmd_buffer));
|
memset(hs_cmd_buffer, 0, sizeof(hs_cmd_buffer));
|
||||||
int size = event_size <= sizeof(hs_cmd_buffer)? event_size : sizeof(hs_cmd_buffer);
|
int size = event[3] <= sizeof(hs_cmd_buffer)? event[3] : sizeof(hs_cmd_buffer);
|
||||||
memcpy(hs_cmd_buffer, &event[3], size - 1);
|
memcpy(hs_cmd_buffer, &event[4], size - 1);
|
||||||
printf("Received custom indication: \"%s\". \nExit code or call hsp_hs_send_result.\n", hs_cmd_buffer);
|
printf("Received custom indication: \"%s\". \nExit code or call hsp_hs_send_result.\n", hs_cmd_buffer);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -275,9 +275,11 @@ void socket_connection_retry_parked(void){
|
|||||||
connection_t * conn = (connection_t *) it->next;
|
connection_t * conn = (connection_t *) it->next;
|
||||||
|
|
||||||
// dispatch packet !!! connection, type, channel, data, size
|
// dispatch packet !!! connection, type, channel, data, size
|
||||||
log_info("socket_connection_hci_process retry parked %p", conn);
|
uint16_t packet_type = little_endian_read_16( conn->buffer, 0);
|
||||||
int dispatch_err = (*socket_connection_packet_callback)(conn, little_endian_read_16( conn->buffer, 0), little_endian_read_16( conn->buffer, 2),
|
uint16_t channel = little_endian_read_16( conn->buffer, 2);
|
||||||
&conn->buffer[sizeof(packet_header_t)], little_endian_read_16( conn->buffer, 4));
|
uint16_t length = little_endian_read_16( conn->buffer, 4);
|
||||||
|
log_info("socket_connection_hci_process retry parked %p (type %u, channel %04x, length %u", conn, packet_type, channel, length);
|
||||||
|
int dispatch_err = (*socket_connection_packet_callback)(conn, packet_type, channel, &conn->buffer[sizeof(packet_header_t)], length);
|
||||||
// "un-park" if successful
|
// "un-park" if successful
|
||||||
if (!dispatch_err) {
|
if (!dispatch_err) {
|
||||||
log_info("socket_connection_hci_process dispatch succeeded -> un-park connection %p", conn);
|
log_info("socket_connection_hci_process dispatch succeeded -> un-park connection %p", conn);
|
||||||
|
@ -311,18 +311,20 @@ void hsp_ag_set_speaker_gain(uint8_t gain){
|
|||||||
hsp_run();
|
hsp_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hsp_timeout_handler(btstack_timer_source_t * timer){
|
static void hsp_ringing_timeout_handler(btstack_timer_source_t * timer){
|
||||||
ag_ring = 1;
|
ag_ring = 1;
|
||||||
}
|
|
||||||
|
|
||||||
static void hsp_timeout_start(void){
|
|
||||||
btstack_run_loop_remove_timer(&hs_timeout);
|
|
||||||
btstack_run_loop_set_timer_handler(&hs_timeout, hsp_timeout_handler);
|
|
||||||
btstack_run_loop_set_timer(&hs_timeout, 2000); // 2 seconds timeout
|
btstack_run_loop_set_timer(&hs_timeout, 2000); // 2 seconds timeout
|
||||||
btstack_run_loop_add_timer(&hs_timeout);
|
btstack_run_loop_add_timer(&hs_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hsp_timeout_stop(void){
|
static void hsp_ringing_timer_start(void){
|
||||||
|
btstack_run_loop_remove_timer(&hs_timeout);
|
||||||
|
btstack_run_loop_set_timer_handler(&hs_timeout, hsp_ringing_timeout_handler);
|
||||||
|
btstack_run_loop_set_timer(&hs_timeout, 2000); // 2 seconds timeout
|
||||||
|
btstack_run_loop_add_timer(&hs_timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void hsp_ringing_timer_stop(void){
|
||||||
btstack_run_loop_remove_timer(&hs_timeout);
|
btstack_run_loop_remove_timer(&hs_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,14 +332,14 @@ void hsp_ag_start_ringing(void){
|
|||||||
if (hsp_state != HSP_W2_CONNECT_SCO) return;
|
if (hsp_state != HSP_W2_CONNECT_SCO) return;
|
||||||
ag_ring = 1;
|
ag_ring = 1;
|
||||||
hsp_state = HSP_W4_RING_ANSWER;
|
hsp_state = HSP_W4_RING_ANSWER;
|
||||||
hsp_timeout_start();
|
hsp_ringing_timer_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hsp_ag_stop_ringing(void){
|
void hsp_ag_stop_ringing(void){
|
||||||
ag_ring = 0;
|
ag_ring = 0;
|
||||||
ag_num_button_press_received = 0;
|
ag_num_button_press_received = 0;
|
||||||
hsp_state = HSP_W2_CONNECT_SCO;
|
hsp_state = HSP_W2_CONNECT_SCO;
|
||||||
hsp_timeout_stop();
|
hsp_ringing_timer_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hsp_run(void){
|
static void hsp_run(void){
|
||||||
@ -469,11 +471,12 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
ag_send_error = 1;
|
ag_send_error = 1;
|
||||||
if (!hsp_ag_callback) return;
|
if (!hsp_ag_callback) return;
|
||||||
// re-use incoming buffer to avoid reserving large buffers - ugly but efficient
|
// re-use incoming buffer to avoid reserving large buffers - ugly but efficient
|
||||||
uint8_t * event = packet - 3;
|
uint8_t * event = packet - 4;
|
||||||
event[0] = HCI_EVENT_HSP_META;
|
event[0] = HCI_EVENT_HSP_META;
|
||||||
event[1] = size + 1;
|
event[1] = size + 2;
|
||||||
event[2] = HSP_SUBEVENT_HS_COMMAND;
|
event[2] = HSP_SUBEVENT_HS_COMMAND;
|
||||||
(*hsp_ag_callback)(event, size+3);
|
event[3] = size;
|
||||||
|
(*hsp_ag_callback)(event, size+4);
|
||||||
}
|
}
|
||||||
|
|
||||||
hsp_run();
|
hsp_run();
|
||||||
|
@ -52,39 +52,107 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* API_START */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Packet handler for HSP Audio Gateway (AG) events.
|
||||||
|
*
|
||||||
|
* The HSP AG event has type HCI_EVENT_HSP_META with following subtypes:
|
||||||
|
* - HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE
|
||||||
|
* - HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE
|
||||||
|
* - HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED
|
||||||
|
* - HSP_SUBEVENT_SPEAKER_GAIN_CHANGED
|
||||||
|
* - HSP_SUBEVENT_HS_COMMAND
|
||||||
|
*
|
||||||
|
* @param event See include/btstack/hci_cmds.h
|
||||||
|
* @param event_size
|
||||||
|
*/
|
||||||
typedef void (*hsp_ag_callback_t)(uint8_t * event, uint16_t event_size);
|
typedef void (*hsp_ag_callback_t)(uint8_t * event, uint16_t event_size);
|
||||||
|
|
||||||
|
/**
|
||||||
void hsp_ag_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name);
|
* @brief Set up HSP AG.
|
||||||
|
* @param rfcomm_channel_nr
|
||||||
|
*/
|
||||||
void hsp_ag_init(uint8_t rfcomm_channel_nr);
|
void hsp_ag_init(uint8_t rfcomm_channel_nr);
|
||||||
|
|
||||||
// Register callback (packet handler) for hsp audio gateway
|
/**
|
||||||
|
* @brief Create HSP Audio Gateway (AG) SDP service record.
|
||||||
|
* @param service Empty buffer in which a new service record will be stored.
|
||||||
|
* @param service_record_handle
|
||||||
|
* @param rfcomm_channel_nr
|
||||||
|
* @param name
|
||||||
|
*/
|
||||||
|
void hsp_ag_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Register packet handler to receive HSP AG events.
|
||||||
|
* @param callback
|
||||||
|
*/
|
||||||
void hsp_ag_register_packet_handler(hsp_ag_callback_t callback);
|
void hsp_ag_register_packet_handler(hsp_ag_callback_t callback);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Connect to HSP Headset
|
||||||
|
*
|
||||||
|
* Perform SDP query for an RFCOMM service on a remote device,
|
||||||
|
* and establish an RFCOMM connection if such service is found. The reception of the
|
||||||
|
* HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE or
|
||||||
|
* HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE event
|
||||||
|
* indicate if the connection is successfully established or not.
|
||||||
|
*
|
||||||
|
* @param bd_addr
|
||||||
|
*/
|
||||||
void hsp_ag_connect(bd_addr_t bd_addr);
|
void hsp_ag_connect(bd_addr_t bd_addr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Disconnect from HSP Headset.
|
||||||
|
*
|
||||||
|
* Releases the RFCOMM channel.
|
||||||
|
* @param bd_addr
|
||||||
|
*/
|
||||||
void hsp_ag_disconnect(void);
|
void hsp_ag_disconnect(void);
|
||||||
|
|
||||||
// +VGM=[0..15]
|
/**
|
||||||
|
* @brief Set microphone gain.
|
||||||
|
* @param gain Valid range: [0,15]
|
||||||
|
*/
|
||||||
void hsp_ag_set_microphone_gain(uint8_t gain);
|
void hsp_ag_set_microphone_gain(uint8_t gain);
|
||||||
|
|
||||||
// +VGS=[0..15]
|
/**
|
||||||
|
* @brief Set speaker gain.
|
||||||
|
* @param gain Valid range: [0,15]
|
||||||
|
*/
|
||||||
void hsp_ag_set_speaker_gain(uint8_t gain);
|
void hsp_ag_set_speaker_gain(uint8_t gain);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Start ringing because of incoming call.
|
||||||
|
*/
|
||||||
void hsp_ag_start_ringing(void);
|
void hsp_ag_start_ringing(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Stop ringing (e.g. call was terminated).
|
||||||
|
*/
|
||||||
void hsp_ag_stop_ringing(void);
|
void hsp_ag_stop_ringing(void);
|
||||||
|
|
||||||
// When support custom commands is enabled, AG will emit HSP_SUBEVENT_HS_COMMAND.
|
/**
|
||||||
// On occurance of this event, client's packet handler must send the result back
|
* @brief Enable custom AT commands.
|
||||||
// by calling hsp_ag_send_result function.
|
*
|
||||||
|
* Custom commands are disabled by default.
|
||||||
|
* When enabled, custom AT commands are received via the HSP_SUBEVENT_HS_COMMAND.
|
||||||
|
* @param enable
|
||||||
|
*/
|
||||||
void hsp_ag_enable_custom_commands(int enable);
|
void hsp_ag_enable_custom_commands(int enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Send a custom AT command to HSP Headset.
|
||||||
|
*
|
||||||
|
* On HSP_SUBEVENT_AG_INDICATION, the client needs to respond
|
||||||
|
* with this function with the result to the custom command.
|
||||||
|
* @param result
|
||||||
|
*/
|
||||||
int hsp_ag_send_result(char * result);
|
int hsp_ag_send_result(char * result);
|
||||||
|
|
||||||
|
/* API_END */
|
||||||
|
|
||||||
#if defined __cplusplus
|
#if defined __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -133,6 +133,15 @@ static void emit_event(uint8_t event_subtype, uint8_t value){
|
|||||||
(*hsp_hs_callback)(event, sizeof(event));
|
(*hsp_hs_callback)(event, sizeof(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void emit_ring_event(void){
|
||||||
|
if (!hsp_hs_callback) return;
|
||||||
|
uint8_t event[3];
|
||||||
|
event[0] = HCI_EVENT_HSP_META;
|
||||||
|
event[1] = sizeof(event) - 2;
|
||||||
|
event[2] = HSP_SUBEVENT_RING;
|
||||||
|
(*hsp_hs_callback)(event, sizeof(event));
|
||||||
|
}
|
||||||
|
|
||||||
static void emit_event_audio_connected(uint8_t status, uint16_t handle){
|
static void emit_event_audio_connected(uint8_t status, uint16_t handle){
|
||||||
if (!hsp_hs_callback) return;
|
if (!hsp_hs_callback) return;
|
||||||
uint8_t event[6];
|
uint8_t event[6];
|
||||||
@ -381,7 +390,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
packet++;
|
packet++;
|
||||||
}
|
}
|
||||||
if (strncmp((char *)packet, HSP_AG_RING, strlen(HSP_AG_RING)) == 0){
|
if (strncmp((char *)packet, HSP_AG_RING, strlen(HSP_AG_RING)) == 0){
|
||||||
emit_event(HSP_SUBEVENT_RING, 0);
|
emit_ring_event();
|
||||||
} else if (strncmp((char *)packet, HSP_AG_OK, strlen(HSP_AG_OK)) == 0){
|
} else if (strncmp((char *)packet, HSP_AG_OK, strlen(HSP_AG_OK)) == 0){
|
||||||
printf("OK RECEIVED\n");
|
printf("OK RECEIVED\n");
|
||||||
switch (hsp_state){
|
switch (hsp_state){
|
||||||
@ -410,11 +419,12 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
|
|||||||
// add trailing \0
|
// add trailing \0
|
||||||
packet[size] = 0;
|
packet[size] = 0;
|
||||||
// re-use incoming buffer to avoid reserving large buffers - ugly but efficient
|
// re-use incoming buffer to avoid reserving large buffers - ugly but efficient
|
||||||
uint8_t * event = packet - 3;
|
uint8_t * event = packet - 4;
|
||||||
event[0] = HCI_EVENT_HSP_META;
|
event[0] = HCI_EVENT_HSP_META;
|
||||||
event[1] = size + 1;
|
event[1] = size + 2;
|
||||||
event[2] = HSP_SUBEVENT_AG_INDICATION;
|
event[2] = HSP_SUBEVENT_AG_INDICATION;
|
||||||
(*hsp_hs_callback)(event, size+3);
|
event[3] = size;
|
||||||
|
(*hsp_hs_callback)(event, size+4);
|
||||||
}
|
}
|
||||||
hsp_run();
|
hsp_run();
|
||||||
return;
|
return;
|
||||||
|
@ -55,41 +55,52 @@ extern "C" {
|
|||||||
/* API_START */
|
/* API_START */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Packet handler for HSP Headset (HS) events. The HSP HS event has type HCI_EVENT_HSP_META with following subtypes:
|
* @brief Packet handler for HSP Headset (HS) events.
|
||||||
* - HSP_SUBEVENT_ERROR
|
*
|
||||||
|
* The HSP HS event has type HCI_EVENT_HSP_META with following subtypes:
|
||||||
* - HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE
|
* - HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE
|
||||||
* - HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE
|
* - HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE
|
||||||
* - HSP_SUBEVENT_RING
|
* - HSP_SUBEVENT_RING
|
||||||
* - HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED
|
* - HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED
|
||||||
* - HSP_SUBEVENT_SPEAKER_GAIN_CHANGED
|
* - HSP_SUBEVENT_SPEAKER_GAIN_CHANGED
|
||||||
* - HSP_SUBEVENT_AG_INDICATION
|
* - HSP_SUBEVENT_AG_INDICATION
|
||||||
|
*
|
||||||
|
* @param event See include/btstack/hci_cmds.h
|
||||||
|
* @param event_size
|
||||||
*/
|
*/
|
||||||
typedef void (*hsp_hs_callback_t)(uint8_t * event, uint16_t event_size);
|
typedef void (*hsp_hs_callback_t)(uint8_t * event, uint16_t event_size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set up HSP HS
|
* @brief Set up HSP HS.
|
||||||
* @param rfcomm_channel_nr
|
* @param rfcomm_channel_nr
|
||||||
*/
|
*/
|
||||||
void hsp_hs_init(uint8_t rfcomm_channel_nr);
|
void hsp_hs_init(uint8_t rfcomm_channel_nr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Create HSP Headset (HS) SDP service record. have_remote_audio_control?
|
* @brief Create HSP Headset (HS) SDP service record.
|
||||||
|
* @param service Empty buffer in which a new service record will be stored.
|
||||||
|
* @param rfcomm_channel_nr
|
||||||
|
* @param name
|
||||||
|
* @param have_remote_audio_control
|
||||||
*/
|
*/
|
||||||
void hsp_hs_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name, uint8_t have_remote_audio_control);
|
void hsp_hs_create_sdp_record(uint8_t * service, uint32_t service_record_handle, int rfcomm_channel_nr, const char * name, uint8_t have_remote_audio_control);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Register packet handler to receive HSP HS events.
|
* @brief Register packet handler to receive HSP HS events.
|
||||||
|
* @param callback
|
||||||
*/
|
*/
|
||||||
void hsp_hs_register_packet_handler(hsp_hs_callback_t callback);
|
void hsp_hs_register_packet_handler(hsp_hs_callback_t callback);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Connect to HSP Audio Gateway
|
* @brief Connect to HSP Audio Gateway.
|
||||||
*
|
*
|
||||||
* Perform SDP query for an RFCOMM service on a remote device,
|
* Perform SDP query for an RFCOMM service on a remote device,
|
||||||
* and establish an RFCOMM connection if such service is found. The reception of the
|
* and establish an RFCOMM connection if such service is found. The reception of the
|
||||||
* HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE or
|
* HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE or
|
||||||
* HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE event
|
* HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE event
|
||||||
* indicate if the connection is successfully established or not.
|
* indicate if the connection is successfully established or not.
|
||||||
|
*
|
||||||
|
* @param bd_addr
|
||||||
*/
|
*/
|
||||||
void hsp_hs_connect(bd_addr_t bd_addr);
|
void hsp_hs_connect(bd_addr_t bd_addr);
|
||||||
|
|
||||||
@ -97,6 +108,7 @@ void hsp_hs_connect(bd_addr_t bd_addr);
|
|||||||
* @brief Disconnect from HSP Audio Gateway
|
* @brief Disconnect from HSP Audio Gateway
|
||||||
*
|
*
|
||||||
* Releases the RFCOMM channel.
|
* Releases the RFCOMM channel.
|
||||||
|
* @param bd_addr
|
||||||
*/
|
*/
|
||||||
void hsp_hs_disconnect(bd_addr_t bd_addr);
|
void hsp_hs_disconnect(bd_addr_t bd_addr);
|
||||||
|
|
||||||
@ -105,7 +117,7 @@ void hsp_hs_disconnect(bd_addr_t bd_addr);
|
|||||||
*
|
*
|
||||||
* The new gain value will be confirmed by the HSP Audio Gateway.
|
* The new gain value will be confirmed by the HSP Audio Gateway.
|
||||||
* A HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED event will be received.
|
* A HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED event will be received.
|
||||||
* @param gain - valid range: [0,15]
|
* @param gain Valid range: [0,15]
|
||||||
*/
|
*/
|
||||||
void hsp_hs_set_microphone_gain(uint8_t gain);
|
void hsp_hs_set_microphone_gain(uint8_t gain);
|
||||||
|
|
||||||
@ -120,24 +132,27 @@ void hsp_hs_set_speaker_gain(uint8_t gain);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Send button press action.
|
* @brief Send button press action.
|
||||||
|
* @param gain Valid range: [0,15]
|
||||||
*/
|
*/
|
||||||
void hsp_hs_send_button_press(void);
|
void hsp_hs_send_button_press(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable custom indications
|
* @brief Enable custom indications.
|
||||||
*
|
*
|
||||||
* Custom indications are disable by default.
|
* Custom indications are disabled by default.
|
||||||
* When enabled, custom indications are received via the HSP_SUBEVENT_AG_INDICATION.
|
* When enabled, custom indications are received via the HSP_SUBEVENT_AG_INDICATION.
|
||||||
|
* @param enable
|
||||||
*/
|
*/
|
||||||
void hsp_hs_enable_custom_indications(int enable);
|
void hsp_hs_enable_custom_indications(int enable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Send answer to custom command
|
* @brief Send answer to custom indication.
|
||||||
*
|
*
|
||||||
* On HSP_SUBEVENT_AG_INDICATION, the client needs to respond
|
* On HSP_SUBEVENT_AG_INDICATION, the client needs to respond
|
||||||
* with this function with the result to the custom indication
|
* with this function with the result to the custom indication
|
||||||
|
* @param result
|
||||||
*/
|
*/
|
||||||
int hsp_hs_send_result(const char * indication);
|
int hsp_hs_send_result(const char * result);
|
||||||
|
|
||||||
/* API_END */
|
/* API_END */
|
||||||
|
|
||||||
|
@ -172,8 +172,8 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
|
|||||||
break;
|
break;
|
||||||
case HSP_SUBEVENT_HS_COMMAND:{
|
case HSP_SUBEVENT_HS_COMMAND:{
|
||||||
memset(hs_cmd_buffer, 0, sizeof(hs_cmd_buffer));
|
memset(hs_cmd_buffer, 0, sizeof(hs_cmd_buffer));
|
||||||
int size = event_size <= sizeof(hs_cmd_buffer)? event_size : sizeof(hs_cmd_buffer);
|
int size = event[3] <= sizeof(hs_cmd_buffer)? event[3] : sizeof(hs_cmd_buffer);
|
||||||
memcpy(hs_cmd_buffer, &event[3], size - 1);
|
memcpy(hs_cmd_buffer, &event[4], size - 1);
|
||||||
printf("Received custom command: \"%s\". \nExit code or call hsp_ag_send_result.\n", hs_cmd_buffer);
|
printf("Received custom command: \"%s\". \nExit code or call hsp_ag_send_result.\n", hs_cmd_buffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -292,8 +292,8 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
|
|||||||
break;
|
break;
|
||||||
case HSP_SUBEVENT_AG_INDICATION:
|
case HSP_SUBEVENT_AG_INDICATION:
|
||||||
memset(hs_cmd_buffer, 0, sizeof(hs_cmd_buffer));
|
memset(hs_cmd_buffer, 0, sizeof(hs_cmd_buffer));
|
||||||
int size = event_size <= sizeof(hs_cmd_buffer)? event_size : sizeof(hs_cmd_buffer);
|
int size = event[3] <= sizeof(hs_cmd_buffer)? event[3] : sizeof(hs_cmd_buffer);
|
||||||
memcpy(hs_cmd_buffer, &event[3], size - 1);
|
memcpy(hs_cmd_buffer, &event[4], size - 1);
|
||||||
printf("Received custom indication: \"%s\". \nExit code or call hsp_hs_send_result.\n", hs_cmd_buffer);
|
printf("Received custom indication: \"%s\". \nExit code or call hsp_hs_send_result.\n", hs_cmd_buffer);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "hci_dump.h"
|
#include "hci_dump.h"
|
||||||
#include "l2cap.h"
|
#include "l2cap.h"
|
||||||
#include "mock.h"
|
#include "mock.h"
|
||||||
|
#include "classic/sdp_util.h"
|
||||||
|
|
||||||
#include "CppUTest/TestHarness.h"
|
#include "CppUTest/TestHarness.h"
|
||||||
#include "CppUTest/CommandLineTestRunner.h"
|
#include "CppUTest/CommandLineTestRunner.h"
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "classic/sdp_query_rfcomm.h"
|
#include "classic/sdp_query_rfcomm.h"
|
||||||
|
#include "classic/sdp_util.h"
|
||||||
#include "hci_cmd.h"
|
#include "hci_cmd.h"
|
||||||
#include "btstack_run_loop.h"
|
#include "btstack_run_loop.h"
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "hci_dump.h"
|
#include "hci_dump.h"
|
||||||
#include "l2cap.h"
|
#include "l2cap.h"
|
||||||
#include "mock.h"
|
#include "mock.h"
|
||||||
|
#include "classic/sdp_util.h"
|
||||||
|
|
||||||
#include "CppUTest/TestHarness.h"
|
#include "CppUTest/TestHarness.h"
|
||||||
#include "CppUTest/CommandLineTestRunner.h"
|
#include "CppUTest/CommandLineTestRunner.h"
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "hci_dump.h"
|
#include "hci_dump.h"
|
||||||
#include "l2cap.h"
|
#include "l2cap.h"
|
||||||
#include "mock.h"
|
#include "mock.h"
|
||||||
|
#include "classic/sdp_util.h"
|
||||||
|
|
||||||
#include "CppUTest/TestHarness.h"
|
#include "CppUTest/TestHarness.h"
|
||||||
#include "CppUTest/CommandLineTestRunner.h"
|
#include "CppUTest/CommandLineTestRunner.h"
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# BlueKitchen GmbH (c) 2014
|
# BlueKitchen GmbH (c) 2014
|
||||||
|
|
||||||
@ -61,6 +62,8 @@ def parse_defines():
|
|||||||
def my_parse_events(path):
|
def my_parse_events(path):
|
||||||
events = []
|
events = []
|
||||||
le_events = []
|
le_events = []
|
||||||
|
hfp_events = []
|
||||||
|
hsp_events = []
|
||||||
params = []
|
params = []
|
||||||
event_types = set()
|
event_types = set()
|
||||||
format = None
|
format = None
|
||||||
@ -79,6 +82,10 @@ def my_parse_events(path):
|
|||||||
if format != None:
|
if format != None:
|
||||||
if key.lower().startswith('hci_subevent_'):
|
if key.lower().startswith('hci_subevent_'):
|
||||||
le_events.append((value, key.lower().replace('hci_subevent_', 'hci_event_'), format, params))
|
le_events.append((value, key.lower().replace('hci_subevent_', 'hci_event_'), format, params))
|
||||||
|
elif key.lower().startswith('hsp_subevent_'):
|
||||||
|
hsp_events.append((value, key.lower().replace('hsp_subevent_', 'hsp_event_'), format, params))
|
||||||
|
elif key.lower().startswith('hfp_subevent_'):
|
||||||
|
hfp.append((value, key.lower().replace('hfp_subevent_', 'hfp_event_'), format, params))
|
||||||
else:
|
else:
|
||||||
events.append((value, key, format, params))
|
events.append((value, key, format, params))
|
||||||
event_types.add(key)
|
event_types.add(key)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user