⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at https://www.dialog-semiconductor.com/support . We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
adam.stroz
Offline
Last seen: 3 weeks 6 days ago
Joined: 2020-05-22 07:54
Directed advertise

Hello,

I'm trying to run direct advertising on the Da14531 chip but I can't see it working, below is the code which I added  (based on empty_periphertial_template):

static const struct default_app_operations user_default_app_operations = {
    .default_operation_adv = user_advertise_operation,
};
void user_advertise_operation(void){

app_easy_gap_directed_advertise_start(0);//0 and 1 have the same result

}

I tryed to re-start advertise by add this part of code to app_direct_advertise_complete fun.

... Part of user_app_callbacks 
   .app_on_adv_direct_complete         = app_direct_advertise_complete,
...

void app_direct_advertise_complete(const uint8_t x){
     app_easy_gap_directed_advertise_start(0);
}

I check adv packet with BLE sniffer application, and i also tryed to discover my device by using central implementation app with andother DA14531. 
If i insert a breakpoint in app_direct_advertise_complete the x varriable has a value of 0x45 (which indicates a timeout error). 
I have two questions:
If I have to see the package on the phone (in the BLE sniffer application), if I have entered an bad central address in the .peer_addr filed in the user_adv_conf structure?

How to check if advertise is working ( I only have a Development Kit-USB board)?

Device: 
PM_Dialog
Offline
Last seen: 5 months 2 weeks ago
Staff
Joined: 2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

Thanks for your question. Before answering your questions, I’d like to highlight first that the direct advertisement is for establishing very quick connections. According to the Bluetooth LE specs, you can advertise directed, if you are aware of the Central BD Address.

Please note that if you are using a mobile phone as a Central device, the mobile phones are usually using random BD addresses, which means that the BD address will be changing continually and so, you won’t be able to know it. Directed advertisement can be done only in the case that the Central is using a public BD address and is not changing every time.

The Central’s BD address should be added in the .peer_addr_type of the user_adv_config structure in the user_config.h header file. Then, the app_easy_gap_directed_advertise_start() API should be used in user_app_adv_start() with a proper BD address to field mentioned above. In the direct advertisement, the PDU includes only the BD address of the device.

See below a quick example demonstrating the directed advertisement with a high duty cycle. Please follow this in  ble_app_peripheral example of the SDK6.0.14.

SDK location : 6.0.14.1114\projects\target_apps\ble_examples\ble_app_peripheral\Keil_5

1. Use the following user_app_adv_start().  Remove the app_adv_data_update_timer_used from the user_peripheral.c file and comment out the app_add_ad_struct().

void user_app_adv_start(void)
{
  struct gapm_start_advertise_cmd* cmd;
  cmd = app_easy_gap_directed_advertise_get_active(0);
  app_easy_gap_directed_advertise_start(0);
}

 

2, If you run it, an NMI will occur. To avoid the NMI you have two choices:

A] Put the device into sleep mode when the directed adverting is timed out. To do so, you should add arch_set_extended_sleep(false) after app_easy_gap_directed_advertise_start(0). If it is still acting in active mode, it will wait for an interrupt, the WDOG will time out and an NMI will occur.

B] Use the . app_on_adv_direct_complete =  user_app_adv_direct_complete in order to restart adverting. ( same as undirected advertising)

void user_app_adv_direct_complete(uint8_t status)
{
  if (status == GAP_ERR_TIMEOUT)
  {
    user_app_adv_start();
  }
}

 

3. When the directed advertising times out, the status will be GAP_ERR_TIMEOUT (= 0x45).

Of course, you should add the proper BD address in user_adv_config struct

There are 2 modes available for directed advertising: High duty cycle and low duty cycle

    I] High duty cycle: The advertising will last for ~1.28sec (adv interval is 1.25ms). If no central connects to the peripheral, a timeout will occur.

    II} Low duty cycle: The peripheral will advertise forever using the adv interval defined in user_config.h.

In both cases, the BLE sniffer can be used to capture the ADV_DIRECT_IND advertising packets.

Thanks, PM_Dialog

adam.stroz
Offline
Last seen: 3 weeks 6 days ago
Joined: 2020-05-22 07:54
Hello,

Hello,

I tested what you wrote to me:

On DA14531 MODULE i start BLE central app, below config (i use PUBLIC BD Addres only for test purposes):

#define	SCAN_FILTER												(SCAN_FILTER_NONE)

#define CONNECT_TO_PERIPHERAL							(0)

#define CFG_NVDS_TAG_BD_ADDRESS             {0x01, 0x00, 0x70, 0xCA, 0xEA, 0x80}
#define USER_CFG_ADDRESS_MODE       APP_CFG_ADDR_PUB

On DA14531 (USB dev kit) i started ble_app_peripheral (with the settings you wrote to me):

#define CFG_NVDS_TAG_BD_ADDRESS             {0x03, 0x00, 0x70, 0xCA, 0xEA, 0x80}
#define USER_CFG_ADDRESS_MODE       APP_CFG_ADDR_PUB

void user_app_adv_start(void)
{
  struct gapm_start_advertise_cmd* cmd;
  cmd = app_easy_gap_directed_advertise_get_active(0);
  app_easy_gap_directed_advertise_start(0);
}
void user_app_adv_direct_complete(uint8_t status)
{
  if (status == GAP_ERR_TIMEOUT)
  {
    user_app_adv_start();
  }
}

But unfortunately I can't see anything in the terminall (i see only other devices), in BLE sniffer I also don't see any packets from DA14531 (USB dev kit) .

PM_Dialog
Offline
Last seen: 5 months 2 weeks ago
Staff
Joined: 2018-02-08 11:03
Hi adam.stroz,

Hi adam.stroz,

Thanks for coming and posting to the forums. Exciting news! We’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the NEW forum only - please POST any new threads at  https://www.dialog-semiconductor.com/support

We’ll be fixing bugs / optimizing the searching and tagging over the coming days.

This ticket has been ported on : https://www.dialog-semiconductor.com/products/bluetooth-low-energy?post_id=11459#tab-support_tab_content

I’ll respond to you as soon as possible on the NEW forum thread.

Thanks, PM_Dialog