Ibeacon abvertisemt not working in changing of connectable mode

working on ble advertisement in DA14531 , using the below application

https://github.com/dialog-semiconductor/BLE_SDK6_examples/tree/main/connectivity/ibeacon

defualt application i have changed the adv interval and major minor settings i can able to run the application and starts the advertisement .

then i wanted to change the advertisement mode to connectable mode. so have changed the code user_app.c  to undirected connectable mode api call. its succesfully compiled but not  seeing any advertisement starts. how to check with logs ? is the below changes are correct ?

void user_app_adv_start(void)
{
ibeacon_adv_payload_t adv_payload;
// struct gapm_start_advertise_cmd *cmd = app_easy_gap_non_connectable_advertise_get_active();
struct gapm_start_advertise_cmd *cmd = app_easy_gap_undirected_advertise_get_active();

/* Setup the iBeacon advertising payload */
adv_payload.flags[0] = FLAG_0;
adv_payload.flags[1] = FLAG_1;
adv_payload.flags[2] = FLAG_2;
adv_payload.length = LENGTH;
adv_payload.type = TYPE;
adv_payload.company_id[0] = COMPANY_ID_0;
adv_payload.company_id[1] = COMPANY_ID_1;
adv_payload.beacon_type[0] = BEACON_TYPE_0;
adv_payload.beacon_type[1] = BEACON_TYPE_1;

/* Convert ASCII UUID to hex format */
uuid2hex((char *)UUID_STR, adv_payload.uuid);

adv_payload.major = MAJOR;
adv_payload.minor = MINOR;
adv_payload.measured_power = MEASURED_POWER;

memcpy(cmd->info.host.adv_data, &adv_payload, sizeof(ibeacon_adv_payload_t));
cmd->info.host.adv_data_len = sizeof(ibeacon_adv_payload_t);

/* Set the advertising interval */
cmd->intv_min = MS_TO_BLESLOTS(ADV_INTERVAL_ms);
cmd->intv_max = MS_TO_BLESLOTS(ADV_INTERVAL_ms);

//append_device_name(9,9,,"200000001");

/* Request advertising is started.. */
app_easy_gap_non_connectable_advertise_start();
//app_easy_gap_undirected_advertise_start();
}

Best regards,

Sowmiya

  • Hi Sowmiya,

    Thank you for posting your question online.
    You are not able to see your device advertising in connectable mode because of the advertising Data.
    If you go on the user_config.h file:

    /*
     ****************************************************************************************
     *
     * Advertising or scan response data for the following cases:
     *
     * - ADV_IND: Connectable undirected advertising event.
     *    - The maximum length of the user defined advertising data shall be 28 bytes.
     *    - The Flags data type are written by the related ROM function, hence the user shall
     *      not include them in the advertising data. The related ROM function adds 3 bytes in
     *      the start of the advertising data that are to be transmitted over the air.
     *    - The maximum length of the user defined response data shall be 31 bytes.
     *
     * - ADV_NONCONN_IND: Non-connectable undirected advertising event.
     *    - The maximum length of the user defined advertising data shall be 31 bytes.
     *    - The Flags data type may be omitted, hence the user can use all the 31 bytes for
     *      data.
     *    - The scan response data shall be empty.
     *
     * - ADV_SCAN_IND: Scannable undirected advertising event.
     *    - The maximum length of the user defined advertising data shall be 31 bytes.
     *    - The Flags data type may be omitted, hence the user can use all the 31 bytes for
     *      data.
     *    - The maximum length of the user defined response data shall be 31 bytes.
     ****************************************************************************************
     */

    The Advertising Data can transmit 31 bytes of information. But the first 3 bytes are used for Flags (as stated in the Bluetooth Specification) in the undirected connectable advertising. In the non-connectable advertising mode, we are able to use all the 31bytes for our own information. 
    This is happening on the ibeacon example you are working on. 
    We have stated that we are working with non-connectable advertising, and we are saving information on all 31 bytes of the Advertising Data.
    If you want to use the Advertising (and Scan Response) Data with undirected connectable advertising, then you should insert your Data on the user_config.h file and when you call the app_easy_gap_undirected_advertise_get_active it will short the data out.
    Please refer on our BLE Advertising Tutorial here: DA145XX Tutorial BLE Advertising — DA145XX Tutorial BLE Advertising (renesas.com)

    Kind Regards,
    OV_Renesas

  • thanks , now i have tried to enable logs to check in uart by adding uart files and headers in  main ,but not even it showing any logs which i have modified after that when i am connecting the device its shows DAP ERROR while reading DP-CTrl register. how to recoer from this state . its urgent i am not even able to check with logs . 

    i have tried the defualt blinky example i am able to see the logs in terminal  , but the changes i have done on iBEACON example is not even advertising in non connectable after adding the uart printf_string statement .

    is there any sample application code to check  with logs on IBEACON Advertisementl. ?wanted to know wthether the application is running or not .

    Awaiting for reply..

    thanks,

    Sowmiya

  • Hi Sowmiya,

    Thank you for the reply.
    I am not really sure what kind of configurations you have done on the ibeacon project.
    First of all you should go on the da1458x_config_basic.h file and define CFG_PRINTF:

    /****************************************************************************************************************/
    /* UART Console Print. If CFG_PRINTF is defined, serial interface logging mechanism will be enabled.            */
    /* If CFG_PRINTF_UART2 is defined, then serial interface logging mechanism is implemented using UART2, else UART1 */
    /* will be used.                                                                                                */
    /****************************************************************************************************************/
    #define CFG_PRINTF
    #ifdef CFG_PRINTF
        #define CFG_PRINTF_UART2
    #endif

    After that you should go on the sdk_driver folder and right click to Add Existing files to Group:


    Then navigate on the following path to find the UART driver files:

    And select uart.c and uart_utils.c files.
    After that you should include the following header file in each file you want to add a print statement:
    #include "arch_console.h"

    I personally added a print statement in the user_app_init, user_app_adv and on the periph_init functions.
    In the periph_init function I print the time of numbers we have woken-up from the Extended Sleep Mode in order to advertise:
    		if(periph_counter ==0)
    		{
    			arch_printf("Booting Sequence \r\n");
    		}
    		else{
    			arch_printf("Wake-up from Extended Sleep \r\n");
    			arch_printf("counter: %02d \r\n", periph_counter);
    		}
    		periph_counter ++;


    If you are working with a Development Kit, you could use the Smart Snippets Toolbox as well.
    The Power Profiler feature can show you the average current consumption of the board and you can see your device advertising.

    Kind Regards,
    OV_Renesas

  • thanks for the quick reply , i am new to this controller.

    i had did the same , please check the attached images.. 

    and in sdk driver added uart files.

    then my main file user_app.c  chnages has below..

    /**
     ****************************************************************************************
     *
     * @file user_app.c
     *
     * @brief iBeacon user application source code.
     *
     * Copyright (c) 2012-2020 Dialog Semiconductor. All rights reserved.
     *
     * This software ("Software") is owned by Dialog Semiconductor.
     *
     * By using this Software you agree that Dialog Semiconductor retains all
     * intellectual property and proprietary rights in and to this Software and any
     * use, reproduction, disclosure or distribution of the Software without express
     * written permission or a license agreement from Dialog Semiconductor is
     * strictly prohibited. This Software is solely for use on or in conjunction
     * with Dialog Semiconductor products.
     *
     * EXCEPT AS OTHERWISE PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, THE
     * SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. EXCEPT AS OTHERWISE
     * PROVIDED IN A LICENSE AGREEMENT BETWEEN THE PARTIES, IN NO EVENT SHALL
     * DIALOG SEMICONDUCTOR BE LIABLE FOR ANY DIRECT, SPECIAL, INDIRECT, INCIDENTAL,
     * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
     * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
     * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
     * OF THE SOFTWARE.
     *
     ****************************************************************************************
     */
    
    /**
     ****************************************************************************************
     * @addtogroup APP
     * @{
     ****************************************************************************************
     */
    
    /*
     * INCLUDE FILES
     ****************************************************************************************
     */
    #include <stdint.h>
    #include "spi_flash.h"
    
    #include "arch_system.h"
    #include "uart.h"
    #include "uart_utils.h"
    #include "user_periph_setup.h"
    #include "arch_console.h"
    
    #include "user_app.h"
    #if defined (__DA14531__)
    #include "rf_531.h"
    #endif
    
    /*
     * DEFINES
     ****************************************************************************************
     */
    /* Select output power */
    #undef  TX_POWER_2d5Bm
    
    /* Advertising payload field sizes */
    #define FLAGS_LEN										3
    #define COMPANY_ID_LEN							        2
    #define BEACON_TYPE_LEN							        2
    #define UUID_LEN										16
    
    /* Fixed advertising fields */
    #define FLAG_0											0x02
    #define FLAG_1											0x01
    #define FLAG_2											0x06
    #define LENGTH											0x1A
    #define TYPE											0xFF
    #define COMPANY_ID_0								    0x4C
    #define COMPANY_ID_1								    0x00
    #define BEACON_TYPE_0								    0x02
    #define BEACON_TYPE_1								    0x15
    
    #define APP_AD_MSD_COMPANY_ID               (0x004C)
    
    #if defined (TX_POWER_2d5Bm)
    #define MEASURED_POWER                                  0xC7
    #if !defined (__DA14531__)
        #error "Config error: Can not define TX_POWER_2d5Bm when device selected is DA14585 or DA14586."
    #endif
    #else    
    /* Output power 0dBm */
    #define MEASURED_POWER							        0xC5
    #endif
    
    /* User defined advertising fields */
    #define UUID_STR										"d4070339-6da4-4e50-a375-bade13be6daa"
    #define MAJOR											0x0100
    #define MINOR											0x0000
    
    /* Set the advertising rate */
    #define ADV_INTERVAL_ms							        100
    
    /*
     * TYPE DEFINITIONS
     ****************************************************************************************
     */
    
    /* Apple Proximity Beacon Specification - Release R1  */
    typedef struct __attribute__ ((__packed__)) {
    	uint8_t  flags[FLAGS_LEN];
    	uint8_t  length;
    	uint8_t  type;
    	uint8_t  company_id[COMPANY_ID_LEN];
    	uint8_t  beacon_type[BEACON_TYPE_LEN];
    	uint8_t  uuid[UUID_LEN];
    	uint16_t major;
    	uint16_t minor;
    	uint8_t  measured_power;
    } ibeacon_adv_payload_t;
    
    /*
     * LOCAL VARIABLE DEFINITIONS
     ****************************************************************************************
     */
    
    /*
     * FUNCTION DEFINITIONS
     ****************************************************************************************
    */ 
    static uint8_t hex2byte(char *hex);
    static void uuid2hex(char *uuid, uint8_t *output);
    
    /**
     ****************************************************************************************
     * @brief System start callback - gets called following a reset (but NOT on wakeup).
     * @return void
     ****************************************************************************************
    */
    void user_app_on_init(void)
    {
        /* If we have booted from flash then it will still be in active mode, power down to 
             reduce current consumption. */
        (void)spi_flash_power_down();	
        
        #if defined (__DA14531__) && defined (TX_POWER_2d5Bm)
                /* Set output power to maximum value (+2.5dBm) */
                rf_pa_pwr_set(RF_TX_PWR_LVL_PLUS_2d5);
        #endif
    
        default_app_on_init();
    	
    	/*system_init();
    	 printf_string(UART, "\n\r\n\r");
        printf_string(UART, "***************\n\r");
        printf_string(UART, "* BLINKY DEMO *\n\r");
        printf_string(UART, "***************\n\r");*/
    	
    }
    
    /**
     ****************************************************************************************
     * @brief Advertising start callback - called by the stack to allow the user to start 
     *        advertising.
     * @return void
     ****************************************************************************************
    */
    void user_app_adv_start(void)
    {
        ibeacon_adv_payload_t adv_payload;
        //struct gapm_start_advertise_cmd *cmd = app_easy_gap_non_connectable_advertise_get_active();	
    	
    	struct gapm_start_advertise_cmd *cmd = app_easy_gap_undirected_advertise_get_active();
    	
    	 arch_printf("Booting Sequence \r\n");
    	
    	 
    
        /* Setup the iBeacon advertising payload */
      //  adv_payload.flags[0]       = FLAG_0;
      //  adv_payload.flags[1]       = FLAG_1;
      //  adv_payload.flags[2]       = FLAG_2;
      //  adv_payload.length         =  LENGTH;           //LENGTH;
      //  adv_payload.type           = TYPE;
        adv_payload.company_id[0]  = APP_AD_MSD_COMPANY_ID & 0xFF; // LSB
        adv_payload.company_id[1]  = (APP_AD_MSD_COMPANY_ID >> 8 )& 0xFF; // MSB
       // adv_payload.beacon_type[0] = BEACON_TYPE_0;
       // adv_payload.beacon_type[1] = BEACON_TYPE_1;
    
        /* Convert ASCII UUID to hex format */
      //  uuid2hex((char *)UUID_STR, adv_payload.uuid);
        
        adv_payload.major = MAJOR;
        adv_payload.minor = MINOR;
        adv_payload.measured_power = MEASURED_POWER;
    
     //   memcpy(cmd->info.host.adv_data, &adv_payload, sizeof(ibeacon_adv_payload_t));
    //    cmd->info.host.adv_data_len = sizeof(ibeacon_adv_payload_t);
    
         memcpy(cmd->info.host.adv_data, &adv_payload,4);
        cmd->info.host.adv_data_len = 4;
    
        /* Set the advertising interval */
        cmd->intv_min = MS_TO_BLESLOTS(ADV_INTERVAL_ms);
        cmd->intv_max = MS_TO_BLESLOTS(ADV_INTERVAL_ms);
    
        /* Request advertising is started.. */
       // app_easy_gap_non_connectable_advertise_start();
    	 app_easy_gap_undirected_advertise_start();
    }
    
    /**
     ****************************************************************************************
     * @brief Converts UUID ASCII string to hex equivalent.
     * @return void
     ****************************************************************************************
    */
    static void uuid2hex(char *uuid, uint8_t *output)
    {
        uint8_t in_ix;
        uint8_t out_ix;
        for (out_ix = 0, in_ix = 0; out_ix < UUID_LEN; out_ix++, in_ix += 2) {
            if (uuid[in_ix] == '-') {
                 in_ix++;
            }
            output[out_ix] = hex2byte(&uuid[in_ix]);
        }	
    }
    
    /**
     ****************************************************************************************
     * @brief Converts ASCII character to hex equivalent.
     * @return void
     ****************************************************************************************
    */
    static uint8_t hex2byte(char *hex)
    {
        uint8_t byte = 0;
        uint8_t digits = 2;
    
        while (digits--) {
            uint8_t c = *hex++;	
            if (c >= '0' && c <= '9') c = c - '0';
            else if (c >= 'a' && c <= 'f') c = c - 'a' + 10;
            else if (c >= 'A' && c <= 'F') c = c - 'A' + 10;
            else c = 0;
            byte = byte << 4;
            byte = byte | (c & 0x0F);
        }
        return byte;
    }
    
    /// @} APP
    

    for the connetable mode advterisement also changed in the same file.

    in user_confg.h file

    #define USER_ADVERTISE_DATA "\x03"\
    ADV_TYPE_COMPLETE_LIST_16BIT_SERVICE_IDS\
    ADV_UUID_DEVICE_INFORMATION_SERVICE

    is anything i had missed ? please check the files attached 

    Thanks 

    Sowmiya

  • Hi Sowmiya,

    Thank you for the reply.
    From what I can see you have not defined the CFG_PRINTF inside the da1458x_config_basic.h file.
    You should also use the function:

    arch_printf("Hello World");

    Please refer on our guide here as well: 10. Debugging via Serial Port — DA145XX Tutorial SDK Getting started (renesas.com)
    Keep also in mind our SDK6 SW Platform Reference : 5. Peripheral Example Applications — DA14585/DA14531 SW Platform Reference Manual (renesas.com)

    Can you share more detail what are you trying to implement?
    Why have you configured the ibeacon example this way? You could just use the ble_app_peripheral example which is inside the SDK for undirected advertising, and you will not need to make so many configurations.
    After the DA14531 finished the booting sequence, then it enters on the user_app_init callback function and after this it goes on the user_app_adv_start callback function. When we call:
    	struct gapm_start_advertise_cmd *cmd = app_easy_gap_undirected_advertise_get_active();

    We sort the Advertising Data accordingly, and after that you overwrite this data with the ibeacon data. 
    The ibeacon example is not the best example to test the undirected connectable advertising. 
    Please check the available examples on the SDK, path: SDK_path\projects\target_apps\ble_examples

    Kind Regards,
    OV_Renesas

  • yes , thanks for the response but now my device is in DAP ERROR state not even detecting to flash the firmware .

    void user_app_on_init(void)
    {
        /* If we have booted from flash then it will still be in active mode, power down to 
             reduce current consumption. */
        (void)spi_flash_power_down();	
        
        #if defined (__DA14531__) && defined (TX_POWER_2d5Bm)
                /* Set output power to maximum value (+2.5dBm) */
                rf_pa_pwr_set(RF_TX_PWR_LVL_PLUS_2d5);
        #endif
    
        default_app_on_init();
    	
    	 system_init();
    	 printf_string(UART, "\n\r\n\r");
        printf_string(UART, "***************\n\r");
        printf_string(UART, "* BLINKY DEMO *\n\r");
        printf_string(UART, "***************\n\r");
    	
    }

    did this changes before flashed this firmware now it is in error state .

    how to recover the device from DAP error while reading  DAP -ctrl register state .?

    thanks ,

    sowmiya

  • Hi Sowmiya,

    Thank you for the reply.
    Why have you inserted the system_init function inside the user_app_on_init callback function?
    This is the reason why your device has crashed.
    The device has finished the booting sequence and the initialization of all the peripherals and then you call the system_init again unexpectedly. 
    Please remove it, use the arch_printf function to print messages, and if you want to test undirected connectable advertising please check the available examples on the SDK.

    Kind Regards,
    OV_Renesas

  • yes , i will check with the examples but now how to recover from the crash state ? is there any way to come out error state then only i can able to do the further changes.

    is it possible to overcome from the DAP error state ?

    thanks ,

    sowmiya

  • Can you share more detail what are you trying to implement?
    Why have you configured the ibeacon example this way? You could just use the ble_app_peripheral example which is inside the SDK for undirected advertising, and you will not need to make so many configurations.

    i wanted to do ibeacon advertisement with connectable mode . with out connectable mode i did the ibeacon advertisemt .

    The Advertising Data can transmit 31 bytes of information. But the first 3 bytes are used for Flags (as stated in the Bluetooth Specification) in the undirected connectable advertising. In the non-connectable advertising mode, we are able to use all the 31bytes for our own information. 
    This is happening on the ibeacon example you are working on. 
    We have stated that we are working with non-connectable advertising, and we are saving information on all 31 bytes of the Advertising Data.

    is it possible to get all 31 bytes with connectable mode ?  i have tried in ble_app_peripheral with connectable mode able write data with exiiting service also can we chnage the defualt service to custom service ? is it possible to change the advertisemt of ibeacon format with the manufacture data ?how many bytes can advertise ?

    Thanks ,

    Sowmiya

  • Hi Sowmiya,

    Thank you for the reply.
    Ibeacons are by default advertising in non-connectable mode. Since you want to use Ibeacon with connectable mode you should enter the ibeacon data into the advertising data and keep in mind to occupy 29 bytes at max. 
    Unfortunately, it is not possible to get all 31 bytes with connectable mode. The first 3 bytes used for Flags are necessary and specified in the Bluetooth SIG Specification.
    Can you clarify what you mean by the following:

    i have tried in ble_app_peripheral with connectable mode able write data with exiiting service also can we chnage the defualt service to custom service ?

    The ibeacon format is a fixed format which you can not modify. You could create your own custom advertising format and insert the Manufacturer data there.
    Please check also our Eddystone Beacon example available on our GitRepo: BLE_SDK6_examples/interfaces/wakeup_hibernation_ext_timer at main · dialog-semiconductor/BLE_SDK6_examples · GitHub
    The Eddystone Beacon supports an open format, so you could insert custom data (for instance, manufacturer data). In this example you can see how they have configured ADC values and the Battery Service values showing up on the advertising data.

    Kind Regards,
    OV_Renesas