1 /* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holders nor the names of 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 4. Any redistribution, use, or modification is done solely for 17 * personal benefit and not for any commercial purpose or for 18 * monetary gain. 19 * 20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Please inquire about commercial licensing options at 34 * [email protected] 35 * 36 */ 37 38 // ***************************************************************************** 39 // 40 // HSP Headset 41 // 42 // ***************************************************************************** 43 44 #include "btstack_config.h" 45 46 #include <stdint.h> 47 #include <stdio.h> 48 #include <stdlib.h> 49 #include <string.h> 50 51 #include "btstack_debug.h" 52 #include "btstack_event.h" 53 #include "btstack_memory.h" 54 #include "btstack_run_loop.h" 55 #include "classic/sdp_server.h" 56 #include "classic/sdp_query_rfcomm.h" 57 #include "classic/sdp_util.h" 58 #include "hci.h" 59 #include "hci_cmd.h" 60 #include "hci_dump.h" 61 #include "hsp_hs.h" 62 #include "l2cap.h" 63 64 #define HSP_AG_OK "OK" 65 #define HSP_AG_ERROR "ERROR" 66 #define HSP_AG_RING "RING" 67 #define HSP_MICROPHONE_GAIN "+VGM=" 68 #define HSP_SPEAKER_GAIN "+VGS=" 69 70 #define HSP_HS_AT_CKPD "AT+CKPD=200\r\n" 71 #define HSP_HS_MICROPHONE_GAIN "AT+VGM" 72 #define HSP_HS_SPEAKER_GAIN "AT+VGS" 73 74 static const char default_hsp_hs_service_name[] = "Headset"; 75 76 static bd_addr_t remote = {0x04, 0x0C, 0xCE, 0xE4, 0x85, 0xD3}; 77 static uint8_t channel_nr = 0; 78 79 static uint16_t mtu; 80 static uint16_t rfcomm_cid = 0; 81 static uint16_t sco_handle = 0; 82 static uint16_t rfcomm_handle = 0; 83 84 // static uint8_t connection_state = 0; 85 86 static int hs_microphone_gain = -1; 87 static int hs_speaker_gain = -1; 88 89 static uint8_t hs_send_button_press = 0; 90 static uint8_t hs_support_custom_indications = 0; 91 static uint8_t hs_outgoing_connection = 0; 92 93 static btstack_packet_callback_registration_t hci_event_callback_registration; 94 95 typedef enum { 96 HSP_IDLE, 97 HSP_SDP_QUERY_RFCOMM_CHANNEL, 98 HSP_W4_SDP_EVENT_QUERY_COMPLETE, 99 HSP_W4_RFCOMM_CONNECTED, 100 HSP_W4_USER_ACTION, 101 HSP_W2_CONNECT_SCO, 102 HSP_W4_SCO_CONNECTED, 103 HSP_ACTIVE, 104 HSP_W2_DISCONNECT_SCO, 105 HSP_W4_SCO_DISCONNECTED, 106 HSP_W2_DISCONNECT_RFCOMM, 107 HSP_W4_RFCOMM_DISCONNECTED, 108 HSP_W4_CONNECTION_ESTABLISHED_TO_SHUTDOWN 109 } hsp_state_t; 110 111 static hsp_state_t hsp_state = HSP_IDLE; 112 113 static void hsp_run(void); 114 static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); 115 static void handle_query_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); 116 117 static hsp_hs_callback_t hsp_hs_callback; 118 static void dummy_notify(uint8_t * event, uint16_t size){} 119 120 void hsp_hs_register_packet_handler(hsp_hs_callback_t callback){ 121 if (callback == NULL){ 122 callback = &dummy_notify; 123 } 124 hsp_hs_callback = callback; 125 } 126 127 static void emit_event(uint8_t event_subtype, uint8_t value){ 128 if (!hsp_hs_callback) return; 129 uint8_t event[4]; 130 event[0] = HCI_EVENT_HSP_META; 131 event[1] = sizeof(event) - 2; 132 event[2] = event_subtype; 133 event[3] = value; // status 0 == OK 134 (*hsp_hs_callback)(event, sizeof(event)); 135 } 136 137 static void emit_ring_event(void){ 138 if (!hsp_hs_callback) return; 139 uint8_t event[3]; 140 event[0] = HCI_EVENT_HSP_META; 141 event[1] = sizeof(event) - 2; 142 event[2] = HSP_SUBEVENT_RING; 143 (*hsp_hs_callback)(event, sizeof(event)); 144 } 145 146 static void emit_event_audio_connected(uint8_t status, uint16_t handle){ 147 if (!hsp_hs_callback) return; 148 uint8_t event[6]; 149 event[0] = HCI_EVENT_HSP_META; 150 event[1] = sizeof(event) - 2; 151 event[2] = HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE; 152 event[3] = status; 153 little_endian_store_16(event, 4, handle); 154 (*hsp_hs_callback)(event, sizeof(event)); 155 } 156 157 // remote audio volume control 158 // AG +VGM=13 [0..15] ; HS AT+VGM=6 | AG OK 159 160 static int hsp_hs_send_str_over_rfcomm(uint16_t cid, const char * command){ 161 if (!rfcomm_can_send_packet_now(rfcomm_cid)) return 1; 162 int err = rfcomm_send(cid, (uint8_t*) command, strlen(command)); 163 if (err){ 164 log_info("rfcomm_send_internal -> error 0X%02x", err); 165 } 166 return err; 167 } 168 169 void hsp_hs_enable_custom_indications(int enable){ 170 hs_support_custom_indications = enable; 171 } 172 173 int hsp_hs_send_result(const char * result){ 174 if (!hs_support_custom_indications) return 1; 175 return hsp_hs_send_str_over_rfcomm(rfcomm_cid, result); 176 } 177 178 179 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){ 180 uint8_t* attribute; 181 de_create_sequence(service); 182 183 // 0x0000 "Service Record Handle" 184 de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceRecordHandle); 185 de_add_number(service, DE_UINT, DE_SIZE_32, service_record_handle); 186 187 // 0x0001 "Service Class ID List" 188 de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList); 189 attribute = de_push_sequence(service); 190 { 191 // see Bluetooth Erratum #3507 192 de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_HSP); // 0x1108 193 de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_Headset_HS); // 0x1131 194 de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_GenericAudio); // 0x1203 195 } 196 de_pop_sequence(service, attribute); 197 198 // 0x0004 "Protocol Descriptor List" 199 de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList); 200 attribute = de_push_sequence(service); 201 { 202 uint8_t* l2cpProtocol = de_push_sequence(attribute); 203 { 204 de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, SDP_L2CAPProtocol); 205 } 206 de_pop_sequence(attribute, l2cpProtocol); 207 208 uint8_t* rfcomm = de_push_sequence(attribute); 209 { 210 de_add_number(rfcomm, DE_UUID, DE_SIZE_16, SDP_RFCOMMProtocol); // rfcomm_service 211 de_add_number(rfcomm, DE_UINT, DE_SIZE_8, rfcomm_channel_nr); // rfcomm channel 212 } 213 de_pop_sequence(attribute, rfcomm); 214 } 215 de_pop_sequence(service, attribute); 216 217 // 0x0005 "Public Browse Group" 218 de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BrowseGroupList); // public browse group 219 attribute = de_push_sequence(service); 220 { 221 de_add_number(attribute, DE_UUID, DE_SIZE_16, SDP_PublicBrowseGroup); 222 } 223 de_pop_sequence(service, attribute); 224 225 // 0x0009 "Bluetooth Profile Descriptor List" 226 de_add_number(service, DE_UINT, DE_SIZE_16, SDP_BluetoothProfileDescriptorList); 227 attribute = de_push_sequence(service); 228 { 229 uint8_t *hsp_profile = de_push_sequence(attribute); 230 { 231 de_add_number(hsp_profile, DE_UUID, DE_SIZE_16, SDP_HSP); 232 de_add_number(hsp_profile, DE_UINT, DE_SIZE_16, 0x0102); // Verision 1.2 233 } 234 de_pop_sequence(attribute, hsp_profile); 235 } 236 de_pop_sequence(service, attribute); 237 238 // 0x0100 "Service Name" 239 de_add_number(service, DE_UINT, DE_SIZE_16, 0x0100); 240 if (name){ 241 de_add_data(service, DE_STRING, strlen(name), (uint8_t *) name); 242 } else { 243 de_add_data(service, DE_STRING, strlen(default_hsp_hs_service_name), (uint8_t *) default_hsp_hs_service_name); 244 } 245 246 // Remote audio volume control 247 de_add_number(service, DE_UINT, DE_SIZE_16, 0x030C); 248 de_add_number(service, DE_BOOL, DE_SIZE_8, have_remote_audio_control); 249 } 250 251 static void hsp_hs_reset_state(void){ 252 hsp_state = HSP_IDLE; 253 254 rfcomm_cid = 0; 255 rfcomm_handle = 0; 256 sco_handle = 0; 257 258 hs_microphone_gain = -1; 259 hs_speaker_gain = -1; 260 261 hs_send_button_press = 0; 262 hs_support_custom_indications = 0; 263 } 264 265 void hsp_hs_init(uint8_t rfcomm_channel_nr){ 266 // register for HCI events 267 hci_event_callback_registration.callback = &packet_handler; 268 hci_add_event_handler(&hci_event_callback_registration); 269 270 // init L2CAP 271 l2cap_init(); 272 273 rfcomm_init(); 274 rfcomm_register_service(packet_handler, rfcomm_channel_nr, 0xffff); // reserved channel, mtu limited by l2cap 275 276 hsp_hs_reset_state(); 277 } 278 279 280 void hsp_hs_connect(bd_addr_t bd_addr){ 281 if (hsp_state != HSP_IDLE) return; 282 hs_outgoing_connection = 1; 283 hsp_state = HSP_SDP_QUERY_RFCOMM_CHANNEL; 284 memcpy(remote, bd_addr, 6); 285 hsp_run(); 286 } 287 288 void hsp_hs_disconnect(bd_addr_t bd_addr){ 289 switch (hsp_state){ 290 case HSP_ACTIVE: 291 hsp_state = HSP_W4_USER_ACTION; 292 hs_send_button_press = 1; 293 break; 294 case HSP_W4_RFCOMM_CONNECTED: 295 hsp_state = HSP_W4_CONNECTION_ESTABLISHED_TO_SHUTDOWN; 296 break; 297 default: 298 return; 299 } 300 hsp_run(); 301 } 302 303 304 void hsp_hs_set_microphone_gain(uint8_t gain){ 305 if (gain < 0 || gain >15) { 306 log_info("Gain must be in interval [0..15], it is given %d", gain); 307 return; 308 } 309 hs_microphone_gain = gain; 310 hsp_run(); 311 } 312 313 // AG +VGS=5 [0..15] ; HS AT+VGM=6 | AG OK 314 void hsp_hs_set_speaker_gain(uint8_t gain){ 315 if (gain < 0 || gain >15) { 316 log_info("Gain must be in interval [0..15], it is given %d", gain); 317 return; 318 } 319 hs_speaker_gain = gain; 320 hsp_run(); 321 } 322 323 324 static void hsp_run(void){ 325 int err; 326 327 if (hs_send_button_press){ 328 hs_send_button_press = 0; 329 err = hsp_hs_send_str_over_rfcomm(rfcomm_cid, HSP_HS_AT_CKPD); 330 if (err) { 331 hs_send_button_press = 1; 332 } 333 return; 334 } 335 336 switch (hsp_state){ 337 case HSP_SDP_QUERY_RFCOMM_CHANNEL: 338 hsp_state = HSP_W4_SDP_EVENT_QUERY_COMPLETE; 339 sdp_query_rfcomm_channel_and_name_for_uuid(&handle_query_rfcomm_event, remote, SDP_Headset_AG); 340 break; 341 342 case HSP_W2_CONNECT_SCO: 343 hsp_state = HSP_W4_SCO_CONNECTED; 344 break; 345 346 case HSP_W2_DISCONNECT_SCO: 347 hsp_state = HSP_W4_SCO_DISCONNECTED; 348 break; 349 350 case HSP_ACTIVE: 351 352 if (hs_microphone_gain >= 0){ 353 int gain = hs_microphone_gain; 354 hs_microphone_gain = -1; 355 char buffer[20]; 356 sprintf(buffer, "%s=%d\r\n", HSP_HS_MICROPHONE_GAIN, gain); 357 err = hsp_hs_send_str_over_rfcomm(rfcomm_cid, buffer); 358 if (err) { 359 hs_microphone_gain = gain; 360 } 361 break; 362 } 363 364 if (hs_speaker_gain >= 0){ 365 int gain = hs_speaker_gain; 366 hs_speaker_gain = -1; 367 char buffer[20]; 368 sprintf(buffer, "%s=%d\r\n", HSP_HS_SPEAKER_GAIN, gain); 369 err = hsp_hs_send_str_over_rfcomm(rfcomm_cid, buffer); 370 if (err) { 371 hs_speaker_gain = gain; 372 } 373 break; 374 } 375 376 break; 377 default: 378 break; 379 } 380 } 381 382 383 static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ 384 // printf("packet_handler type %u, packet[0] %x\n", packet_type, packet[0]); 385 if (packet_type == RFCOMM_DATA_PACKET){ 386 // skip over leading newline 387 while (size > 0 && (packet[0] == '\n' || packet[0] == '\r')){ 388 size--; 389 packet++; 390 } 391 if (strncmp((char *)packet, HSP_AG_RING, strlen(HSP_AG_RING)) == 0){ 392 emit_ring_event(); 393 } else if (strncmp((char *)packet, HSP_AG_OK, strlen(HSP_AG_OK)) == 0){ 394 switch (hsp_state){ 395 case HSP_W4_RFCOMM_CONNECTED: 396 hsp_state = HSP_W2_CONNECT_SCO; 397 break; 398 case HSP_W4_USER_ACTION: 399 hsp_state = HSP_W2_DISCONNECT_SCO; 400 break; 401 default: 402 break; 403 } 404 } else if (strncmp((char *)packet, HSP_MICROPHONE_GAIN, strlen(HSP_MICROPHONE_GAIN)) == 0){ 405 uint8_t gain = (uint8_t)atoi((char*)&packet[strlen(HSP_MICROPHONE_GAIN)]); 406 emit_event(HSP_SUBEVENT_MICROPHONE_GAIN_CHANGED, gain); 407 408 } else if (strncmp((char *)packet, HSP_SPEAKER_GAIN, strlen(HSP_SPEAKER_GAIN)) == 0){ 409 uint8_t gain = (uint8_t)atoi((char*)&packet[strlen(HSP_SPEAKER_GAIN)]); 410 emit_event(HSP_SUBEVENT_SPEAKER_GAIN_CHANGED, gain); 411 } else { 412 if (!hsp_hs_callback) return; 413 // strip trailing newline 414 while (size > 0 && (packet[size-1] == '\n' || packet[size-1] == '\r')){ 415 size--; 416 } 417 // add trailing \0 418 packet[size] = 0; 419 // re-use incoming buffer to avoid reserving large buffers - ugly but efficient 420 uint8_t * event = packet - 4; 421 event[0] = HCI_EVENT_HSP_META; 422 event[1] = size + 2; 423 event[2] = HSP_SUBEVENT_AG_INDICATION; 424 event[3] = size; 425 (*hsp_hs_callback)(event, size+4); 426 } 427 hsp_run(); 428 return; 429 } 430 431 if (packet_type != HCI_EVENT_PACKET) return; 432 uint8_t event = hci_event_packet_get_type(packet); 433 bd_addr_t event_addr; 434 uint16_t handle; 435 436 switch (event) { 437 case HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE:{ 438 int index = 2; 439 uint8_t status = packet[index++]; 440 sco_handle = little_endian_read_16(packet, index); 441 index+=2; 442 bd_addr_t address; 443 memcpy(address, &packet[index], 6); 444 index+=6; 445 uint8_t link_type = packet[index++]; 446 uint8_t transmission_interval = packet[index++]; // measured in slots 447 uint8_t retransmission_interval = packet[index++];// measured in slots 448 uint16_t rx_packet_length = little_endian_read_16(packet, index); // measured in bytes 449 index+=2; 450 uint16_t tx_packet_length = little_endian_read_16(packet, index); // measured in bytes 451 index+=2; 452 uint8_t air_mode = packet[index]; 453 454 if (status != 0){ 455 log_error("(e)SCO Connection failed, status %u", status); 456 emit_event_audio_connected(status, sco_handle); 457 break; 458 } 459 switch (link_type){ 460 case 0x00: 461 log_info("SCO Connection established."); 462 if (transmission_interval != 0) log_error("SCO Connection: transmission_interval not zero: %d.", transmission_interval); 463 if (retransmission_interval != 0) log_error("SCO Connection: retransmission_interval not zero: %d.", retransmission_interval); 464 if (rx_packet_length != 0) log_error("SCO Connection: rx_packet_length not zero: %d.", rx_packet_length); 465 if (tx_packet_length != 0) log_error("SCO Connection: tx_packet_length not zero: %d.", tx_packet_length); 466 break; 467 case 0x02: 468 log_info("eSCO Connection established."); 469 break; 470 default: 471 log_error("(e)SCO reserved link_type 0x%2x", link_type); 472 break; 473 } 474 log_info("sco_handle 0x%2x, address %s, transmission_interval %u slots, retransmission_interval %u slots, " 475 " rx_packet_length %u bytes, tx_packet_length %u bytes, air_mode 0x%2x (0x02 == CVSD)", sco_handle, 476 bd_addr_to_str(address), transmission_interval, retransmission_interval, rx_packet_length, tx_packet_length, air_mode); 477 478 if (hsp_state == HSP_W4_CONNECTION_ESTABLISHED_TO_SHUTDOWN){ 479 hsp_state = HSP_W2_DISCONNECT_SCO; 480 break; 481 } 482 483 // forward event to app 484 hsp_hs_callback(packet, size); 485 486 hsp_state = HSP_ACTIVE; 487 emit_event_audio_connected(0, sco_handle); 488 break; 489 } 490 491 case RFCOMM_EVENT_INCOMING_CONNECTION: 492 // data: event (8), len(8), address(48), channel (8), rfcomm_cid (16) 493 if (hsp_state != HSP_IDLE) return; 494 495 reverse_bd_addr(&packet[2], event_addr); 496 rfcomm_cid = little_endian_read_16(packet, 9); 497 log_info("RFCOMM channel %u requested for %s", packet[8], bd_addr_to_str(event_addr)); 498 rfcomm_accept_connection(rfcomm_cid); 499 500 hsp_state = HSP_W4_RFCOMM_CONNECTED; 501 break; 502 503 case RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE: 504 // printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE packet_handler type %u, packet[0] %x\n", packet_type, packet[0]); 505 // data: event(8), len(8), status (8), address (48), handle(16), server channel(8), rfcomm_cid(16), max frame size(16) 506 if (packet[2]) { 507 log_info("RFCOMM channel open failed, status %u", packet[2]); 508 hsp_hs_reset_state(); 509 emit_event(HSP_SUBEVENT_AUDIO_CONNECTION_COMPLETE, packet[2]); 510 hs_outgoing_connection = 0; 511 } else { 512 // data: event(8) , len(8), status (8), address (48), handle (16), server channel(8), rfcomm_cid(16), max frame size(16) 513 rfcomm_handle = little_endian_read_16(packet, 9); 514 rfcomm_cid = little_endian_read_16(packet, 12); 515 mtu = little_endian_read_16(packet, 14); 516 log_info("RFCOMM channel open succeeded. New RFCOMM Channel ID %u, max frame size %u", rfcomm_cid, mtu); 517 518 if (hs_outgoing_connection){ 519 hs_outgoing_connection = 0; 520 hs_send_button_press = 1; 521 } 522 523 switch (hsp_state){ 524 case HSP_W4_RFCOMM_CONNECTED: 525 hsp_state = HSP_W2_CONNECT_SCO; 526 break; 527 case HSP_W4_CONNECTION_ESTABLISHED_TO_SHUTDOWN: 528 hsp_state = HSP_W2_DISCONNECT_RFCOMM; 529 break; 530 default: 531 break; 532 } 533 } 534 break; 535 536 case RFCOMM_EVENT_CAN_SEND_NOW: 537 hsp_hs_callback(packet, size); 538 break; 539 540 case HCI_EVENT_DISCONNECTION_COMPLETE: 541 handle = little_endian_read_16(packet,3); 542 if (handle == sco_handle){ 543 sco_handle = 0; 544 hsp_state = HSP_W2_DISCONNECT_RFCOMM; 545 break; 546 } 547 break; 548 case RFCOMM_EVENT_CHANNEL_CLOSED: 549 hsp_hs_reset_state(); 550 emit_event(HSP_SUBEVENT_AUDIO_DISCONNECTION_COMPLETE,0); 551 break; 552 default: 553 break; 554 } 555 hsp_run(); 556 } 557 558 static void handle_query_rfcomm_event(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){ 559 switch (hci_event_packet_get_type(packet)){ 560 case SDP_EVENT_QUERY_RFCOMM_SERVICE: 561 channel_nr = sdp_event_query_rfcomm_service_get_rfcomm_channel(packet); 562 log_info("** Service name: '%s', RFCOMM port %u", sdp_event_query_rfcomm_service_get_name(packet), channel_nr); 563 break; 564 case SDP_EVENT_QUERY_COMPLETE: 565 if (channel_nr > 0){ 566 hsp_state = HSP_W4_RFCOMM_CONNECTED; 567 log_info("RFCOMM create channel"); 568 rfcomm_create_channel(packet_handler, remote, channel_nr, NULL); 569 break; 570 } 571 hsp_hs_reset_state(); 572 log_info("Service not found, status %u.", sdp_event_query_complete_get_status(packet)); 573 break; 574 } 575 } 576 577 void hsp_hs_send_button_press(void){ 578 hs_send_button_press = 1; 579 hsp_run(); 580 } 581