This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to modify custom Advertising packet values

Hello All,

I am working on nrf52810 board

Using sdk 14.2

I am trying to modify some bytes of advertising packet  .

I am referring the previous post as link given below

https://devzone.nordicsemi.com/f/nordic-q-a/8854/fully-custom-advertisement-data

I have modified the advertising init function as per the above link.

But i am getting warning like incompatible type.

how to solve this issue with proper advertising .

What modification is required in the code..?

Please reply if anyone having solution for this issue.

I am attaching the my main.c file please verify and let me know any changes required.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
* Copyright (c) 2015 - 2017, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Waiting for reply..

Regards,

Rohit

Parents
  • Hi Rohit,

    It seems like you are passing a wrong argument to the function sd_ble_gap_adv_start

    modify your code like this and try:

    ble_gap_adv_params_t adv_params;

    // Start advertising
    memset(&adv_params, 0, sizeof(adv_params));

    adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND;
    adv_params.p_peer_addr = NULL;
    adv_params.fp = BLE_GAP_ADV_FP_ANY;
    adv_params.interval = APP_ADV_INTERVAL;
    adv_params.timeout = APP_ADV_TIMEOUT_IN_SECONDS;

    err_code = sd_ble_gap_adv_start(&adv_params, APP_BLE_CONN_CFG_TAG);
    APP_ERROR_CHECK(err_code);

    Regards

    Honey

  • Hi Honey,

    i have solved by modify advertising  init section  with code below

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    uint8_t adata[31];
    int i;
    memset(adata, 0, sizeof(adata));
    adata[0] = 30;
    adata[1] = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME;
    adata[2] = 'F';
    adata[3] = 'I';
    adata[4] = 'N';
    adata[5] = 'D';
    adata[6] = '_';
    adata[7] = '0';
    adata[8] = '0';
    adata[9] =BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    adata[10] = BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA;
    // now fill the 29 bytes with whatever you want
    for(i = 11; i < sizeof(adata); i++)
    adata[i] = 0;
    err_code = sd_ble_gap_adv_data_set(adata, sizeof(adata), NULL, 0);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    like this shown below

    while connecting it is not connecting to app(nrf connect).

    What changes are required to make connectable ...?

    Regards,

    Rohit 

Reply
  • Hi Honey,

    i have solved by modify advertising  init section  with code below

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    uint8_t adata[31];
    int i;
    memset(adata, 0, sizeof(adata));
    adata[0] = 30;
    adata[1] = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME;
    adata[2] = 'F';
    adata[3] = 'I';
    adata[4] = 'N';
    adata[5] = 'D';
    adata[6] = '_';
    adata[7] = '0';
    adata[8] = '0';
    adata[9] =BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    adata[10] = BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA;
    // now fill the 29 bytes with whatever you want
    for(i = 11; i < sizeof(adata); i++)
    adata[i] = 0;
    err_code = sd_ble_gap_adv_data_set(adata, sizeof(adata), NULL, 0);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    like this shown below

    while connecting it is not connecting to app(nrf connect).

    What changes are required to make connectable ...?

    Regards,

    Rohit 

Children
  • Hi Rohit,

    Changes you made seems to be connectable.

    Are you calling this function sd_ble_gap_adv_start in advertising init section.

    Your advertising_start function is empty and disconnect event will stops advertising further.

    case BLE_GAP_EVT_DISCONNECTED:
    NRF_LOG_INFO("Disconnected");
    bsp_board_led_off(CONNECTED_LED);
    m_conn_handle = BLE_CONN_HANDLE_INVALID;
    // err_code = app_button_disable();
    // APP_ERROR_CHECK(err_code);
    advertising_start();
    break;

    Regards

    Honey

  • Hi Honey,

    i have modified code as per your suggestion code is working but it is not connecting with the app as shown below

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
    {
    ret_code_t err_code;
    switch (p_ble_evt->header.evt_id)
    {
    case BLE_GAP_EVT_CONNECTED:
    NRF_LOG_INFO("Connected");
    bsp_board_led_on(CONNECTED_LED);
    bsp_board_led_off(ADVERTISING_LED);
    m_conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
    // err_code = app_button_enable();
    // APP_ERROR_CHECK(err_code);
    // advertising_init();
    break;
    case BLE_GAP_EVT_DISCONNECTED:
    NRF_LOG_INFO("Disconnected");
    bsp_board_led_off(CONNECTED_LED);
    m_conn_handle = BLE_CONN_HANDLE_INVALID;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    what is the issue with my code ...? 

    Please reply...

    Regards,

    Rohit

  • Hi Honey ,

     Thanks for your support and your suggestion.

    Error is in my side.

    I was getting the GATT issue in debugger in app.

    "error 22 (0x16) gatt conn terminate local host"

    (it is Pairing issue between mobile and device. Just we have to do unpair )

    I have solved the issue with referring below link..

    https://devzone.nordicsemi.com/f/nordic-q-a/30804/nrf-connect-for-android-disconnects-with-error-22-gatt-conn-terminate-local-host

    Thanks Again,

    Rohit