hfp: provide acl_handle in events to identify connection

This commit is contained in:
Matthias Ringwald 2021-04-07 18:01:39 +02:00
parent 11d54508be
commit d703d377e1
5 changed files with 379 additions and 101 deletions

View File

@ -65,6 +65,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
events instead of callback, and `RFCOMM_DATA_PACKET` for received data
- HSP AG: emit HSP_SUBEVENT_BUTTON_PRESSED instead of audio connection setup/release
- Examples: use `btstack_event.h` getters instead of direct array access, use enum to compare status codes
- HFP: provide acl_handle in events to identify connection
- HCI Transport: extract convenience function declaration for h4, h5, em9304_spi, and usb into separate hci_transport_{type}.h
- GATT Client: Use ATT_READ_REQUEST for first blob of Read Long Characteristic
- HID: Move `src/classic/hid.h` into `src` and prefix with `btstack_` to use it with BLE and avoid name clashes

View File

@ -1519,14 +1519,16 @@ typedef uint8_t sm_key_t[16];
#define HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED 0x01
/**
* @format 1
* @format 1H
* @param subevent_code
* @param con_handle
*/
#define HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED 0x02
/**
* @format 11HB1
* @format 1H1HB1
* @param subevent_code
* @param con_handle
* @param status 0 == OK
* @param sco_handle
* @param bd_addr
@ -1535,21 +1537,25 @@ typedef uint8_t sm_key_t[16];
#define HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED 0x03
/**
* @format 1
* @format 1HH
* @param subevent_code
* @param con_handle
* @param sco_handle
*/
#define HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED 0x04
/**
* @format 11
* @format 1H1
* @param subevent_code
* @param con_handle
* @param status 0 == OK
*/
#define HFP_SUBEVENT_COMPLETE 0x05
/**
* @format 11111111T
* @format 1H1111111T
* @param subevent_code
* @param con_handle
* @param indicator_index
* @param indicator_status
* @param indicator_min_range
@ -1562,8 +1568,9 @@ typedef uint8_t sm_key_t[16];
#define HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED 0x06
/**
* @format 111T
* @format 1H11T
* @param subevent_code
* @param con_handle
* @param network_operator_mode
* @param network_operator_format
* @param network_operator_name
@ -1571,21 +1578,24 @@ typedef uint8_t sm_key_t[16];
#define HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED 0x07
/**
* @format 11
* @format 1H1
* @param subevent_code
* @param con_handle
* @param error
*/
#define HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR 0x08
/**
* @format 1
* @format 1H
* @param subevent_code
* @param con_handle
*/
#define HFP_SUBEVENT_START_RINGINIG 0x0A
/**
* @format 1
* @format 1H
* @param subevent_code
* @param con_handle
*/
#define HFP_SUBEVENT_STOP_RINGINIG 0x0B
@ -1596,83 +1606,95 @@ typedef uint8_t sm_key_t[16];
#define HFP_SUBEVENT_CALL_TERMINATED 0x0C
/**
* @format 1T
* @format 1HT
* @param subevent_code
* @param con_handle
* @param number
*/
#define HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER 0x0D
/**
* @format 1
* @format 1H
* @param subevent_code
* @param con_handle
*/
#define HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG 0x0E
/**
* @format 1T
* @format 1HT
* @param subevent_code
* @param con_handle
* @param number
*/
#define HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG 0x0F
/**
* @format 1T
* @format 1HT
* @param subevent_code
* @param con_handle
* @param dtmf code
*/
#define HFP_SUBEVENT_TRANSMIT_DTMF_CODES 0x10
/**
* @format 1
* @format 1H
* @param subevent_code
* @param con_handle
*/
#define HFP_SUBEVENT_CALL_ANSWERED 0x11
#define HFP_SUBEVENT_CALL_ANSWERED 0x11
/**
* @format 1
* @format 1H
* @param subevent_code
* @param con_handle
*/
#define HFP_SUBEVENT_CONFERENCE_CALL 0x12
/**
* @format 1
* @format 1H
* @param subevent_code
* @param con_handle
*/
#define HFP_SUBEVENT_RING 0x13
/**
* @format 11
* @format 1H1
* @param subevent_code
* @param con_handle
* @param gain
*/
#define HFP_SUBEVENT_SPEAKER_VOLUME 0x14
#define HFP_SUBEVENT_SPEAKER_VOLUME 0x14
/**
* @format 11
* @format 1H1
* @param subevent_code
* @param con_handle
* @param gain
*/
#define HFP_SUBEVENT_MICROPHONE_VOLUME 0x15
/**
* @format 11T
* @format 1H1T
* @param subevent_code
* @param con_handle
* @param type
* @param number
*/
#define HFP_SUBEVENT_CALL_WAITING_NOTIFICATION 0x16
/**
* @format 11T
* @format 1H1T
* @param subevent_code
* @param con_handle
* @param type
* @param number
*/
#define HFP_SUBEVENT_CALLING_LINE_IDENTIFICATION_NOTIFICATION 0x17
/**
* @format 1111111T
* @format 1H111111T
* @param subevent_code
* @param con_handle
* @param clcc_idx
* @param clcc_dir
* @param clcc_status
@ -1684,31 +1706,35 @@ typedef uint8_t sm_key_t[16];
#define HFP_SUBEVENT_ENHANCED_CALL_STATUS 0x18
/**
* @format 111T
* @format 1H11T
* @param subevent_code
* @param con_handle
* @param status
* @param bnip_type
* @param bnip_number
*/
#define HFP_SUBEVENT_SUBSCRIBER_NUMBER_INFORMATION 0x19
#define HFP_SUBEVENT_SUBSCRIBER_NUMBER_INFORMATION 0x19
/**
* @format 1T
* @format 1HT
* @param subevent_code
* @param con_handle
* @param value
*/
#define HFP_SUBEVENT_RESPONSE_AND_HOLD_STATUS 0x1A
/**
* @format 1T
* @format 1HT
* @param subevent_code
* @param con_handle
* @param command
*/
#define HFP_SUBEVENT_AT_MESSAGE_SENT 0x1B
/**
* @format 1T
* @format 1HT
* @param subevent_code
* @param con_handle
* @param command
*/
#define HFP_SUBEVENT_AT_MESSAGE_RECEIVED 0x1C

View File

@ -3978,7 +3978,25 @@ static inline void hfp_subevent_service_level_connection_established_get_bd_addr
reverse_bytes(&event[6], bd_addr, 6);
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_service_level_connection_released_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_audio_connection_established_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field status from event HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED
* @param event packet
@ -3986,7 +4004,7 @@ static inline void hfp_subevent_service_level_connection_established_get_bd_addr
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_audio_connection_established_get_status(const uint8_t * event){
return event[3];
return event[5];
}
/**
* @brief Get field sco_handle from event HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED
@ -3995,7 +4013,7 @@ static inline uint8_t hfp_subevent_audio_connection_established_get_status(const
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_audio_connection_established_get_sco_handle(const uint8_t * event){
return little_endian_read_16(event, 4);
return little_endian_read_16(event, 6);
}
/**
* @brief Get field bd_addr from event HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED
@ -4004,7 +4022,7 @@ static inline hci_con_handle_t hfp_subevent_audio_connection_established_get_sco
* @note: btstack_type B
*/
static inline void hfp_subevent_audio_connection_established_get_bd_addr(const uint8_t * event, bd_addr_t bd_addr){
reverse_bytes(&event[6], bd_addr, 6);
reverse_bytes(&event[8], bd_addr, 6);
}
/**
* @brief Get field negotiated_codec from event HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED
@ -4013,10 +4031,37 @@ static inline void hfp_subevent_audio_connection_established_get_bd_addr(const u
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_audio_connection_established_get_negotiated_codec(const uint8_t * event){
return event[12];
return event[14];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_audio_connection_released_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field sco_handle from event HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED
* @param event packet
* @return sco_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_audio_connection_released_get_sco_handle(const uint8_t * event){
return little_endian_read_16(event, 5);
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_COMPLETE
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_complete_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field status from event HFP_SUBEVENT_COMPLETE
* @param event packet
@ -4024,9 +4069,18 @@ static inline uint8_t hfp_subevent_audio_connection_established_get_negotiated_c
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_complete_get_status(const uint8_t * event){
return event[3];
return event[5];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_ag_indicator_status_changed_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field indicator_index from event HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED
* @param event packet
@ -4034,7 +4088,7 @@ static inline uint8_t hfp_subevent_complete_get_status(const uint8_t * event){
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_index(const uint8_t * event){
return event[3];
return event[5];
}
/**
* @brief Get field indicator_status from event HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED
@ -4043,7 +4097,7 @@ static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_ind
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_status(const uint8_t * event){
return event[4];
return event[6];
}
/**
* @brief Get field indicator_min_range from event HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED
@ -4052,7 +4106,7 @@ static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_sta
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_min_range(const uint8_t * event){
return event[5];
return event[7];
}
/**
* @brief Get field indicator_max_range from event HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED
@ -4061,7 +4115,7 @@ static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_min
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_max_range(const uint8_t * event){
return event[6];
return event[8];
}
/**
* @brief Get field indicator_mandatory from event HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED
@ -4070,7 +4124,7 @@ static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_max
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_mandatory(const uint8_t * event){
return event[7];
return event[9];
}
/**
* @brief Get field indicator_enabled from event HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED
@ -4079,7 +4133,7 @@ static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_man
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_enabled(const uint8_t * event){
return event[8];
return event[10];
}
/**
* @brief Get field indicator_status_changed from event HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED
@ -4088,7 +4142,7 @@ static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_ena
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_status_changed(const uint8_t * event){
return event[9];
return event[11];
}
/**
* @brief Get field indicator_name from event HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED
@ -4097,9 +4151,18 @@ static inline uint8_t hfp_subevent_ag_indicator_status_changed_get_indicator_sta
* @note: btstack_type T
*/
static inline const char * hfp_subevent_ag_indicator_status_changed_get_indicator_name(const uint8_t * event){
return (const char *) &event[10];
return (const char *) &event[12];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_network_operator_changed_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field network_operator_mode from event HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED
* @param event packet
@ -4107,7 +4170,7 @@ static inline const char * hfp_subevent_ag_indicator_status_changed_get_indicato
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_network_operator_changed_get_network_operator_mode(const uint8_t * event){
return event[3];
return event[5];
}
/**
* @brief Get field network_operator_format from event HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED
@ -4116,7 +4179,7 @@ static inline uint8_t hfp_subevent_network_operator_changed_get_network_operator
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_network_operator_changed_get_network_operator_format(const uint8_t * event){
return event[4];
return event[6];
}
/**
* @brief Get field network_operator_name from event HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED
@ -4125,9 +4188,18 @@ static inline uint8_t hfp_subevent_network_operator_changed_get_network_operator
* @note: btstack_type T
*/
static inline const char * hfp_subevent_network_operator_changed_get_network_operator_name(const uint8_t * event){
return (const char *) &event[5];
return (const char *) &event[7];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_extended_audio_gateway_error_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field error from event HFP_SUBEVENT_EXTENDED_AUDIO_GATEWAY_ERROR
* @param event packet
@ -4135,12 +4207,39 @@ static inline const char * hfp_subevent_network_operator_changed_get_network_ope
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_extended_audio_gateway_error_get_error(const uint8_t * event){
return event[3];
return event[5];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_START_RINGINIG
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_start_ringinig_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_STOP_RINGINIG
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_stop_ringinig_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_place_call_with_number_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field number from event HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER
* @param event packet
@ -4148,10 +4247,28 @@ static inline uint8_t hfp_subevent_extended_audio_gateway_error_get_error(const
* @note: btstack_type T
*/
static inline const char * hfp_subevent_place_call_with_number_get_number(const uint8_t * event){
return (const char *) &event[3];
return (const char *) &event[5];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_attach_number_to_voice_tag_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_number_for_voice_tag_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field number from event HFP_SUBEVENT_NUMBER_FOR_VOICE_TAG
* @param event packet
@ -4159,9 +4276,18 @@ static inline const char * hfp_subevent_place_call_with_number_get_number(const
* @note: btstack_type T
*/
static inline const char * hfp_subevent_number_for_voice_tag_get_number(const uint8_t * event){
return (const char *) &event[3];
return (const char *) &event[5];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_TRANSMIT_DTMF_CODES
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_transmit_dtmf_codes_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field dtmf from event HFP_SUBEVENT_TRANSMIT_DTMF_CODES
* @param event packet
@ -4169,12 +4295,48 @@ static inline const char * hfp_subevent_number_for_voice_tag_get_number(const ui
* @note: btstack_type T
*/
static inline const char * hfp_subevent_transmit_dtmf_codes_get_dtmf(const uint8_t * event){
return (const char *) &event[3];
return (const char *) &event[5];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_CALL_ANSWERED
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_call_answered_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_CONFERENCE_CALL
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_conference_call_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_RING
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_ring_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_SPEAKER_VOLUME
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_speaker_volume_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field gain from event HFP_SUBEVENT_SPEAKER_VOLUME
* @param event packet
@ -4182,9 +4344,18 @@ static inline const char * hfp_subevent_transmit_dtmf_codes_get_dtmf(const uint8
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_speaker_volume_get_gain(const uint8_t * event){
return event[3];
return event[5];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_MICROPHONE_VOLUME
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_microphone_volume_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field gain from event HFP_SUBEVENT_MICROPHONE_VOLUME
* @param event packet
@ -4192,9 +4363,18 @@ static inline uint8_t hfp_subevent_speaker_volume_get_gain(const uint8_t * event
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_microphone_volume_get_gain(const uint8_t * event){
return event[3];
return event[5];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_CALL_WAITING_NOTIFICATION
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_call_waiting_notification_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field type from event HFP_SUBEVENT_CALL_WAITING_NOTIFICATION
* @param event packet
@ -4202,7 +4382,7 @@ static inline uint8_t hfp_subevent_microphone_volume_get_gain(const uint8_t * ev
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_call_waiting_notification_get_type(const uint8_t * event){
return event[3];
return event[5];
}
/**
* @brief Get field number from event HFP_SUBEVENT_CALL_WAITING_NOTIFICATION
@ -4211,9 +4391,18 @@ static inline uint8_t hfp_subevent_call_waiting_notification_get_type(const uint
* @note: btstack_type T
*/
static inline const char * hfp_subevent_call_waiting_notification_get_number(const uint8_t * event){
return (const char *) &event[4];
return (const char *) &event[6];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_CALLING_LINE_IDENTIFICATION_NOTIFICATION
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_calling_line_identification_notification_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field type from event HFP_SUBEVENT_CALLING_LINE_IDENTIFICATION_NOTIFICATION
* @param event packet
@ -4221,7 +4410,7 @@ static inline const char * hfp_subevent_call_waiting_notification_get_number(con
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_calling_line_identification_notification_get_type(const uint8_t * event){
return event[3];
return event[5];
}
/**
* @brief Get field number from event HFP_SUBEVENT_CALLING_LINE_IDENTIFICATION_NOTIFICATION
@ -4230,9 +4419,18 @@ static inline uint8_t hfp_subevent_calling_line_identification_notification_get_
* @note: btstack_type T
*/
static inline const char * hfp_subevent_calling_line_identification_notification_get_number(const uint8_t * event){
return (const char *) &event[4];
return (const char *) &event[6];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_ENHANCED_CALL_STATUS
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_enhanced_call_status_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field clcc_idx from event HFP_SUBEVENT_ENHANCED_CALL_STATUS
* @param event packet
@ -4240,7 +4438,7 @@ static inline const char * hfp_subevent_calling_line_identification_notification
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_idx(const uint8_t * event){
return event[3];
return event[5];
}
/**
* @brief Get field clcc_dir from event HFP_SUBEVENT_ENHANCED_CALL_STATUS
@ -4249,7 +4447,7 @@ static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_idx(const uint8
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_dir(const uint8_t * event){
return event[4];
return event[6];
}
/**
* @brief Get field clcc_status from event HFP_SUBEVENT_ENHANCED_CALL_STATUS
@ -4258,7 +4456,7 @@ static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_dir(const uint8
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_status(const uint8_t * event){
return event[5];
return event[7];
}
/**
* @brief Get field clcc_mode from event HFP_SUBEVENT_ENHANCED_CALL_STATUS
@ -4267,7 +4465,7 @@ static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_status(const ui
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_mode(const uint8_t * event){
return event[6];
return event[8];
}
/**
* @brief Get field clcc_mpty from event HFP_SUBEVENT_ENHANCED_CALL_STATUS
@ -4276,7 +4474,7 @@ static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_mode(const uint
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_mpty(const uint8_t * event){
return event[7];
return event[9];
}
/**
* @brief Get field bnip_type from event HFP_SUBEVENT_ENHANCED_CALL_STATUS
@ -4285,7 +4483,7 @@ static inline uint8_t hfp_subevent_enhanced_call_status_get_clcc_mpty(const uint
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_enhanced_call_status_get_bnip_type(const uint8_t * event){
return event[8];
return event[10];
}
/**
* @brief Get field bnip_number from event HFP_SUBEVENT_ENHANCED_CALL_STATUS
@ -4294,9 +4492,18 @@ static inline uint8_t hfp_subevent_enhanced_call_status_get_bnip_type(const uint
* @note: btstack_type T
*/
static inline const char * hfp_subevent_enhanced_call_status_get_bnip_number(const uint8_t * event){
return (const char *) &event[9];
return (const char *) &event[11];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_SUBSCRIBER_NUMBER_INFORMATION
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_subscriber_number_information_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field status from event HFP_SUBEVENT_SUBSCRIBER_NUMBER_INFORMATION
* @param event packet
@ -4304,7 +4511,7 @@ static inline const char * hfp_subevent_enhanced_call_status_get_bnip_number(con
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_subscriber_number_information_get_status(const uint8_t * event){
return event[3];
return event[5];
}
/**
* @brief Get field bnip_type from event HFP_SUBEVENT_SUBSCRIBER_NUMBER_INFORMATION
@ -4313,7 +4520,7 @@ static inline uint8_t hfp_subevent_subscriber_number_information_get_status(cons
* @note: btstack_type 1
*/
static inline uint8_t hfp_subevent_subscriber_number_information_get_bnip_type(const uint8_t * event){
return event[4];
return event[6];
}
/**
* @brief Get field bnip_number from event HFP_SUBEVENT_SUBSCRIBER_NUMBER_INFORMATION
@ -4322,9 +4529,18 @@ static inline uint8_t hfp_subevent_subscriber_number_information_get_bnip_type(c
* @note: btstack_type T
*/
static inline const char * hfp_subevent_subscriber_number_information_get_bnip_number(const uint8_t * event){
return (const char *) &event[5];
return (const char *) &event[7];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_RESPONSE_AND_HOLD_STATUS
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_response_and_hold_status_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field value from event HFP_SUBEVENT_RESPONSE_AND_HOLD_STATUS
* @param event packet
@ -4332,9 +4548,18 @@ static inline const char * hfp_subevent_subscriber_number_information_get_bnip_n
* @note: btstack_type T
*/
static inline const char * hfp_subevent_response_and_hold_status_get_value(const uint8_t * event){
return (const char *) &event[3];
return (const char *) &event[5];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_AT_MESSAGE_SENT
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_at_message_sent_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field command from event HFP_SUBEVENT_AT_MESSAGE_SENT
* @param event packet
@ -4342,9 +4567,18 @@ static inline const char * hfp_subevent_response_and_hold_status_get_value(const
* @note: btstack_type T
*/
static inline const char * hfp_subevent_at_message_sent_get_command(const uint8_t * event){
return (const char *) &event[3];
return (const char *) &event[5];
}
/**
* @brief Get field con_handle from event HFP_SUBEVENT_AT_MESSAGE_RECEIVED
* @param event packet
* @return con_handle
* @note: btstack_type H
*/
static inline hci_con_handle_t hfp_subevent_at_message_received_get_con_handle(const uint8_t * event){
return little_endian_read_16(event, 3);
}
/**
* @brief Get field command from event HFP_SUBEVENT_AT_MESSAGE_RECEIVED
* @param event packet
@ -4352,7 +4586,7 @@ static inline const char * hfp_subevent_at_message_sent_get_command(const uint8_
* @note: btstack_type T
*/
static inline const char * hfp_subevent_at_message_received_get_command(const uint8_t * event){
return (const char *) &event[3];
return (const char *) &event[5];
}
#ifdef ENABLE_BLE

View File

@ -331,19 +331,21 @@ static void hfp_emit_event_for_context(hfp_connection_t * hfp_connection, uint8_
}
void hfp_emit_simple_event(hfp_connection_t * hfp_connection, uint8_t event_subtype){
uint8_t event[3];
uint8_t event[5];
event[0] = HCI_EVENT_HFP_META;
event[1] = sizeof(event) - 2;
event[2] = event_subtype;
little_endian_store_16(event, 3, hfp_connection->acl_handle);
hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
}
void hfp_emit_event(hfp_connection_t * hfp_connection, uint8_t event_subtype, uint8_t value){
uint8_t event[4];
uint8_t event[6];
event[0] = HCI_EVENT_HFP_META;
event[1] = sizeof(event) - 2;
event[2] = event_subtype;
event[3] = value; // status 0 == OK
little_endian_store_16(event, 3, hfp_connection->acl_handle);
event[5] = value; // status 0 == OK
hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
}
@ -361,23 +363,29 @@ void hfp_emit_slc_connection_event(hfp_connection_t * hfp_connection, uint8_t st
hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
}
static void hfp_emit_audio_connection_released(hfp_connection_t * hfp_connection){
uint8_t event[3];
static void hfp_emit_audio_connection_released(hfp_connection_t * hfp_connection, hci_con_handle_t sco_handle){
uint8_t event[7];
int pos = 0;
event[pos++] = HCI_EVENT_HFP_META;
event[pos++] = sizeof(event) - 2;
event[pos++] = HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED;
little_endian_store_16(event, pos, hfp_connection->acl_handle);
pos += 2;
little_endian_store_16(event, pos, sco_handle);
pos += 2;
hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
}
void hfp_emit_sco_event(hfp_connection_t * hfp_connection, uint8_t status, hci_con_handle_t con_handle, bd_addr_t addr, uint8_t negotiated_codec){
uint8_t event[13];
void hfp_emit_sco_event(hfp_connection_t * hfp_connection, uint8_t status, hci_con_handle_t sco_handle, bd_addr_t addr, uint8_t negotiated_codec){
uint8_t event[15];
int pos = 0;
event[pos++] = HCI_EVENT_HFP_META;
event[pos++] = sizeof(event) - 2;
event[pos++] = HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED;
little_endian_store_16(event, pos, hfp_connection->acl_handle);
pos += 2;
event[pos++] = status; // status 0 == OK
little_endian_store_16(event, pos, con_handle);
little_endian_store_16(event, pos, sco_handle);
pos += 2;
reverse_bd_addr(addr,&event[pos]);
pos += 6;
@ -394,9 +402,10 @@ void hfp_emit_string_event(hfp_connection_t * hfp_connection, uint8_t event_subt
event[0] = HCI_EVENT_HFP_META;
event[1] = sizeof(event) - 2;
event[2] = event_subtype;
uint16_t size = btstack_min(strlen(value), sizeof(event) - 4);
little_endian_store_16(event, 3, hfp_connection->acl_handle);
uint16_t size = btstack_min(strlen(value), sizeof(event) - 6);
strncpy((char*)&event[3], value, size);
event[3 + size] = 0;
event[5 + size] = 0;
hfp_emit_event_for_context(hfp_connection, event, sizeof(event));
}
@ -834,7 +843,7 @@ void hfp_handle_hci_event(uint8_t packet_type, uint16_t channel, uint8_t *packet
}
hfp_connection->state = HFP_SERVICE_LEVEL_CONNECTION_ESTABLISHED;
hfp_emit_audio_connection_released(hfp_connection);
hfp_emit_audio_connection_released(hfp_connection, handle);
if (hfp_connection->release_slc_connection){
hfp_connection->release_slc_connection = 0;
@ -926,9 +935,10 @@ void hfp_handle_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *pac
if ( hfp_connection->state == HFP_AUDIO_CONNECTION_ESTABLISHED){
// service connection was released, this implicitly releases audio connection as well
hfp_connection->release_audio_connection = 0;
hci_con_handle_t sco_handle = hfp_connection->sco_handle;
gap_disconnect(hfp_connection->sco_handle);
hfp_connection->state = HFP_W4_SCO_DISCONNECTED_TO_SHUTDOWN;
hfp_emit_audio_connection_released(hfp_connection);
hfp_emit_audio_connection_released(hfp_connection, sco_handle);
hfp_emit_event(hfp_connection, HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED, 0);
} else {
// regular case

View File

@ -125,45 +125,49 @@ static hfp_connection_t * get_hfp_hf_connection_context_for_acl_handle(uint16_t
static void hfp_hf_emit_subscriber_information(const hfp_connection_t * hfp_connection, uint8_t status){
if (hfp_hf_callback == NULL) return;
uint8_t event[31];
uint8_t event[33];
event[0] = HCI_EVENT_HFP_META;
event[1] = sizeof(event) - 2;
event[2] = HFP_SUBEVENT_SUBSCRIBER_NUMBER_INFORMATION;
event[3] = status;
event[4] = hfp_connection->bnip_type;
uint16_t size = btstack_min(strlen(hfp_connection->bnip_number), sizeof(event) - 6);
strncpy((char*)&event[5], hfp_connection->bnip_number, size);
event[5 + size] = 0;
little_endian_store_16(event, 3, hfp_connection->acl_handle);
event[5] = status;
event[6] = hfp_connection->bnip_type;
uint16_t size = btstack_min(strlen(hfp_connection->bnip_number), sizeof(event) - 8);
strncpy((char*)&event[7], hfp_connection->bnip_number, size);
event[7 + size] = 0;
(*hfp_hf_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
}
static void hfp_hf_emit_type_and_number(const hfp_connection_t * hfp_connection, uint8_t event_subtype){
if (hfp_hf_callback == NULL) return;
uint8_t event[30];
uint8_t event[32];
event[0] = HCI_EVENT_HFP_META;
event[1] = sizeof(event) - 2;
event[2] = event_subtype;
event[3] = hfp_connection->bnip_type;
uint16_t size = btstack_min(strlen(hfp_connection->bnip_number), sizeof(event) - 5);
strncpy((char*)&event[4], hfp_connection->bnip_number, size);
event[4 + size] = 0;
little_endian_store_16(event, 3, hfp_connection->acl_handle);
event[5] = hfp_connection->bnip_type;
uint16_t size = btstack_min(strlen(hfp_connection->bnip_number), sizeof(event) - 7);
strncpy((char*)&event[6], hfp_connection->bnip_number, size);
event[6 + size] = 0;
(*hfp_hf_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
}
static void hfp_hf_emit_enhanced_call_status(const hfp_connection_t * hfp_connection){
if (hfp_hf_callback == NULL) return;
uint8_t event[36];
uint8_t event[38];
int pos = 0;
event[pos++] = HCI_EVENT_HFP_META;
event[pos++] = sizeof(event) - 2;
event[pos++] = HFP_SUBEVENT_ENHANCED_CALL_STATUS;
little_endian_store_16(event, pos, hfp_connection->acl_handle);
pos += 2;
event[pos++] = hfp_connection->clcc_idx;
event[pos++] = hfp_connection->clcc_dir;
event[pos++] = hfp_connection->clcc_status;
event[pos++] = hfp_connection->clcc_mode;
event[pos++] = hfp_connection->clcc_mpty;
event[pos++] = hfp_connection->bnip_type;
uint16_t size = btstack_min(strlen(hfp_connection->bnip_number), sizeof(event) - pos);
uint16_t size = btstack_min(strlen(hfp_connection->bnip_number), sizeof(event) - pos - 1);
strncpy((char*)&event[pos], hfp_connection->bnip_number, size);
pos += size;
event[pos++] = 0;
@ -172,12 +176,14 @@ static void hfp_hf_emit_enhanced_call_status(const hfp_connection_t * hfp_connec
static void hfp_emit_ag_indicator_event(const hfp_connection_t * hfp_connection, const hfp_ag_indicator_t * indicator){
if (hfp_hf_callback == NULL) return;
uint8_t event[10+HFP_MAX_INDICATOR_DESC_SIZE+1];
if (hfp_hf_callback == NULL) return;
uint8_t event[12+HFP_MAX_INDICATOR_DESC_SIZE+1];
int pos = 0;
event[pos++] = HCI_EVENT_HFP_META;
event[pos++] = sizeof(event) - 2;
event[pos++] = HFP_SUBEVENT_AG_INDICATOR_STATUS_CHANGED;
little_endian_store_16(event, pos, hfp_connection->acl_handle);
pos += 2;
event[pos++] = indicator->index;
event[pos++] = indicator->status;
event[pos++] = indicator->min_range;
@ -193,14 +199,15 @@ static void hfp_emit_ag_indicator_event(const hfp_connection_t * hfp_connection,
static void hfp_emit_network_operator_event(const hfp_connection_t * hfp_connection){
if (hfp_hf_callback == NULL) return;
uint8_t event[5+HFP_MAX_NETWORK_OPERATOR_NAME_SIZE+1];
uint8_t event[7+HFP_MAX_NETWORK_OPERATOR_NAME_SIZE+1];
event[0] = HCI_EVENT_HFP_META;
event[1] = sizeof(event) - 2;
event[2] = HFP_SUBEVENT_NETWORK_OPERATOR_CHANGED;
event[3] = hfp_connection->network_operator.mode;
event[4] = hfp_connection->network_operator.format;
strncpy((char*)&event[5], hfp_connection->network_operator.name, HFP_MAX_NETWORK_OPERATOR_NAME_SIZE);
event[5+HFP_MAX_NETWORK_OPERATOR_NAME_SIZE] = 0;
little_endian_store_16(event, 3, hfp_connection->acl_handle);
event[5] = hfp_connection->network_operator.mode;
event[6] = hfp_connection->network_operator.format;
strncpy((char*)&event[7], hfp_connection->network_operator.name, HFP_MAX_NETWORK_OPERATOR_NAME_SIZE);
event[7+HFP_MAX_NETWORK_OPERATOR_NAME_SIZE] = 0;
(*hfp_hf_callback)(HCI_EVENT_PACKET, 0, event, sizeof(event));
}