Starting with btstack (HFP_ag_Demo and HFP_hf_Demo)

616 views
Skip to first unread message

Achref Mabrouk

unread,
Jul 16, 2018, 2:01:48 PM7/16/18
to btstack-dev
Hey,

I'm trying to run HFP_ag_Demo using an STM32F091RC and a CC2564. I managed to do the first changes to make the code compile on Eclipse but I still don't know how to personalize the Demo to connect my CC2564 to a bluetooth earpiece. I admit that i'm a bit lost: 
- Where in the code i can enter the address of the device i want to be connected to ? 
- I don't see in the code where a quiry is done to look for the available devices and try to connect to one of them.
- Should I change something in the code of "HFP_ag_Demo" or just run it as it is.
- I triyed to do a quiry just after the event "BTSTACK_EVENT_STATE" and connect to a specific device (my earpiece) after the inquiry result , this is how my code looks like (I put in blue color what i added to the standard code): 

 * In my main .c : 

static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
UNUSED(size);
UNUSED(channel);
if (packet_type != HCI_EVENT_PACKET) return;
switch(hci_event_packet_get_type(packet)){
case BTSTACK_EVENT_STATE:
if (btstack_event_state_get_state(packet) != HCI_STATE_WORKING) return;
printf("BTstack up and running.\n");

if(hci_can_send_command_packet_now())
{
hci_send_cmd(&hci_write_inquiry_mode,0x00);
}

break;

case HCI_EVENT_COMMAND_COMPLETE:
if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_version_information)){
uint16_t manufacturer   = little_endian_read_16(packet, 10);
uint16_t lmp_subversion = little_endian_read_16(packet, 12);
// assert manufacturer is TI
if (manufacturer != BLUETOOTH_COMPANY_ID_TEXAS_INSTRUMENTS_INC){
printf("ERROR: Expected Bluetooth Chipset from TI but got manufacturer 0x%04x\n", manufacturer);
break;
}
// assert correct init script is used based on expected lmp_subversion
if (lmp_subversion != btstack_chipset_cc256x_lmp_subversion()){
printf("Error: LMP Subversion does not match initscript! ");
printf("Your initscripts is for %s chipset\n", btstack_chipset_cc256x_lmp_subversion() < lmp_subversion ? "an older" : "a newer");
printf("Please update Makefile to include the appropriate bluetooth_init_cc256???.c file\n");
break;
}
}

if (HCI_EVENT_IS_COMMAND_COMPLETE(packet,hci_write_inquiry_mode))
{
gap_inquiry_start(4);
}
break;

default:
break;
}
}


void port_main(void){
// init memory pools
btstack_memory_init();
// default run loop for embedded systems - classic while loop
btstack_run_loop_init(btstack_run_loop_embedded_get_instance());
// enable packet logging, at least while porting
hci_dump_open( NULL, HCI_DUMP_STDOUT );
// init HCI
hci_init(hci_transport_h4_instance(btstack_uart_block_embedded_instance()), (void*) &config);

hci_set_chipset(btstack_chipset_cc256x_instance());

// inform about BTstack state
hci_event_callback_registration.callback = &packet_handler;
hci_add_event_handler(&hci_event_callback_registration);

// hand over to BTstack example code
btstack_main(0, NULL);
// go
btstack_run_loop_execute();
}

* In HFP_ag_Demo : 

static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t * event, uint16_t event_size){
    UNUSED(channel);
    bd_addr_t addr;
    uint8_t status;
    switch (packet_type){
        case HCI_EVENT_PACKET:
            switch(hci_event_packet_get_type(event)){
#ifndef HAVE_BTSTACK_STDIN
                case BTSTACK_EVENT_STATE:
                    if (btstack_event_state_get_state(event) != HCI_STATE_WORKING) break;
                    printf("Establish HFP AG service level connection to %s...\n", bd_addr_to_str(device_addr));
                    hfp_ag_establish_service_level_connection(device_addr);
                    break;
#endif
                case GAP_EVENT_INQUIRY_RESULT:
                    gap_event_inquiry_result_get_bd_addr(event, addr);
                    // print info
                    printf("Device found: %s ",  bd_addr_to_str(addr));
                    printf("with COD: 0x%06x, ", (unsigned int) gap_event_inquiry_result_get_class_of_device(event));
                    if (gap_event_inquiry_result_get_rssi_available(event)){
                        printf(", rssi %d dBm", (int8_t) gap_event_inquiry_result_get_rssi(event));
                    }
                    if (gap_event_inquiry_result_get_name_available(event)){
                        char name_buffer[240];
                        int name_len = gap_event_inquiry_result_get_name_len(event);
                        memcpy(name_buffer, gap_event_inquiry_result_get_name(event), name_len);
                        name_buffer[name_len] = 0;
                        printf(", name '%s'", name_buffer);
                    }
                    printf("\n");

                    if (strcmp(bd_addr_to_str(addr),"00:22:A6:33:AE:D3") == 0)
                    {
            printf("\r\nDevice Achref Found\r\n");
            for (int i = 0; i< BD_ADDR_LEN; i++)
            {
            address_Ach[i] = addr[i];
            }
                    }

                    break;
                case GAP_EVENT_INQUIRY_COMPLETE:
                    printf("Inquiry scan complete.\n");

            if (address_Ach[1] == 34)
                {
            gap_connectable_control(1);
            hsp_ag_connect(address_Ach);
                }

                    break;
                case HCI_EVENT_SCO_CAN_SEND_NOW:
                    sco_demo_send(sco_handle); 
                    break; 
                case HCI_EVENT_COMMAND_COMPLETE:
                    if (HCI_EVENT_IS_COMMAND_COMPLETE(event, hci_read_local_supported_features)){
                        dump_supported_codecs();
                    }
                    break;
                default:
                    break;
            }

            if (hci_event_packet_get_type(event) != HCI_EVENT_HFP_META) return;

            if (event[3]
                && hci_event_hfp_meta_get_subevent_code(event) != HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER
                && hci_event_hfp_meta_get_subevent_code(event) != HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG 
                && hci_event_hfp_meta_get_subevent_code(event) != HFP_SUBEVENT_TRANSMIT_DTMF_CODES){
                printf("ERROR, status: %u\n", event[3]);
                return;
            }

            switch (hci_event_hfp_meta_get_subevent_code(event)) {   
                case HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_ESTABLISHED:
                    status = hfp_subevent_service_level_connection_established_get_status(event);
                    if (status){
                        printf("Connection failed, staus 0x%02x\n", status);
                        break;
                    }
                    acl_handle = hfp_subevent_service_level_connection_established_get_con_handle(event);
                    hfp_subevent_service_level_connection_established_get_bd_addr(event, device_addr);
                    printf("Service level connection established to %s.\n", bd_addr_to_str(device_addr));
                    dump_supported_codecs();
#ifndef HAVE_BTSTACK_STDIN
                    log_info("Establish Audio connection %s", bd_addr_to_str(device_addr));
                    printf("Establish Audio connection %s...\n", bd_addr_to_str(device_addr));
                    hfp_ag_establish_audio_connection(acl_handle);
#endif
                    break;
                case HFP_SUBEVENT_SERVICE_LEVEL_CONNECTION_RELEASED:
                    printf("Service level connection released.\n");
                    sco_handle = 0;
                    break;
                case HFP_SUBEVENT_AUDIO_CONNECTION_ESTABLISHED:
                    if (hfp_subevent_audio_connection_established_get_status(event)){
                        printf("Audio connection establishment failed with status %u\n", hfp_subevent_audio_connection_established_get_status(event));
                        sco_handle = 0;
                    } else {
                        sco_handle = hfp_subevent_audio_connection_established_get_handle(event);
                        printf("Audio connection established with SCO handle 0x%04x.\n", sco_handle);
                        negotiated_codec = hfp_subevent_audio_connection_established_get_negotiated_codec(event);
                        switch (negotiated_codec){
                            case 0x01:
                                printf("Using CVSD codec.\n");
                                break;
                            case 0x02:
                                printf("Using mSBC codec.\n");
                                break;
                            default:
                                printf("Using unknown codec 0x%02x.\n", negotiated_codec);
                                break;
                        }
                        sco_demo_set_codec(negotiated_codec);
                        hci_request_sco_can_send_now_event();
                    }
                    break;
                case HFP_SUBEVENT_AUDIO_CONNECTION_RELEASED:
                    printf("Audio connection released\n");
                    sco_handle = 0;
                    sco_demo_close();
                    break;
                case HFP_SUBEVENT_START_RINGINIG:
                    printf("Start Ringing\n");
                    break;        
                case HFP_SUBEVENT_STOP_RINGINIG:
                    printf("Stop Ringing\n");
                    break;
                case HFP_SUBEVENT_PLACE_CALL_WITH_NUMBER:
                    printf("Outgoing call '%s'\n", hfp_subevent_place_call_with_number_get_number(event));
                    // validate number
                    if ( strcmp("1234567", hfp_subevent_place_call_with_number_get_number(event)) == 0
                      || strcmp("7654321", hfp_subevent_place_call_with_number_get_number(event)) == 0
                      || (memory_1_enabled && strcmp(">1", hfp_subevent_place_call_with_number_get_number(event)) == 0)){
                        printf("Dialstring valid: accept call\n");
                        hfp_ag_outgoing_call_accepted();
                    } else {
                        printf("Dialstring invalid: reject call\n");
                        hfp_ag_outgoing_call_rejected();
                    }
                    break;
                
                case HFP_SUBEVENT_ATTACH_NUMBER_TO_VOICE_TAG:
                    printf("Attach number to voice tag. Sending '1234567\n");
                    hfp_ag_send_phone_number_for_voice_tag(acl_handle, "1234567");
                    break;
                case HFP_SUBEVENT_TRANSMIT_DTMF_CODES:
                    printf("Send DTMF Codes: '%s'\n", hfp_subevent_transmit_dtmf_codes_get_dtmf(event));
                    hfp_ag_send_dtmf_code_done(acl_handle);
                    break;
                case HFP_SUBEVENT_CALL_ANSWERED:
                    printf("Call answered by HF\n");
                    break;
                default:
                    printf("Event not handled %u\n", hci_event_hfp_meta_get_subevent_code(event));
                    break;
            }
            break;
        case HCI_SCO_DATA_PACKET:
            sco_demo_receive(event, event_size);
            break;
        default:
            break;
    }
}

int btstack_main(int argc, const char * argv[]);
int btstack_main(int argc, const char * argv[]){
    (void)argc;
    (void)argv;

    sco_demo_init();

    // register for HCI events
    hci_event_callback_registration.callback = &packet_handler;
    hci_add_event_handler(&hci_event_callback_registration);
    hci_register_sco_packet_handler(&packet_handler);

    gap_set_local_name("HFP AG Demo 00:00:00:00:00:00");
    gap_discoverable_control(1);

    // L2CAP
    l2cap_init();

    uint16_t supported_features                   =
        (1<<HFP_AGSF_ESCO_S4)                     |
        (1<<HFP_AGSF_HF_INDICATORS)               |
        (1<<HFP_AGSF_CODEC_NEGOTIATION)           |
        (1<<HFP_AGSF_EXTENDED_ERROR_RESULT_CODES) |
        (1<<HFP_AGSF_ENHANCED_CALL_CONTROL)       |
        (1<<HFP_AGSF_ENHANCED_CALL_STATUS)        |
        (1<<HFP_AGSF_ABILITY_TO_REJECT_A_CALL)    |
        (1<<HFP_AGSF_IN_BAND_RING_TONE)           |
        (1<<HFP_AGSF_VOICE_RECOGNITION_FUNCTION)  |
        (1<<HFP_AGSF_THREE_WAY_CALLING);
    int wide_band_speech = 1;

    // HFP
    rfcomm_init();
    hfp_ag_init(rfcomm_channel_nr);
    hfp_ag_init_supported_features(supported_features);
    hfp_ag_init_codecs(sizeof(codecs), codecs);
    hfp_ag_init_ag_indicators(ag_indicators_nr, ag_indicators);
    hfp_ag_init_hf_indicators(hf_indicators_nr, hf_indicators); 
    hfp_ag_init_call_hold_services(call_hold_services_nr, call_hold_services);
    hfp_ag_set_subcriber_number_information(&subscriber_number, 1);
    hfp_ag_register_packet_handler(&packet_handler);
    hci_register_sco_packet_handler(&packet_handler);

    // SDP Server
    sdp_init();
    memset(hfp_service_buffer, 0, sizeof(hfp_service_buffer));
    hfp_ag_create_sdp_record( hfp_service_buffer, 0x10001, rfcomm_channel_nr, hfp_ag_service_name, 0, supported_features, wide_band_speech);
    printf("SDP service record size: %u\n", de_get_len( hfp_service_buffer));
    sdp_register_service(hfp_service_buffer);
    
    // parse humand readable Bluetooth address
    sscanf_bd_addr(device_addr_string, device_addr);

#ifdef HAVE_BTSTACK_STDIN
    btstack_stdin_setup(stdin_process);

#endif  
    // turn on!
    hci_power_control(HCI_POWER_ON);
    return 0;
}

This is what i get when i run it (messages after i found the bluetooth earpiece and try to connect to it)

sp_ag.c.470: Start SDP query 00:22:A6:33:AE:D3, 0x1108
l2cap.c.1821: L2CAP_CREATE_CHANNEL addr 00:22:A6:33:AE:D3 psm 0x1 mtu 1017 -> local mtu 1017
hci.c.3563: Create_connection to 00:22:A6:33:AE:D3
hci.c.185: create_connection_for_addr 00:22:A6:33:AE:D3, type ff
 hci.c.3575: conn state 0
Connection_complete (status=0) 00:22:A6:33:AE:D3
hci.c.2019: New connection: handle 1, 00:22:A6:33:AE:D3
hci.c.3922: BTSTACK_EVENT_NR_CONNECTIONS_CHANGED 1
CI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE, bonding flags 2, eSCO 1
l2cap.c.1757: l2cap received remote supported features, sec_level_0_allowed for psm 1 = 1
hci_send_acl_packet_fragments entered
hci.c.627: hci_send_acl_packet_fragments loop entered
hci.c.652: hci_send_acl_packet_fragments loop before send (more fragments 0)
.
.
.
ACL classic buffers: 1 used of 4
.
.
.

LOG -- l2cap.c.2463: L2CAP signaling handler code 5, state 11
LOG -- l2cap.c.1053: l2cap_stop_rtx for local cid 0x40
 LOG -- l2cap.c.2395: l2cap_signaling_handle_configure_response
LOG -- hci.c.448: ACL classic buffers: 0 used of 4
LOG -- l2cap.c.2463: L2CAP signaling handler code 4, state 11
LOG -- l2cap.c.2315: Remote MTU 48
.
.
.
HCI_EVENT_LINK_KEY_REQUEST
.
.
.

2CAP_EVENT_CHANNEL_OPENED status 0x0 addr 00:22:A6:33:AE:D3 handle 0x1 psm 0x1 local_cid 0x40 remote_cid 0x40 local_mtu 1017, remote_mtu 48, flush_timeout 0
.
.
.
(Messages indicating that FRCOMM and L2CAP channels are closed  and DSP ...

Can you please tell me the steps to make this demo run correctly and how to connect it to a specific bluetooth earpiece. Thank you in advance.


Best regards,
Achref,


Matthias Ringwald

unread,
Jul 19, 2018, 8:35:41 AM7/19/18
to btsta...@googlegroups.com
Hi Achref

The hfp_ag_demo doesn't have a way to find a device and then connect to it directly - it's missing from the "UI".
To test, please find the address of your device somehow - eg. using the gap_inquiry example or by pressing 'v' - assuming that you have implemented support for stdin on your target.
Then put the device address into device_addr_string of the demo. Without stdin support, the demo automatically connects to that one. With stdin, please 'a' and on success press 'b'/

if that doesn't work, please enable full packet log in main()..  hci_dump_open( NULL, HCI_DUMP_STDOUT ); and also #define ENABLE_LOG_INFO - which seems to be on alreay - and send a full output. You may run the output through tool/create_packet_log.py to get a .pklg file that can be viewed in WireShark.

Best
 Matthias

--
You received this message because you are subscribed to the Google Groups "btstack-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
To post to this group, send email to btsta...@googlegroups.com.
Visit this group at https://groups.google.com/group/btstack-dev.
For more options, visit https://groups.google.com/d/optout.

Mabrouk Achref

unread,
Jul 20, 2018, 5:02:47 AM7/20/18
to btsta...@googlegroups.com
Hi Matthias,

knowing the address of the device, I put it into  device_addr_string as you told me, but when i run the code nothing happens after having the event of "BTstack up and running" .

image.png

I think I'm missing something that has something to do with the link keys... Are they generated and stored automatically or should I do it manually ? If so, what form a link key has, and in which level should I store it ? and should it be a dynamic storage or a static one ? should I store it in RAM or in FLASH ?) 

Another issue, why doesn't the Menu "show_usage" appear on the UART consol even when I define "HAVE_BTSTACK_STDIN" ? Is there something else to do apart from defining "HAVE_BTSTACK_STDIN" ? 


Thank you in advance.

Best regards,
Achref

Matthias Ringwald

unread,
Jul 20, 2018, 5:11:00 AM7/20/18
to btsta...@googlegroups.com
Hi Achref

If you define  HAVE_BTSTACK_STDIN, the demo will not connect automatically. Instead, you can press e.g. space to get the usage info (show_usage), and there hit 'a' to create the Service Level Connection (SLC). With 'b', you could then open an audio connection.

So, if you have implemented support for stdin (see http://bluekitchen-gmbh.com/cross-platform-console-input/) you can just use the console commands. If not, please undef HAVE_BTSTACK_STDIN and have the demo create the connection automatically. If that succeeds, the demo will also create an audio connection.

Link keys: eventually, they should be stored in Flash via BTstack's TLV mechanism (http://bluekitchen-gmbh.com/storing-link-keys-in-flash-memory/). For test/develop, you can delete the pairing on the mobile phone each time, and/or use btstack_link_key_db_memory.c that allows for re-connects unless you reboot your device.

best
 matthias

On 20 Jul 2018, at 11:02, Mabrouk Achref <achrefm...@gmail.com> wrote:

Hi Matthias,

knowing the address of the device, I put it into 
device_addr_string as you told me, but when i run the code nothing happens after having the event of "BTstack up and running" .

Achref Mabrouk

unread,
Aug 6, 2018, 5:06:36 AM8/6/18
to btstack-dev
Hi Matthias,

First of all thank you very much for your help. I am now able to establish an hfp connection between the CC2564 device and my bluetooth headset using the menu "show_usage" , however, when I try to establish an audio connection, here is the message I get in the usart console (see attached image), and then I end up in the "hard_fault_hundler()". Am I missing some configuration ? Can you please help me by telling me what I should check ?


Thank you in advance.

Best regards,
Achref Mabrouk
Bt_stack_log.PNG

Matthias Ringwald

unread,
Aug 6, 2018, 5:57:54 AM8/6/18
to btsta...@googlegroups.com
Hi Achref

The message in the image is probably caused by MAX_NR_HCI_CONNECTIONS being 1 in btstack_config.h - and we need to for HFP.

I did verify the stm32-f4 port and fixed it there. Please update to the latest version on develop or master and try again.

No idea about the hard-fault - that's tricky to debug, you may simple step from the last log message.

Best 
Matthias

Sent from my iPhone
<Bt_stack_log.PNG>

Achref Mabrouk

unread,
Aug 6, 2018, 10:32:33 AM8/6/18
to btstack-dev
Hi,

Thank you Matthias, that helped me.

Can you please tell me where to find the configuration of the output clock and the WA clock of the CC2564 to communicate, via I2S, with the U-box modem which has its integrated CODEC ? 
From what I understood, the SCO is, by default, rooted via I2S when ENABLE_SCO_OVER_HCI is not enabled, and the bluetooth device is configured as Master by default for an I2S communication, so it should generate the two clocks; CLK and WA. Am I wrong ? 

Thank you in advance,

Best.

Achref Mabrouk 

Matthias Ringwald

unread,
Aug 6, 2018, 4:01:10 PM8/6/18
to btsta...@googlegroups.com
Hi Achref

Which u-box module do you use?

The I2S of CC2564 is configured via vendor specific commands.There's commented code in chipset/cc256x/btstack_chipset_cc256x.c that you can try to activate.
I never tried I2S yet. For HFP, you usually want Wide-Band Speech which either requires to enable SCO over HCI or use TI's special firmware to do SBC inside the CC2564. However, this feature disables BLE so you cannot use HFP WBS with BLE together. Most people want HFP WBS and BLE at the same time.


Best
 Matthias

Mabrouk Achref

unread,
Aug 7, 2018, 4:21:16 AM8/7/18
to btsta...@googlegroups.com
Hi Matthias,

Thank you for your answer.

For the moment I'm using a SARA-U270 but later I'll use a SARA-G340. SARA-U270 requires a sampling frequency of 8KHz and should be the master in the I2S communication, so i'm trying to modify the CC2564 configuration to set the right frequency and switch it to slave mode knowing that it's set master mode by default in bt_stack.

Best.


Achref Mabrouk

unread,
Aug 10, 2018, 4:21:55 AM8/10/18
to btstack-dev
Hi Matthias,

I'm trying to re-configure the CC25654 using the command "HCI_VS_Write_CODEC_Config (0xFD06)", but when I send the command using "hci_can_send_command_packet_now()" then "hci_send_cmd()",  "hci_can_send_command_packet_now()" never returns a "True" so I couldn't send the command. Is there a specific place in the code where i can send hci commands ? should I send it befor turning on the HCI (hci_power_control()) or after ? 

Thank you in advance.

Best,

Achref
 


Matthias Ringwald

unread,
Aug 13, 2018, 7:45:19 AM8/13/18
to btsta...@googlegroups.com
Hi Achref

After the hci_power_control(ON), you should wait for the BTSTACK_EVENT_STATE packet with state HCI_STATE_WORKING. 

packet_handler:....

switch (packet_type) {
        case HCI_EVENT_PACKET:
            switch (hci_event_packet_get_type(packet)) {
                case BTSTACK_EVENT_STATE:
                if (btstack_event_state_get_state(packet) == HCI_STATE_WORKING) {
// set some flag to know that we're running
send_sco_config = 1;
                } 
      }
}

if (send_sco_config && hci_can_send_command_packet_now(){
send_sco_config = 0;
hci_send_cmd(..)
}

Alternatively, you could modify the hci_route_sco_over_hci array in btstack_chipset_cc256x.c file to include your SCO configuration for testing.

Best
 Matthias

Achref Mabrouk

unread,
Aug 14, 2018, 4:58:58 AM8/14/18
to btstack-dev

Hi Matthias,

Thank you very much, that helped me a lot. Now I'm able to communicate the voice between the CC2564 and a headset. The voice is comming/going from/to the modem and communicated to the CC2564 via PCM/I2S.

 However, the voice is noisy, it's much noisier when it comes to go from the headset to the phone (which is in call with the modem) and iIhear what I say (the voice is repeated). In the other way, from the phone (so from the modem) to the CC2564 and then to the headset, it's better but still has some noise.

I tried with and without the "wide_band_speach". I tried different PCM/I2S configurations (16 bits - 8KHz / 16 bits - 16KHz ). Do you have any idea where this problem could come from ?

Thank you in advance;

Best.

Achref



  

Matthias Ringwald

unread,
Aug 15, 2018, 3:50:43 PM8/15/18
to btsta...@googlegroups.com
Hi

Bluetooth does not provide any echo cancelling. I'm not sure which side would need to implement that, probably the HFP HF side.

noise: SCO has a high packet loss rate - in contrast to ACL data packets that are just retransmitted. With wide-band-speech and SBC, the SBD decoder can be used to reconstruct a decent 'fill' packet that is hardly audible. With CVSD, the so-called packet-loss concealment is possible but much harder. 

When you tried wide-band-speech, what did do the SBC decoding? Did you use the special Assisted HFP init script from TI?

Best
 Matthias

Giorgia Falbo

unread,
May 21, 2019, 8:41:52 AM5/21/19
to btstack-dev
Hi Matthias,
I'm trying to run the same demo on a STM32F4 with the cc2564. Could you please help me to understand who to log the packets with hci_dump_open? I don't understand what I should expect from it. I'm using window 10 and atollic for the degug.

thanks in advance,

To unsubscribe from this group and stop receiving emails from it, send an email to btsta...@googlegroups.com.

Matthias Ringwald

unread,
May 21, 2019, 8:46:59 AM5/21/19
to btsta...@googlegroups.com
Hi Giorgia

Please check if ENABLE_SEGGER_RTT is enabled in btstack_config.h
Without that, debug output incl. hci_dump should go over the Console UART. With ENABLE_SEGGER_RTT, it goes over Segger's RTT https://www.segger.com/products/debug-probes/j-link/technology/about-real-time-transfer/). RTT is possible even with free tools like OpenOCD, but I've only used it with J-Link adapter, both on board (J-Link OB, can be flashed to the F4 discovery board and others) or the external one.

Logging SCO over UART at 115200 doesn't work, but works well over RTT

Best
Matthias
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To post to this group, send email to btsta...@googlegroups.com.
> Visit this group at https://groups.google.com/group/btstack-dev.
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/e462be65-80fd-4516-a1c6-9c546971a5b8%40googlegroups.com.

Giorgia Falbo

unread,
May 23, 2019, 8:06:01 AM5/23/19
to btstack-dev
Hi Matthias,
thank you for  your answer. Could you please help me to undestand whether is right to use hci_dump_open( NULL, HCI_DUMP_BLUEZ ); after i've enabled the J-Link OB? I still don't manage to get any result even if I'm running the gap_inquiry.c example and i managed to find the device.

Regards,

Giorgia 

Matthias Ringwald

unread,
May 23, 2019, 8:46:49 AM5/23/19
to btsta...@googlegroups.com
Hi Giorgia

Ok, you have Segger's J-Link OB installed now.

hci_dump_open() enables HCI packet logging and lets you choose between binary format (a bit advanced) or hex dump style (STDOUT)

If you have ENABLE_SEGGER_RTT enabled, all output is sent via RTT. There's an RTT Viewer as part of the Segger J-Link package.
As a quick check, you could also download Segger's Ozone debugger and follow the project wizard to pick your MCU and the compiled .elf file.
It usually detects RTT use automatically, if not, use the context menu on the 'terminal' window to select 'capture rtt'. now, press the run button and it should be fine.

Best
Matthias
> To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
> To post to this group, send email to btsta...@googlegroups.com.
> Visit this group at https://groups.google.com/group/btstack-dev.
> To view this discussion on the web visit https://groups.google.com/d/msgid/btstack-dev/a4115c56-5e28-48bb-8b57-f46c6a93d933%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages