1fffdd288SMatthias Ringwald /* 2fffdd288SMatthias Ringwald * Copyright (C) 2014 BlueKitchen GmbH 3fffdd288SMatthias Ringwald * 4fffdd288SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5fffdd288SMatthias Ringwald * modification, are permitted provided that the following conditions 6fffdd288SMatthias Ringwald * are met: 7fffdd288SMatthias Ringwald * 8fffdd288SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9fffdd288SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10fffdd288SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11fffdd288SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12fffdd288SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13fffdd288SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14fffdd288SMatthias Ringwald * contributors may be used to endorse or promote products derived 15fffdd288SMatthias Ringwald * from this software without specific prior written permission. 16fffdd288SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17fffdd288SMatthias Ringwald * personal benefit and not for any commercial purpose or for 18fffdd288SMatthias Ringwald * monetary gain. 19fffdd288SMatthias Ringwald * 20fffdd288SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21fffdd288SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22fffdd288SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23fffdd288SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24fffdd288SMatthias Ringwald * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25fffdd288SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26fffdd288SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27fffdd288SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28fffdd288SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29fffdd288SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30fffdd288SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31fffdd288SMatthias Ringwald * SUCH DAMAGE. 32fffdd288SMatthias Ringwald * 33fffdd288SMatthias Ringwald * Please inquire about commercial licensing options at 34fffdd288SMatthias Ringwald * [email protected] 35fffdd288SMatthias Ringwald * 36fffdd288SMatthias Ringwald */ 37fffdd288SMatthias Ringwald 38fffdd288SMatthias Ringwald /* 39fffdd288SMatthias Ringwald * hfp_ag_demo.c 40fffdd288SMatthias Ringwald */ 41fffdd288SMatthias Ringwald 42fffdd288SMatthias Ringwald // ***************************************************************************** 43fffdd288SMatthias Ringwald /* EXAMPLE_START(hfp_ag_demo): HFP Audio Gateway (AG) Demo 44fffdd288SMatthias Ringwald * 45fffdd288SMatthias Ringwald * @text This HFP Audio Gateway example demonstrates how to receive 46fffdd288SMatthias Ringwald * an output from a remote HFP Hands-Free (HF) unit, and, 47*d0755cd6SMatthias Ringwald * if HAVE_POSIX_STDIN is defined, how to control the HFP HF. 48fffdd288SMatthias Ringwald */ 49fffdd288SMatthias Ringwald // ***************************************************************************** 50fffdd288SMatthias Ringwald 51fffdd288SMatthias Ringwald 52fffdd288SMatthias Ringwald #include <stdint.h> 53fffdd288SMatthias Ringwald #include <stdio.h> 54fffdd288SMatthias Ringwald #include <stdlib.h> 55fffdd288SMatthias Ringwald #include <string.h> 56fffdd288SMatthias Ringwald #include <unistd.h> 57fffdd288SMatthias Ringwald 58fffdd288SMatthias Ringwald #include "btstack.h" 59*d0755cd6SMatthias Ringwald #ifdef HAVE_POSIX_STDIN 60fffdd288SMatthias Ringwald #include "stdin_support.h" 614af4141bSMatthias Ringwald #endif 62fffdd288SMatthias Ringwald 63fffdd288SMatthias Ringwald 64fffdd288SMatthias Ringwald uint8_t hfp_service_buffer[150]; 65fffdd288SMatthias Ringwald const uint8_t rfcomm_channel_nr = 1; 66fffdd288SMatthias Ringwald const char hfp_ag_service_name[] = "BTstack HFP AG Test"; 67fffdd288SMatthias Ringwald 68fffdd288SMatthias Ringwald static bd_addr_t device_addr = {0x00,0x15,0x83,0x5F,0x9D,0x46}; 69fffdd288SMatthias Ringwald 70fffdd288SMatthias Ringwald static uint8_t codecs[1] = {HFP_CODEC_CVSD}; 71fffdd288SMatthias Ringwald static uint16_t handle = -1; 72fffdd288SMatthias Ringwald static int memory_1_enabled = 1; 73fffdd288SMatthias Ringwald 74fffdd288SMatthias Ringwald static int ag_indicators_nr = 7; 75fffdd288SMatthias Ringwald static hfp_ag_indicator_t ag_indicators[] = { 76fffdd288SMatthias Ringwald // index, name, min range, max range, status, mandatory, enabled, status changed 77fffdd288SMatthias Ringwald {1, "service", 0, 1, 1, 0, 0, 0}, 78fffdd288SMatthias Ringwald {2, "call", 0, 1, 0, 1, 1, 0}, 79fffdd288SMatthias Ringwald {3, "callsetup", 0, 3, 0, 1, 1, 0}, 80fffdd288SMatthias Ringwald {4, "battchg", 0, 5, 3, 0, 0, 0}, 81fffdd288SMatthias Ringwald {5, "signal", 0, 5, 5, 0, 1, 0}, 82fffdd288SMatthias Ringwald {6, "roam", 0, 1, 0, 0, 1, 0}, 83fffdd288SMatthias Ringwald {7, "callheld", 0, 2, 0, 1, 1, 0} 84fffdd288SMatthias Ringwald }; 85fffdd288SMatthias Ringwald 86fffdd288SMatthias Ringwald static int call_hold_services_nr = 5; 87fffdd288SMatthias Ringwald static const char* call_hold_services[] = {"1", "1x", "2", "2x", "3"}; 88fffdd288SMatthias Ringwald 89fffdd288SMatthias Ringwald static int hf_indicators_nr = 2; 90fffdd288SMatthias Ringwald static hfp_generic_status_indicator_t hf_indicators[] = { 91fffdd288SMatthias Ringwald {1, 1}, 92fffdd288SMatthias Ringwald {2, 1}, 93fffdd288SMatthias Ringwald }; 94fffdd288SMatthias Ringwald 95fffdd288SMatthias Ringwald char cmd; 96fffdd288SMatthias Ringwald 97fffdd288SMatthias Ringwald // GAP INQUIRY 98fffdd288SMatthias Ringwald 99fffdd288SMatthias Ringwald #define MAX_DEVICES 10 100fffdd288SMatthias Ringwald enum DEVICE_STATE { REMOTE_NAME_REQUEST, REMOTE_NAME_INQUIRED, REMOTE_NAME_FETCHED }; 101fffdd288SMatthias Ringwald struct device { 102fffdd288SMatthias Ringwald bd_addr_t address; 103fffdd288SMatthias Ringwald uint16_t clockOffset; 104fffdd288SMatthias Ringwald uint32_t classOfDevice; 105fffdd288SMatthias Ringwald uint8_t pageScanRepetitionMode; 106fffdd288SMatthias Ringwald uint8_t rssi; 107fffdd288SMatthias Ringwald enum DEVICE_STATE state; 108fffdd288SMatthias Ringwald }; 109fffdd288SMatthias Ringwald 110fffdd288SMatthias Ringwald #define INQUIRY_INTERVAL 5 111fffdd288SMatthias Ringwald struct device devices[MAX_DEVICES]; 112fffdd288SMatthias Ringwald int deviceCount = 0; 113fffdd288SMatthias Ringwald 114fffdd288SMatthias Ringwald 115fffdd288SMatthias Ringwald enum STATE {INIT, W4_INQUIRY_MODE_COMPLETE, ACTIVE} ; 116fffdd288SMatthias Ringwald enum STATE state = INIT; 117fffdd288SMatthias Ringwald 118fffdd288SMatthias Ringwald 119fffdd288SMatthias Ringwald static int getDeviceIndexForAddress( bd_addr_t addr){ 120fffdd288SMatthias Ringwald int j; 121fffdd288SMatthias Ringwald for (j=0; j< deviceCount; j++){ 122fffdd288SMatthias Ringwald if (bd_addr_cmp(addr, devices[j].address) == 0){ 123fffdd288SMatthias Ringwald return j; 124fffdd288SMatthias Ringwald } 125fffdd288SMatthias Ringwald } 126fffdd288SMatthias Ringwald return -1; 127fffdd288SMatthias Ringwald } 128fffdd288SMatthias Ringwald 129*d0755cd6SMatthias Ringwald #ifdef HAVE_POSIX_STDIN 130fffdd288SMatthias Ringwald static void start_scan(void){ 131fffdd288SMatthias Ringwald printf("Starting inquiry scan..\n"); 132fffdd288SMatthias Ringwald hci_send_cmd(&hci_inquiry, HCI_INQUIRY_LAP, INQUIRY_INTERVAL, 0); 133fffdd288SMatthias Ringwald } 134fffdd288SMatthias Ringwald #endif 135fffdd288SMatthias Ringwald 136fffdd288SMatthias Ringwald static int has_more_remote_name_requests(void){ 137fffdd288SMatthias Ringwald int i; 138fffdd288SMatthias Ringwald for (i=0;i<deviceCount;i++) { 139fffdd288SMatthias Ringwald if (devices[i].state == REMOTE_NAME_REQUEST) return 1; 140fffdd288SMatthias Ringwald } 141fffdd288SMatthias Ringwald return 0; 142fffdd288SMatthias Ringwald } 143fffdd288SMatthias Ringwald 144fffdd288SMatthias Ringwald static void do_next_remote_name_request(void){ 145fffdd288SMatthias Ringwald int i; 146fffdd288SMatthias Ringwald for (i=0;i<deviceCount;i++) { 147fffdd288SMatthias Ringwald // remote name request 148fffdd288SMatthias Ringwald if (devices[i].state == REMOTE_NAME_REQUEST){ 149fffdd288SMatthias Ringwald devices[i].state = REMOTE_NAME_INQUIRED; 150fffdd288SMatthias Ringwald printf("Get remote name of %s...\n", bd_addr_to_str(devices[i].address)); 151fffdd288SMatthias Ringwald hci_send_cmd(&hci_remote_name_request, devices[i].address, 152fffdd288SMatthias Ringwald devices[i].pageScanRepetitionMode, 0, devices[i].clockOffset | 0x8000); 153fffdd288SMatthias Ringwald return; 154fffdd288SMatthias Ringwald } 155fffdd288SMatthias Ringwald } 156fffdd288SMatthias Ringwald } 157fffdd288SMatthias Ringwald 158fffdd288SMatthias Ringwald static void continue_remote_names(void){ 159fffdd288SMatthias Ringwald // don't get remote names for testing 160fffdd288SMatthias Ringwald if (has_more_remote_name_requests()){ 161fffdd288SMatthias Ringwald do_next_remote_name_request(); 162fffdd288SMatthias Ringwald return; 163fffdd288SMatthias Ringwald } 164fffdd288SMatthias Ringwald // try to find PTS 165fffdd288SMatthias Ringwald int i; 166fffdd288SMatthias Ringwald for (i=0;i<deviceCount;i++){ 167fffdd288SMatthias Ringwald if (memcmp(devices[i].address, device_addr, 6) == 0){ 168fffdd288SMatthias Ringwald printf("Inquiry scan over, successfully found PTS at index %u\nReady to connect to it.\n", i); 169fffdd288SMatthias Ringwald return; 170fffdd288SMatthias Ringwald } 171fffdd288SMatthias Ringwald } 172fffdd288SMatthias Ringwald printf("Inquiry scan over but PTS not found :(\n"); 173fffdd288SMatthias Ringwald } 174fffdd288SMatthias Ringwald 175fffdd288SMatthias Ringwald static void inquiry_packet_handler (uint8_t packet_type, uint8_t *packet, uint16_t size){ 176fffdd288SMatthias Ringwald bd_addr_t addr; 177fffdd288SMatthias Ringwald int i; 178fffdd288SMatthias Ringwald int numResponses; 179fffdd288SMatthias Ringwald int index; 180fffdd288SMatthias Ringwald 181fffdd288SMatthias Ringwald // printf("packet_handler: pt: 0x%02x, packet[0]: 0x%02x\n", packet_type, packet[0]); 182fffdd288SMatthias Ringwald if (packet_type != HCI_EVENT_PACKET) return; 183fffdd288SMatthias Ringwald 184fffdd288SMatthias Ringwald uint8_t event = packet[0]; 185fffdd288SMatthias Ringwald 186fffdd288SMatthias Ringwald switch(event){ 187fffdd288SMatthias Ringwald case HCI_EVENT_INQUIRY_RESULT: 188fffdd288SMatthias Ringwald case HCI_EVENT_INQUIRY_RESULT_WITH_RSSI:{ 189fffdd288SMatthias Ringwald numResponses = packet[2]; 190fffdd288SMatthias Ringwald int offset = 3; 191fffdd288SMatthias Ringwald for (i=0; i<numResponses && deviceCount < MAX_DEVICES;i++){ 192fffdd288SMatthias Ringwald reverse_bd_addr(addr, &packet[offset]); 193fffdd288SMatthias Ringwald offset += 6; 194fffdd288SMatthias Ringwald index = getDeviceIndexForAddress(addr); 195fffdd288SMatthias Ringwald if (index >= 0) continue; // already in our list 196fffdd288SMatthias Ringwald memcpy(devices[deviceCount].address, addr, 6); 197fffdd288SMatthias Ringwald 198fffdd288SMatthias Ringwald devices[deviceCount].pageScanRepetitionMode = packet[offset]; 199fffdd288SMatthias Ringwald offset += 1; 200fffdd288SMatthias Ringwald 201fffdd288SMatthias Ringwald if (event == HCI_EVENT_INQUIRY_RESULT){ 202fffdd288SMatthias Ringwald offset += 2; // Reserved + Reserved 203fffdd288SMatthias Ringwald devices[deviceCount].classOfDevice = little_endian_read_24(packet, offset); 204fffdd288SMatthias Ringwald offset += 3; 205fffdd288SMatthias Ringwald devices[deviceCount].clockOffset = little_endian_read_16(packet, offset) & 0x7fff; 206fffdd288SMatthias Ringwald offset += 2; 207fffdd288SMatthias Ringwald devices[deviceCount].rssi = 0; 208fffdd288SMatthias Ringwald } else { 209fffdd288SMatthias Ringwald offset += 1; // Reserved 210fffdd288SMatthias Ringwald devices[deviceCount].classOfDevice = little_endian_read_24(packet, offset); 211fffdd288SMatthias Ringwald offset += 3; 212fffdd288SMatthias Ringwald devices[deviceCount].clockOffset = little_endian_read_16(packet, offset) & 0x7fff; 213fffdd288SMatthias Ringwald offset += 2; 214fffdd288SMatthias Ringwald devices[deviceCount].rssi = packet[offset]; 215fffdd288SMatthias Ringwald offset += 1; 216fffdd288SMatthias Ringwald } 217fffdd288SMatthias Ringwald devices[deviceCount].state = REMOTE_NAME_REQUEST; 218fffdd288SMatthias Ringwald printf("Device #%u found: %s with COD: 0x%06x, pageScan %d, clock offset 0x%04x, rssi 0x%02x\n", 219fffdd288SMatthias Ringwald deviceCount, bd_addr_to_str(addr), 220fffdd288SMatthias Ringwald devices[deviceCount].classOfDevice, devices[deviceCount].pageScanRepetitionMode, 221fffdd288SMatthias Ringwald devices[deviceCount].clockOffset, devices[deviceCount].rssi); 222fffdd288SMatthias Ringwald deviceCount++; 223fffdd288SMatthias Ringwald } 224fffdd288SMatthias Ringwald 225fffdd288SMatthias Ringwald break; 226fffdd288SMatthias Ringwald } 227fffdd288SMatthias Ringwald case HCI_EVENT_INQUIRY_COMPLETE: 228fffdd288SMatthias Ringwald for (i=0;i<deviceCount;i++) { 229fffdd288SMatthias Ringwald // retry remote name request 230fffdd288SMatthias Ringwald if (devices[i].state == REMOTE_NAME_INQUIRED) 231fffdd288SMatthias Ringwald devices[i].state = REMOTE_NAME_REQUEST; 232fffdd288SMatthias Ringwald } 233fffdd288SMatthias Ringwald continue_remote_names(); 234fffdd288SMatthias Ringwald break; 235fffdd288SMatthias Ringwald 236fffdd288SMatthias Ringwald case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE: 237fffdd288SMatthias Ringwald reverse_bd_addr(addr, &packet[3]); 238fffdd288SMatthias Ringwald index = getDeviceIndexForAddress(addr); 239fffdd288SMatthias Ringwald if (index >= 0) { 240fffdd288SMatthias Ringwald if (packet[2] == 0) { 241fffdd288SMatthias Ringwald printf("Name: '%s'\n", &packet[9]); 242fffdd288SMatthias Ringwald devices[index].state = REMOTE_NAME_FETCHED; 243fffdd288SMatthias Ringwald } else { 244fffdd288SMatthias Ringwald printf("Failed to get name: page timeout\n"); 245fffdd288SMatthias Ringwald } 246fffdd288SMatthias Ringwald } 247fffdd288SMatthias Ringwald continue_remote_names(); 248fffdd288SMatthias Ringwald break; 249fffdd288SMatthias Ringwald 250fffdd288SMatthias Ringwald default: 251fffdd288SMatthias Ringwald break; 252fffdd288SMatthias Ringwald } 253fffdd288SMatthias Ringwald } 254fffdd288SMatthias Ringwald // GAP INQUIRY END 255*d0755cd6SMatthias Ringwald #ifdef HAVE_POSIX_STDIN 256fffdd288SMatthias Ringwald 257fffdd288SMatthias Ringwald // prototypes 25835833313SMatthias Ringwald static void show_usage(void); 259fffdd288SMatthias Ringwald 260fffdd288SMatthias Ringwald // Testig User Interface 261fffdd288SMatthias Ringwald static void show_usage(void){ 262fffdd288SMatthias Ringwald printf("\n--- Bluetooth HFP Hands-Free (HF) unit Test Console ---\n"); 263fffdd288SMatthias Ringwald printf("---\n"); 264fffdd288SMatthias Ringwald 265fffdd288SMatthias Ringwald printf("a - establish HFP connection to PTS module\n"); 266fffdd288SMatthias Ringwald // printf("A - release HFP connection to PTS module\n"); 267fffdd288SMatthias Ringwald 268fffdd288SMatthias Ringwald printf("b - establish AUDIO connection\n"); 269fffdd288SMatthias Ringwald printf("B - release AUDIO connection\n"); 270fffdd288SMatthias Ringwald 271fffdd288SMatthias Ringwald printf("c - simulate incoming call from 1234567\n"); 272fffdd288SMatthias Ringwald printf("C - simulate call from 1234567 dropped\n"); 273fffdd288SMatthias Ringwald 274fffdd288SMatthias Ringwald printf("d - report AG failure\n"); 275fffdd288SMatthias Ringwald 276fffdd288SMatthias Ringwald printf("e - answer call on AG\n"); 277fffdd288SMatthias Ringwald printf("E - reject call on AG\n"); 278fffdd288SMatthias Ringwald 279fffdd288SMatthias Ringwald printf("r - disable in-band ring tone\n"); 280fffdd288SMatthias Ringwald printf("R - enable in-band ring tone\n"); 281fffdd288SMatthias Ringwald 282fffdd288SMatthias Ringwald printf("f - Disable cellular network\n"); 283fffdd288SMatthias Ringwald printf("F - Enable cellular network\n"); 284fffdd288SMatthias Ringwald 285fffdd288SMatthias Ringwald printf("g - Set signal strength to 0\n"); 286fffdd288SMatthias Ringwald printf("G - Set signal strength to 5\n"); 287fffdd288SMatthias Ringwald 288fffdd288SMatthias Ringwald printf("h - Disable roaming\n"); 289fffdd288SMatthias Ringwald printf("H - Enable roaming\n"); 290fffdd288SMatthias Ringwald 291fffdd288SMatthias Ringwald printf("i - Set battery level to 3\n"); 292fffdd288SMatthias Ringwald printf("I - Set battery level to 5\n"); 293fffdd288SMatthias Ringwald 294fffdd288SMatthias Ringwald printf("j - Answering call on remote side\n"); 295fffdd288SMatthias Ringwald 296fffdd288SMatthias Ringwald printf("k - Clear memory #1\n"); 297fffdd288SMatthias Ringwald printf("K - Set memory #1\n"); 298fffdd288SMatthias Ringwald 299fffdd288SMatthias Ringwald printf("l - Clear last number\n"); 300fffdd288SMatthias Ringwald printf("L - Set last number\n"); 301fffdd288SMatthias Ringwald 302fffdd288SMatthias Ringwald printf("m - simulate incoming call from 7654321\n"); 303fffdd288SMatthias Ringwald // printf("M - simulate call from 7654321 dropped\n"); 304fffdd288SMatthias Ringwald 305fffdd288SMatthias Ringwald printf("n - Disable Voice Regocnition\n"); 306fffdd288SMatthias Ringwald printf("N - Enable Voice Recognition\n"); 307fffdd288SMatthias Ringwald 308fffdd288SMatthias Ringwald printf("o - Set speaker volume to 0 (minimum)\n"); 309fffdd288SMatthias Ringwald printf("O - Set speaker volume to 9 (default)\n"); 310fffdd288SMatthias Ringwald printf("p - Set speaker volume to 12 (higher)\n"); 311fffdd288SMatthias Ringwald printf("P - Set speaker volume to 15 (maximum)\n"); 312fffdd288SMatthias Ringwald 313fffdd288SMatthias Ringwald printf("q - Set microphone gain to 0 (minimum)\n"); 314fffdd288SMatthias Ringwald printf("Q - Set microphone gain to 9 (default)\n"); 315fffdd288SMatthias Ringwald printf("s - Set microphone gain to 12 (higher)\n"); 316fffdd288SMatthias Ringwald printf("S - Set microphone gain to 15 (maximum)\n"); 317fffdd288SMatthias Ringwald 318fffdd288SMatthias Ringwald printf("t - terminate connection\n"); 319fffdd288SMatthias Ringwald printf("u - join held call\n"); 320fffdd288SMatthias Ringwald printf("v - discover nearby HF units\n"); 321fffdd288SMatthias Ringwald printf("w - put incoming call on hold (Response and Hold)\n"); 322fffdd288SMatthias Ringwald printf("x - accept held incoming call (Response and Hold)\n"); 323fffdd288SMatthias Ringwald printf("X - reject held incoming call (Response and Hold)\n"); 324fffdd288SMatthias Ringwald 325fffdd288SMatthias Ringwald printf("---\n"); 326fffdd288SMatthias Ringwald printf("Ctrl-c - exit\n"); 327fffdd288SMatthias Ringwald printf("---\n"); 328fffdd288SMatthias Ringwald } 329fffdd288SMatthias Ringwald 3304af4141bSMatthias Ringwald static void stdin_process(btstack_data_source_t *ds, btstack_data_source_callback_type_t callback_type){ 331fffdd288SMatthias Ringwald read(ds->fd, &cmd, 1); 332fffdd288SMatthias Ringwald switch (cmd){ 333fffdd288SMatthias Ringwald case 'a': 334fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 335fffdd288SMatthias Ringwald printf("Establish HFP service level connection to PTS module %s...\n", bd_addr_to_str(device_addr)); 336fffdd288SMatthias Ringwald hfp_ag_establish_service_level_connection(device_addr); 337fffdd288SMatthias Ringwald break; 338fffdd288SMatthias Ringwald case 'A': 339fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 340fffdd288SMatthias Ringwald printf("Release HFP service level connection.\n"); 341fffdd288SMatthias Ringwald hfp_ag_release_service_level_connection(device_addr); 342fffdd288SMatthias Ringwald break; 343fffdd288SMatthias Ringwald case 'Z': 344fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 345fffdd288SMatthias Ringwald printf("Release HFP service level connection to %s...\n", bd_addr_to_str(device_addr)); 346fffdd288SMatthias Ringwald hfp_ag_release_service_level_connection(device_addr); 347fffdd288SMatthias Ringwald break; 348fffdd288SMatthias Ringwald case 'b': 349fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 350fffdd288SMatthias Ringwald printf("Establish Audio connection %s...\n", bd_addr_to_str(device_addr)); 351fffdd288SMatthias Ringwald hfp_ag_establish_audio_connection(device_addr); 352fffdd288SMatthias Ringwald break; 353fffdd288SMatthias Ringwald case 'B': 354fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 355fffdd288SMatthias Ringwald printf("Release Audio connection.\n"); 356fffdd288SMatthias Ringwald hfp_ag_release_audio_connection(device_addr); 357fffdd288SMatthias Ringwald break; 358fffdd288SMatthias Ringwald case 'c': 359fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 360fffdd288SMatthias Ringwald printf("Simulate incoming call from 1234567\n"); 361fffdd288SMatthias Ringwald hfp_ag_set_clip(129, "1234567"); 362fffdd288SMatthias Ringwald hfp_ag_incoming_call(); 363fffdd288SMatthias Ringwald break; 364fffdd288SMatthias Ringwald case 'm': 365fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 366fffdd288SMatthias Ringwald printf("Simulate incoming call from 7654321\n"); 367fffdd288SMatthias Ringwald hfp_ag_set_clip(129, "7654321"); 368fffdd288SMatthias Ringwald hfp_ag_incoming_call(); 369fffdd288SMatthias Ringwald break; 370fffdd288SMatthias Ringwald case 'C': 371fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 372fffdd288SMatthias Ringwald printf("Simulate terminate call\n"); 373fffdd288SMatthias Ringwald hfp_ag_call_dropped(); 374fffdd288SMatthias Ringwald break; 375fffdd288SMatthias Ringwald case 'd': 376fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 377fffdd288SMatthias Ringwald printf("Report AG failure\n"); 378fffdd288SMatthias Ringwald hfp_ag_report_extended_audio_gateway_error_result_code(device_addr, HFP_CME_ERROR_AG_FAILURE); 379fffdd288SMatthias Ringwald break; 380fffdd288SMatthias Ringwald case 'e': 381fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 382fffdd288SMatthias Ringwald printf("Answer call on AG\n"); 383fffdd288SMatthias Ringwald hfp_ag_answer_incoming_call(); 384fffdd288SMatthias Ringwald break; 385fffdd288SMatthias Ringwald case 'E': 386fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 387fffdd288SMatthias Ringwald printf("Reject call on AG\n"); 388fffdd288SMatthias Ringwald hfp_ag_terminate_call(); 389fffdd288SMatthias Ringwald break; 390fffdd288SMatthias Ringwald case 'f': 391fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 392fffdd288SMatthias Ringwald printf("Disable cellular network\n"); 393fffdd288SMatthias Ringwald hfp_ag_set_registration_status(0); 394fffdd288SMatthias Ringwald break; 395fffdd288SMatthias Ringwald case 'F': 396fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 397fffdd288SMatthias Ringwald printf("Enable cellular network\n"); 398fffdd288SMatthias Ringwald hfp_ag_set_registration_status(1); 399fffdd288SMatthias Ringwald break; 400fffdd288SMatthias Ringwald case 'g': 401fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 402fffdd288SMatthias Ringwald printf("Set signal strength to 0\n"); 403fffdd288SMatthias Ringwald hfp_ag_set_signal_strength(0); 404fffdd288SMatthias Ringwald break; 405fffdd288SMatthias Ringwald case 'G': 406fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 407fffdd288SMatthias Ringwald printf("Set signal strength to 5\n"); 408fffdd288SMatthias Ringwald hfp_ag_set_signal_strength(5); 409fffdd288SMatthias Ringwald break; 410fffdd288SMatthias Ringwald case 'h': 411fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 412fffdd288SMatthias Ringwald printf("Disable roaming\n"); 413fffdd288SMatthias Ringwald hfp_ag_set_roaming_status(0); 414fffdd288SMatthias Ringwald break; 415fffdd288SMatthias Ringwald case 'H': 416fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 417fffdd288SMatthias Ringwald printf("Enable roaming\n"); 418fffdd288SMatthias Ringwald hfp_ag_set_roaming_status(1); 419fffdd288SMatthias Ringwald break; 420fffdd288SMatthias Ringwald case 'i': 421fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 422fffdd288SMatthias Ringwald printf("Set battery level to 3\n"); 423fffdd288SMatthias Ringwald hfp_ag_set_battery_level(3); 424fffdd288SMatthias Ringwald break; 425fffdd288SMatthias Ringwald case 'I': 426fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 427fffdd288SMatthias Ringwald printf("Set battery level to 5\n"); 428fffdd288SMatthias Ringwald hfp_ag_set_battery_level(5); 429fffdd288SMatthias Ringwald break; 430fffdd288SMatthias Ringwald case 'j': 431fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 432fffdd288SMatthias Ringwald printf("Answering call on remote side\n"); 433fffdd288SMatthias Ringwald hfp_ag_outgoing_call_established(); 434fffdd288SMatthias Ringwald break; 435fffdd288SMatthias Ringwald case 'r': 436fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 437fffdd288SMatthias Ringwald printf("Disable in-band ring tone\n"); 438fffdd288SMatthias Ringwald hfp_ag_set_use_in_band_ring_tone(0); 439fffdd288SMatthias Ringwald break; 440fffdd288SMatthias Ringwald case 'k': 441fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 442fffdd288SMatthias Ringwald printf("Memory 1 cleared\n"); 443fffdd288SMatthias Ringwald memory_1_enabled = 0; 444fffdd288SMatthias Ringwald break; 445fffdd288SMatthias Ringwald case 'K': 446fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 447fffdd288SMatthias Ringwald printf("Memory 1 set\n"); 448fffdd288SMatthias Ringwald memory_1_enabled = 1; 449fffdd288SMatthias Ringwald break; 450fffdd288SMatthias Ringwald case 'l': 451fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 452fffdd288SMatthias Ringwald printf("Last dialed number cleared\n"); 453fffdd288SMatthias Ringwald hfp_ag_clear_last_dialed_number(); 454fffdd288SMatthias Ringwald break; 455fffdd288SMatthias Ringwald case 'L': 456fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 457fffdd288SMatthias Ringwald printf("Outgoing call connected, ringing\n"); 458fffdd288SMatthias Ringwald hfp_ag_outgoing_call_ringing(); 459fffdd288SMatthias Ringwald break; 460fffdd288SMatthias Ringwald case 'n': 461fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 462fffdd288SMatthias Ringwald printf("Disable Voice Recognition\n"); 463fffdd288SMatthias Ringwald hfp_ag_activate_voice_recognition(device_addr, 0); 464fffdd288SMatthias Ringwald break; 465fffdd288SMatthias Ringwald case 'N': 466fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 467fffdd288SMatthias Ringwald printf("Enable Voice Recognition\n"); 468fffdd288SMatthias Ringwald hfp_ag_activate_voice_recognition(device_addr, 1); 469fffdd288SMatthias Ringwald break; 470fffdd288SMatthias Ringwald case 'o': 471fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 472fffdd288SMatthias Ringwald printf("Set speaker gain to 0 (minimum)\n"); 473fffdd288SMatthias Ringwald hfp_ag_set_speaker_gain(device_addr, 0); 474fffdd288SMatthias Ringwald break; 475fffdd288SMatthias Ringwald case 'O': 476fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 477fffdd288SMatthias Ringwald printf("Set speaker gain to 9 (default)\n"); 478fffdd288SMatthias Ringwald hfp_ag_set_speaker_gain(device_addr, 9); 479fffdd288SMatthias Ringwald break; 480fffdd288SMatthias Ringwald case 'p': 481fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 482fffdd288SMatthias Ringwald printf("Set speaker gain to 12 (higher)\n"); 483fffdd288SMatthias Ringwald hfp_ag_set_speaker_gain(device_addr, 12); 484fffdd288SMatthias Ringwald break; 485fffdd288SMatthias Ringwald case 'P': 486fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 487fffdd288SMatthias Ringwald printf("Set speaker gain to 15 (maximum)\n"); 488fffdd288SMatthias Ringwald hfp_ag_set_speaker_gain(device_addr, 15); 489fffdd288SMatthias Ringwald break; 490fffdd288SMatthias Ringwald case 'q': 491fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 492fffdd288SMatthias Ringwald printf("Set microphone gain to 0\n"); 493fffdd288SMatthias Ringwald hfp_ag_set_microphone_gain(device_addr, 0); 494fffdd288SMatthias Ringwald break; 495fffdd288SMatthias Ringwald case 'Q': 496fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 497fffdd288SMatthias Ringwald printf("Set microphone gain to 9\n"); 498fffdd288SMatthias Ringwald hfp_ag_set_microphone_gain(device_addr, 9); 499fffdd288SMatthias Ringwald break; 500fffdd288SMatthias Ringwald case 's': 501fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 502fffdd288SMatthias Ringwald printf("Set microphone gain to 12\n"); 503fffdd288SMatthias Ringwald hfp_ag_set_microphone_gain(device_addr, 12); 504fffdd288SMatthias Ringwald break; 505fffdd288SMatthias Ringwald case 'S': 506fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 507fffdd288SMatthias Ringwald printf("Set microphone gain to 15\n"); 508fffdd288SMatthias Ringwald hfp_ag_set_microphone_gain(device_addr, 15); 509fffdd288SMatthias Ringwald break; 510fffdd288SMatthias Ringwald case 'R': 511fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 512fffdd288SMatthias Ringwald printf("Enable in-band ring tone\n"); 513fffdd288SMatthias Ringwald hfp_ag_set_use_in_band_ring_tone(1); 514fffdd288SMatthias Ringwald break; 515fffdd288SMatthias Ringwald case 't': 516fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 517fffdd288SMatthias Ringwald printf("Terminate HCI connection.\n"); 518fffdd288SMatthias Ringwald gap_disconnect(handle); 519fffdd288SMatthias Ringwald break; 520fffdd288SMatthias Ringwald case 'u': 521fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 522fffdd288SMatthias Ringwald printf("Join held call\n"); 523fffdd288SMatthias Ringwald hfp_ag_join_held_call(); 524fffdd288SMatthias Ringwald break; 525fffdd288SMatthias Ringwald case 'v': 526fffdd288SMatthias Ringwald start_scan(); 527fffdd288SMatthias Ringwald break; 528fffdd288SMatthias Ringwald case 'w': 529fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 530fffdd288SMatthias Ringwald printf("AG: Put incoming call on hold (Response and Hold)\n"); 531fffdd288SMatthias Ringwald hfp_ag_hold_incoming_call(); 532fffdd288SMatthias Ringwald break; 533fffdd288SMatthias Ringwald case 'x': 534fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 535fffdd288SMatthias Ringwald printf("AG: Accept held incoming call (Response and Hold)\n"); 536fffdd288SMatthias Ringwald hfp_ag_accept_held_incoming_call(); 537fffdd288SMatthias Ringwald break; 538fffdd288SMatthias Ringwald case 'X': 539fffdd288SMatthias Ringwald log_info("USER:\'%c\'", cmd); 540fffdd288SMatthias Ringwald printf("AG: Reject held incoming call (Response and Hold)\n"); 541fffdd288SMatthias Ringwald hfp_ag_reject_held_incoming_call(); 542fffdd288SMatthias Ringwald break; 543fffdd288SMatthias Ringwald default: 544fffdd288SMatthias Ringwald show_usage(); 545fffdd288SMatthias Ringwald break; 546fffdd288SMatthias Ringwald } 547fffdd288SMatthias Ringwald } 548fffdd288SMatthias Ringwald #endif 549fffdd288SMatthias Ringwald 550fffdd288SMatthias Ringwald static void packet_handler(uint8_t * event, uint16_t event_size){ 551fffdd288SMatthias Ringwald 552fffdd288SMatthias Ringwald if (event[0] == RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE){ 553fffdd288SMatthias Ringwald handle = little_endian_read_16(event, 9); 554fffdd288SMatthias Ringwald printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE received for handle 0x%04x\n", handle); 555fffdd288SMatthias Ringwald return; 556fffdd288SMatthias Ringwald } 557fffdd288SMatthias Ringwald 558fffdd288SMatthias Ringwald switch (event[0]){ 559fffdd288SMatthias Ringwald case RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE: 560fffdd288SMatthias Ringwald handle = little_endian_read_16(event, 9); 561fffdd288SMatthias Ringwald printf("RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE received for handle 0x%04x\n", handle); 562fffdd288SMatthias Ringwald return; 563fffdd288SMatthias Ringwald 564fffdd288SMatthias Ringwald case HCI_EVENT_INQUIRY_RESULT: 565fffdd288SMatthias Ringwald case HCI_EVENT_INQUIRY_RESULT_WITH_RSSI: 566fffdd288SMatthias Ringwald case HCI_EVENT_INQUIRY_COMPLETE: 567fffdd288SMatthias Ringwald case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE: 568fffdd288SMatthias Ringwald inquiry_packet_handler(HCI_EVENT_PACKET, event, event_size); 569fffdd288SMatthias Ringwald break; 570fffdd288SMatthias Ringwald 571fffdd288SMatthias Ringwald default: 572fffdd288SMatthias Ringwald break; 573fffdd288SMatthias Ringwald } 574fffdd288SMatthias Ringwald 575fffdd288SMatthias Ringwald 576fffdd288SMatthias Ringwald if (event[0] != HCI_EVENT_HFP_META) return; 577fffdd288SMatthias Ringwald 578fffdd288SMatthias Ringwald if (event[3] 579fffdd288SMatthias Ringwald && event[2] != HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER 580fffdd288SMatthias Ringwald && event[2] != HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG 581fffdd288SMatthias Ringwald && event[2] != HFP_SUBEVENT_TRANSMIT_DTMF_CODES){ 582fffdd288SMatthias Ringwald printf("ERROR, status: %u\n", event[3]); 583fffdd288SMatthias Ringwald return; 584fffdd288SMatthias Ringwald } 585fffdd288SMatthias Ringwald 586fffdd288SMatthias Ringwald switch (event[2]) { 587fffdd288SMatthias Ringwald case HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED: 588fffdd288SMatthias Ringwald printf("Service level connection established.\n"); 589fffdd288SMatthias Ringwald break; 590fffdd288SMatthias Ringwald case HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED: 591fffdd288SMatthias Ringwald printf("Service level connection released.\n"); 592fffdd288SMatthias Ringwald break; 593fffdd288SMatthias Ringwald case HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED: 594fffdd288SMatthias Ringwald printf("\n** Audio connection established **\n"); 595fffdd288SMatthias Ringwald break; 596fffdd288SMatthias Ringwald case HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED: 597fffdd288SMatthias Ringwald printf("\n** Audio connection released **\n"); 598fffdd288SMatthias Ringwald break; 599fffdd288SMatthias Ringwald case HFP_SUBEVENT_START_RINGINIG: 600fffdd288SMatthias Ringwald printf("\n** Start Ringing **\n"); 601fffdd288SMatthias Ringwald break; 602fffdd288SMatthias Ringwald case HFP_SUBEVENT_STOP_RINGINIG: 603fffdd288SMatthias Ringwald printf("\n** Stop Ringing **\n"); 604fffdd288SMatthias Ringwald break; 605fffdd288SMatthias Ringwald case HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER: 606fffdd288SMatthias Ringwald printf("\n** Outgoing call '%s' **\n", &event[3]); 607fffdd288SMatthias Ringwald // validate number 608fffdd288SMatthias Ringwald if ( strcmp("1234567", (char*) &event[3]) == 0 609fffdd288SMatthias Ringwald || strcmp("7654321", (char*) &event[3]) == 0 610fffdd288SMatthias Ringwald || (memory_1_enabled && strcmp(">1", (char*) &event[3]) == 0)){ 611fffdd288SMatthias Ringwald printf("Dialstring valid: accept call\n"); 612fffdd288SMatthias Ringwald hfp_ag_outgoing_call_accepted(); 613fffdd288SMatthias Ringwald } else { 614fffdd288SMatthias Ringwald printf("Dialstring invalid: reject call\n"); 615fffdd288SMatthias Ringwald hfp_ag_outgoing_call_rejected(); 616fffdd288SMatthias Ringwald } 617fffdd288SMatthias Ringwald break; 618fffdd288SMatthias Ringwald 619fffdd288SMatthias Ringwald case HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG: 620fffdd288SMatthias Ringwald printf("\n** Attach number to voice tag. Sending '1234567\n"); 621fffdd288SMatthias Ringwald hfp_ag_send_phone_number_for_voice_tag(device_addr, "1234567"); 622fffdd288SMatthias Ringwald break; 623fffdd288SMatthias Ringwald case HFP_SUBEVENT_TRANSMIT_DTMF_CODES: 624fffdd288SMatthias Ringwald printf("\n** Send DTMF Codes: '%s'\n", &event[3]); 625fffdd288SMatthias Ringwald hfp_ag_send_dtmf_code_done(device_addr); 626fffdd288SMatthias Ringwald break; 627fffdd288SMatthias Ringwald case HFP_CMD_CALL_ANSWERED: 628fffdd288SMatthias Ringwald printf("Call answered by HF\n"); 629fffdd288SMatthias Ringwald break; 630fffdd288SMatthias Ringwald default: 631fffdd288SMatthias Ringwald printf("Event not handled %u\n", event[2]); 632fffdd288SMatthias Ringwald break; 633fffdd288SMatthias Ringwald } 634fffdd288SMatthias Ringwald } 635fffdd288SMatthias Ringwald 636fffdd288SMatthias Ringwald static hfp_phone_number_t subscriber_number = { 637fffdd288SMatthias Ringwald 129, "225577" 638fffdd288SMatthias Ringwald }; 639fffdd288SMatthias Ringwald 640fffdd288SMatthias Ringwald /* @section Main Application Setup 641fffdd288SMatthias Ringwald * 642fffdd288SMatthias Ringwald * @text Listing MainConfiguration shows main application code. 643fffdd288SMatthias Ringwald * To run a HFP AG service you need to initialize the SDP, and to create and register HFP AG record with it. 644fffdd288SMatthias Ringwald * The packet_handler is used for sending commands to the HFP HF. It also receives the HFP HF's answers. 645fffdd288SMatthias Ringwald * The stdin_process callback allows for sending commands to the HFP HF. 646fffdd288SMatthias Ringwald * At the end the Bluetooth stack is started. 647fffdd288SMatthias Ringwald */ 648fffdd288SMatthias Ringwald 649fffdd288SMatthias Ringwald /* LISTING_START(MainConfiguration): Setup HFP Audio Gateway */ 650fffdd288SMatthias Ringwald 651fffdd288SMatthias Ringwald int btstack_main(int argc, const char * argv[]); 652fffdd288SMatthias Ringwald int btstack_main(int argc, const char * argv[]){ 653fffdd288SMatthias Ringwald // HFP HS address is hardcoded, please change it 654fffdd288SMatthias Ringwald // init L2CAP 655fffdd288SMatthias Ringwald l2cap_init(); 656fffdd288SMatthias Ringwald rfcomm_init(); 657fffdd288SMatthias Ringwald sdp_init(); 658fffdd288SMatthias Ringwald 659fffdd288SMatthias Ringwald hfp_ag_init(rfcomm_channel_nr); 660fffdd288SMatthias Ringwald hfp_ag_init_supported_features(0x3ef | (1<<HFP_AGSF_HF_INDICATORS) | (1<<HFP_AGSF_ESCO_S4)); 661fffdd288SMatthias Ringwald hfp_ag_init_codecs(sizeof(codecs), codecs); 662fffdd288SMatthias Ringwald hfp_ag_init_ag_indicators(ag_indicators_nr, ag_indicators); 663fffdd288SMatthias Ringwald hfp_ag_init_hf_indicators(hf_indicators_nr, hf_indicators); 664fffdd288SMatthias Ringwald hfp_ag_init_call_hold_services(call_hold_services_nr, call_hold_services); 665fffdd288SMatthias Ringwald 666fffdd288SMatthias Ringwald hfp_ag_set_subcriber_number_information(&subscriber_number, 1); 667fffdd288SMatthias Ringwald hfp_ag_register_packet_handler(packet_handler); 668fffdd288SMatthias Ringwald 669fffdd288SMatthias Ringwald memset(hfp_service_buffer, 0, sizeof(hfp_service_buffer)); 670fffdd288SMatthias Ringwald hfp_ag_create_sdp_record( hfp_service_buffer, 0x10001, rfcomm_channel_nr, hfp_ag_service_name, 0, 0); 671fffdd288SMatthias Ringwald printf("SDP service record size: %u\n", de_get_len( hfp_service_buffer)); 672fffdd288SMatthias Ringwald sdp_register_service(hfp_service_buffer); 673fffdd288SMatthias Ringwald 674*d0755cd6SMatthias Ringwald #ifdef HAVE_POSIX_STDIN 675fffdd288SMatthias Ringwald btstack_stdin_setup(stdin_process); 676fffdd288SMatthias Ringwald #endif 677fffdd288SMatthias Ringwald // turn on! 678fffdd288SMatthias Ringwald hci_power_control(HCI_POWER_ON); 679fffdd288SMatthias Ringwald return 0; 680fffdd288SMatthias Ringwald } 681fffdd288SMatthias Ringwald /* LISTING_END */ 682