da14531mod advertisement

Hi Renesas Team,
I am trying to send my beaconing information on every 1hour one sample I am advertising. 
Running the timer internally using MCU core, and when time reaches 1 hour then I will enable the RF core beacon activity, advertise the beacon data and disable the RF core and do the process forever without rebooting the device. please suggest the logic.
I am trying this logic in DA14531MOD hostless.
Thanks,
Kumar
Parents
  • Hi Kumar,

    Thank you for posting your question online.

    I am trying to send my beaconing information on every 1hour one sample I am advertising. 
    Running the timer internally using MCU core, and when time reaches 1 hour then I will enable the RF core beacon activity, advertise the beacon data and disable the RF core and do the process forever without rebooting the device. please suggest the logic.
    I am trying this logic in DA14531MOD hostless.

    Yes, this is possible with the DA14531MOD.
    You can have the following scenario:
    You follow the ibeacon example and the ble_app_sleepmode example (inside the SDK6).
    Note: We also have on Git examples for Eddystone beacon.
    You can start a timer (i.e. for 5seconds), start advertising, after 5 seconds the timer will expire and we stop advertising.
    When we stop advertising you can implement either Extended Sleep without advertising or Deep Sleep.
    In both cases you can have RTC configured in order to set an interrupt after 1 hour. After 1 hour repeat.
    Please refer on our SDK6 examples and the Tutorials on the DA14531 product page for more information.

    Best Regards,
    OV_Renesas

  • Hi Renesas,
    Thanks for your response.
    I did the same and implemented the ibeacon logic and testing for every 30 secs for testing wise.
    Attached the code is working and sending for every 30 secs and after 15 minutes the device is getting rebooted.
    My logic is here initially the device is in connectable mode --> once i configure all the GATT services to disconnect it goes in
    non-connectable mode and starts running the timer and then it broadcasts the ibeacon advertisements based on timer
    30sec given as an example.
    But after some 15 minutes the device is getting rebooted. Is there any issue or modifications required under ble stack.
    I have attached the code for your reference.
    Regards,
    Kumar
    /********************************************************************************************/
    void user_app_adv_start(void)
    {
    	if(bFlag_ble_beacon == false)
    	{	
    		app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb);
    
    		struct gapm_start_advertise_cmd* cmd;
    		cmd = app_easy_gap_undirected_advertise_get_active();
    		app_add_ad_struct(cmd, &mnf_data, sizeof(struct mnf_specific_data_ad_structure), 1);
    		app_easy_gap_undirected_advertise_start();
    	}			
    	if(bFlag_ble_beacon == true)
    	{
    		ibeacon_adv_payload_t adv_payload;
    		struct gapm_start_advertise_cmd *cmd;
    		cmd	= app_easy_gap_non_connectable_advertise_get_active();	
    
    		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;
    
    		uuid2hex((char *)UUID_STR, uuidWr);
    		for(uint8_t i=0;i<16;i++)
    		{
    			adv_payload.uuid[i] = uuidWr[i];
    		}
    			
    		adv_payload.major[0]= MAJOR & 0x0FF; //high byte
    		adv_payload.major[1]= MAJOR >> 8; //high byte
    
    		adv_payload.minor[1]= MINOR & 0x0FF; //high byte
    		adv_payload.minor[0]= MINOR >> 8; //high byte
    	
    		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);
    
    		cmd->intv_min = MS_TO_BLESLOTS(bTransmission_Interval);
    		cmd->intv_max = MS_TO_BLESLOTS(bTransmission_Interval);
    		append_device_name(&cmd->info.host.scan_rsp_data_len,
    												 name_len,
    												 &(cmd->info.host.scan_rsp_data[cmd->info.host.scan_rsp_data_len]),
    													hex_val_t);
    
    		memcpy(cmd->info.host.adv_data, &adv_payload, sizeof(ibeacon_adv_payload_t));
    		cmd->info.host.adv_data_len = sizeof(ibeacon_adv_payload_t);
    		app_easy_gap_non_connectable_advertise_start();
    		arch_set_sleep_mode(ARCH_EXT_SLEEP_ON);
    	}
    	else
    	{
    		
    	}	
    }		
    /********************************************************************************************/
    void user_app_adv_start_update_Fields(void)
    {
        ibeacon_adv_payload_t adv_payload;
        struct gapm_start_advertise_cmd *cmd = app_easy_gap_non_connectable_advertise_get_active();	
    
        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;
    
    	uuid2hex((char *)UUID_STR, uuidWr);
    	for(uint8_t i=0;i<16;i++)
    	{
    			adv_payload.uuid[i] = uuidWr[i];
    	}		
    	adv_payload.major[0]= MAJOR_Value & 0x0FF; //high byte
    	adv_payload.major[1]= MAJOR_Value >> 8; //high byte
    
    	adv_payload.minor[0]= MINOR_Value & 0x0FF; //high byte
    	adv_payload.minor[1]= MINOR_Value >> 8; //high byte
    	
    	/* Set the advertising interval */
    	cmd->intv_min = MS_TO_BLESLOTS(2000);
    	cmd->intv_max = MS_TO_BLESLOTS(2000);
    	
    	adv_payload.measured_power = RSSI_1mVal_measurePwr;
    	append_device_name(&cmd->info.host.scan_rsp_data_len,
    													 name_len,
    													 &(cmd->info.host.scan_rsp_data[cmd->info.host.scan_rsp_data_len]),
    														hex_val_t);
    
    	memcpy(cmd->info.host.adv_data, &adv_payload, sizeof(ibeacon_adv_payload_t));
    	cmd->info.host.adv_data_len = sizeof(ibeacon_adv_payload_t);
    
    	app_easy_gap_update_adv_data(cmd->info.host.adv_data, sizeof(ibeacon_adv_payload_t), cmd->info.host.scan_rsp_data, sizeof(cmd->info.host.scan_rsp_data));
    }
    /********************************************************************************************/
    void app_resume_system_from_sleep(void)
    {
    	#if !defined (__DA14531__)
        if (GetBits16(SYS_STAT_REG, PER_IS_DOWN))
    	#endif
        {
            periph_init();
        }
    
        if (arch_ble_ext_wakeup_get())
        {
            arch_set_sleep_mode(app_default_sleep_mode);
            arch_ble_force_wakeup();
            arch_ble_ext_wakeup_off();
            app_easy_wakeup();
        }
    }
    /********************************************************************************************/
    static void beacon_adv_data_update_timer_cb()
    {
    	app_easy_gap_advertise_stop();
    	battery_percentage = battery_get_lvl(BATT_CR2032);
    	app_resume_system_from_sleep();
    	user_app_adv_start_update_Fields();
    	user_app_adv_start();
    	app_adv_data_update_timer_used = app_easy_timer(((APP_ADV_DATA_UPDATE_TO_BEACON/30)*(30)), beacon_adv_data_update_timer_cb); //30Sec
    }
    /********************************************************************************************/
    
    void user_app_disconnect(struct gapc_disconnect_ind const *param)
    {
    	app_adv_data_update_timer_used = app_easy_timer(((APP_ADV_DATA_UPDATE_TO_BEACON/30)*(30)), beacon_adv_data_update_timer_cb); //30Sec
    }
    /********************************************************************************************/
    void user_app_adv_undirect_complete(uint8_t status)
    {
        if (status == GAP_ERR_CANCELED)
        {
          user_app_adv_start();
        }
    }	
    /********************************************************************************************/
    void user_app_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param)
    {	
    	if(bFlag_ble_beacon == false)
    	{
    		user_battery_message_handler(1);
    		if (app_env[connection_idx].conidx != GAP_INVALID_CONIDX)
    		{
    			app_connection_idx = connection_idx;
    			app_easy_timer_cancel(app_adv_data_update_timer_used);
    			if ((param->con_interval < user_connection_param_conf.intv_min) ||
    				(param->con_interval > user_connection_param_conf.intv_max) ||
    				(param->con_latency != user_connection_param_conf.latency) ||
    				(param->sup_to != user_connection_param_conf.time_out))
    			{
    				app_param_update_request_timer_used = app_easy_timer(APP_PARAM_UPDATE_REQUEST_TO, param_update_request_timer_cb);
    			}
    		}
    		else
    		{
    			user_app_adv_start();
    		}
    		default_app_on_connection(connection_idx, param);
    	}
    }	
    /****************************************************************************************/
    void user_app_disconnect(struct gapc_disconnect_ind const *param)
    {
    	user_battery_message_handler(0);
    	if (app_param_update_request_timer_used != EASY_TIMER_INVALID_TIMER)
    	{
    		app_easy_timer_cancel(app_param_update_request_timer_used);
    		app_param_update_request_timer_used = EASY_TIMER_INVALID_TIMER;
    	}
    	mnf_data_update();
    	bFlag_ble_beacon = false;
    	First_user_app_disconnect_Flag = false;
    	user_app_adv_start();
    	if(bFlag_ble_beacon == false)
    	{
    		user_battery_message_handler(0);
    		if (app_param_update_request_timer_used != EASY_TIMER_INVALID_TIMER)
    		{
    				app_easy_timer_cancel(app_param_update_request_timer_used);
    				app_param_update_request_timer_used = EASY_TIMER_INVALID_TIMER;
    		}
    		mnf_data_update();
    		app_adv_data_update_timer_used = app_easy_timer(((APP_ADV_DATA_UPDATE_TO_BEACON/30)*(30)), ibeacon_adv_data_update_timer_cb);
    		user_app_adv_start();
    		bFlag_ble_beacon = true;
    		bMode = RUNNING_MODE;
    		First_user_app_disconnect_Flag = true;
    		app_easy_gap_advertise_stop();
    	}
    #if (BLE_SUOTA_RECEIVER)
    	// Issue a platform reset when it is requested by the suotar procedure
    	if (suota_state.reboot_requested)
    	{
    			// Reboot request will be served
    			suota_state.reboot_requested = 0;
    
    			// Platform reset
    			platform_reset(RESET_AFTER_SUOTA_UPDATE);
    	}
    #endif
    }	
    /****************************************************************************************/
    void user_app_init(void)
    {
    	(void)spi_flash_power_down();	
    	rf_pa_pwr_set(RF_TX_PWR_LVL_0d0);
    	RSSI_1mVal_measurePwr = 0xC5;
    	fnLED_Toggle_Function(6);
    	uuid2hex((char *)UUID_STR, uuidWr);
      	app_param_update_request_timer_used = EASY_TIMER_INVALID_TIMER;
    
        mnf_data_init();
    
        memcpy(stored_adv_data, USER_ADVERTISE_DATA, USER_ADVERTISE_DATA_LEN);
        stored_adv_data_len = USER_ADVERTISE_DATA_LEN;
        memcpy(stored_scan_rsp_data, USER_ADVERTISE_SCAN_RESPONSE_DATA, USER_ADVERTISE_SCAN_RESPONSE_DATA_LEN);
        stored_scan_rsp_data_len = USER_ADVERTISE_SCAN_RESPONSE_DATA_LEN;
    	default_app_on_init();
    }
    /****************************************************************************************/
    
       
    /**
     ****************************************************************************************
     *
     * @file user_callback_config.h
     *
     * @brief Callback functions configuration file.
     *
     * Copyright (C) 2015-2019 Dialog Semiconductor.
     * This computer program includes Confidential, Proprietary Information
     * of Dialog Semiconductor. All Rights Reserved.
     *
     ****************************************************************************************
     */
    
    #ifndef _USER_CALLBACK_CONFIG_H_
    #define _USER_CALLBACK_CONFIG_H_
    
    /*
     * INCLUDE FILES
     ****************************************************************************************
     */
    
    #include <stdio.h>
    #include "app_callback.h"
    #include "app_default_handlers.h"
    #include "app_entry_point.h"
    #include "app_prf_types.h"
    #if (BLE_APP_SEC)
    #include "app_bond_db.h"
    #endif // (BLE_APP_SEC)
    #include "user_peripheral.h"
    
    /*
     * LOCAL VARIABLE DEFINITIONS
     ****************************************************************************************
     */
    static const struct app_suotar_cb user_app_suotar_cb = {
        .on_suotar_status_change = on_suotar_status_change,
    };
    
    static const struct app_callbacks user_app_callbacks = {
        .app_on_connection                  = user_app_connection,
        .app_on_disconnect                  = user_app_disconnect,
        .app_on_update_params_rejected      = NULL,
        .app_on_update_params_complete      = NULL,
        .app_on_set_dev_config_complete     = default_app_on_set_dev_config_complete,
        .app_on_adv_nonconn_complete        = user_app_adv_undirect_complete,//NULL,
        .app_on_adv_undirect_complete       = user_app_adv_undirect_complete,
        .app_on_adv_direct_complete         = NULL,
        .app_on_db_init_complete            = default_app_on_db_init_complete,
        .app_on_scanning_completed          = NULL,
        .app_on_adv_report_ind              = NULL,
        .app_on_get_dev_name                = default_app_on_get_dev_name,
        .app_on_get_dev_appearance          = default_app_on_get_dev_appearance,
        .app_on_get_dev_slv_pref_params     = default_app_on_get_dev_slv_pref_params,
        .app_on_set_dev_info                = default_app_on_set_dev_info,
        .app_on_data_length_change          = NULL,
        .app_on_update_params_request       = default_app_update_params_request,
        .app_on_generate_static_random_addr = default_app_generate_static_random_addr,
        .app_on_svc_changed_cfg_ind         = NULL,
        .app_on_get_peer_features           = NULL,
    #if (BLE_APP_SEC)
        .app_on_pairing_request             = default_app_on_pairing_request,
        .app_on_tk_exch                     = user_app_on_tk_exch,
        .app_on_irk_exch                    = NULL,
        .app_on_csrk_exch                   = default_app_on_csrk_exch,
        .app_on_ltk_exch                    = default_app_on_ltk_exch,
        .app_on_pairing_succeeded           = default_app_on_pairing_succeeded,
        .app_on_encrypt_ind                 = NULL,
        .app_on_encrypt_req_ind             = default_app_on_encrypt_req_ind,
        .app_on_security_req_ind            = NULL,
        .app_on_addr_solved_ind             = default_app_on_addr_solved_ind,
        .app_on_addr_resolve_failed         = default_app_on_addr_resolve_failed,
        .app_on_ral_cmp_evt                 = default_app_on_ral_cmp_evt,
        .app_on_ral_size_ind                = NULL,
        .app_on_ral_addr_ind                = NULL,
    #endif // (BLE_APP_SEC)
    };
    
    #if (BLE_APP_SEC)
    static const struct app_bond_db_callbacks user_app_bond_db_callbacks = {
        .app_bdb_init                       = default_app_bdb_init,
        .app_bdb_get_size                   = default_app_bdb_get_size,
        .app_bdb_add_entry                  = default_app_bdb_add_entry,
        .app_bdb_remove_entry               = NULL,
        .app_bdb_search_entry               = default_app_bdb_search_entry,
        .app_bdb_get_number_of_stored_irks  = default_app_bdb_get_number_of_stored_irks,
        .app_bdb_get_stored_irks            = default_app_bdb_get_stored_irks,
        .app_bdb_get_device_info_from_slot  = default_app_bdb_get_device_info_from_slot,
    };
    #endif // (BLE_APP_SEC)
    
    
    /*
     * "app_process_catch_rest_cb" symbol handling:
     * - Use #define if "user_catch_rest_hndl" is defined by the user
     * - Use const declaration if "user_catch_rest_hndl" is NULL
     */
    #define app_process_catch_rest_cb       user_catch_rest_hndl
    // static const catch_rest_event_func_t app_process_catch_rest_cb = NULL;
    
    static const struct arch_main_loop_callbacks user_app_main_loop_callbacks = {
        .app_on_init            = user_app_init,
    
        // By default the watchdog timer is reloaded and resumed when the system wakes up.
        // The user has to take into account the watchdog timer handling (keep it running,
        // freeze it, reload it, resume it, etc), when the app_on_ble_powered() is being
        // called and may potentially affect the main loop.
        .app_on_ble_powered     = NULL,
    
        // By default the watchdog timer is reloaded and resumed when the system wakes up.
        // The user has to take into account the watchdog timer handling (keep it running,
        // freeze it, reload it, resume it, etc), when the app_on_system_powered() is being
        // called and may potentially affect the main loop.
        .app_on_system_powered  = NULL,
    
        .app_before_sleep       = NULL,
        .app_validate_sleep     = NULL,
        .app_going_to_sleep     = NULL,
        .app_resume_from_sleep  = NULL,
    };
    
    // Default Handler Operations
    static const struct default_app_operations user_default_app_operations = {
        .default_operation_adv = user_app_adv_start,
    };
    
    // Place in this structure the app_<profile>_db_create and app_<profile>_enable functions
    // for SIG profiles that do not have this function already implemented in the SDK
    // or if you want to override the functionality. Check the prf_func array in the SDK
    // for your reference of which profiles are supported.
    static const struct prf_func_callbacks user_prf_funcs[] =
    {
        {TASK_ID_INVALID,    NULL, NULL}   // DO NOT MOVE. Must always be last
    };
    
    #endif // _USER_CALLBACK_CONFIG_H_
    
  • Hi Kumar,

    Thank you for the reply.

    Attached the code is working and sending for every 30 secs and after 15 minutes the device is getting rebooted.

    This sounds to me like the WatchDog expired and you got HW reset. 
    Have you attached a debugger to see where exactly the project crashes? 
    If it the project is stuck in:

    void platform_reset_func(uint32_t error)
    {
        uint16_t tmp;
    
    #if (!PRODUCTION_TEST)
        // Trigger assert if the reset reason is other than RESET_AFTER_SUOTA_UPDATE
        ASSERT_WARNING(error == RESET_AFTER_SUOTA_UPDATE);
    #endif
        // Trigger SW reset
        tmp = GetWord16(SYS_CTRL_REG);
        tmp = (tmp & ~REMAP_ADR0) | 0; // Map ROM at address 0
        tmp |= SW_RESET;
        SetWord16(SYS_CTRL_REG, tmp);
    }

    That means that you have a Heap Exhaustion issue.
    You can try to increase the Heap size from the da1458x_config_advanced.h file:
    /****************************************************************************************************************/
    /* Custom heap sizes                                                                                            */
    /****************************************************************************************************************/
    // #define DB_HEAP_SZ              1024
    // #define ENV_HEAP_SZ             4928
    // #define MSG_HEAP_SZ             6880
    // #define NON_RET_HEAP_SZ         2048
    


    Based on the source code you shared:
    1) You have 2 user_app_disconnect functions
    2) On user_app_disconnect you start advertising and immediately after you call the Stop advertising API, but on the custom callback user_app_adv_undirect_complete you restart advertising. I do not understand the concept there. 
    3) Have you implemented Deep Sleep or Extended Sleep without Advertising?

    Best Regards,
    OV_Renesas

  • Hi Renesas,

    Thanks for your response. Based on your suggestion i modified the below fields:
    I already called the EXTENDED sleep in "da1458x_config_advanced".
    static const sleep_state_t app_default_sleep_mode = ARCH_EXT_SLEEP_ON;
    I increased the Heap size to #define DB_HEAP_SZ  4096 from the da1458x_config_advanced.h file:
     
    Sorry i just called twice in your shared file, but in my actual file one time called "user_app_disconnect"
     
    user_app_adv_undirect_complete called in call backup, then only my ibeacon transmitting every 30 secs without missing. In general, it will show BLE basic manufacturer data. But every 30secs iBeacon data will be advertising.
     
    Any watchdog related modifications required? please suggest.
     
    Thanks,
    Kumar
    /**
     ****************************************************************************************
     *
     * @file da1458x_config_advanced.h
     *
     * @brief Advanced compile configuration file.
     *
     * Copyright (C) 2014-2020 Dialog Semiconductor.
     * This computer program includes Confidential, Proprietary Information
     * of Dialog Semiconductor. All Rights Reserved.
     *
     ****************************************************************************************
     */
    
    #ifndef _DA1458X_CONFIG_ADVANCED_H_
    #define _DA1458X_CONFIG_ADVANCED_H_
    
    #include "da1458x_stack_config.h"
    
    #if !defined (__DA14531__)
    
    /****************************************************************************************************************/
    /* Low Power clock selection.                                                                                   */
    /*      -LP_CLK_XTAL32      External XTAL32K oscillator                                                         */
    /*      -LP_CLK_RCX20       Internal RCX clock                                                                  */
    /*      -LP_CLK_FROM_OTP    Use the selection in the corresponding field of OTP Header                          */
    /****************************************************************************************************************/
    #define CFG_LP_CLK              LP_CLK_XTAL32
    
    /****************************************************************************************************************/
    /* If defined the application uses a hardcoded value for XTAL16M trimming. Should be disabled for devices       */
    /* where XTAL16M is calibrated and trim value is stored in OTP.                                                 */
    /* Important note. The hardcoded value is the average value of the trimming values giving the optimal results   */
    /* for DA14585 DK devices. May not be applicable in other designs                                               */
    /****************************************************************************************************************/
    #define CFG_USE_DEFAULT_XTAL16M_TRIM_VALUE_IF_NOT_CALIBRATED
    
    /****************************************************************************************************************/
    /* Periodic wakeup period to poll GTL iface. Time in msec.                                                      */
    /****************************************************************************************************************/
    #define CFG_MAX_SLEEP_DURATION_PERIODIC_WAKEUP_MS                  500  // 0.5s
    
    /****************************************************************************************************************/
    /* Periodic wakeup period if GTL iface is not enabled. Time in msec.                                            */
    /****************************************************************************************************************/
    #define CFG_MAX_SLEEP_DURATION_EXTERNAL_WAKEUP_MS              600000  // 600s
    
    /****************************************************************************************************************/
    /* Wakeup from external processor running host application.                                                     */
    /****************************************************************************************************************/
    #undef CFG_EXTERNAL_WAKEUP
    
    /****************************************************************************************************************/
    /* Wakeup external processor when a message is sent to GTL                                                      */
    /****************************************************************************************************************/
    #undef CFG_WAKEUP_EXT_PROCESSOR
    
    /****************************************************************************************************************/
    /* Enables True Random Number Generator. A true random number, generated at system initialization, is used to   */
    /* seed any random number generator (C standard library, ChaCha20, etc.). The following supported options       */
    /* provide a trade-off between code size and start-up latency.                                                  */
    /* - undefined (or 0): TRNG is disabled.                                                                        */
    /* -   32:  Enables TRNG with   32 Bytes Buffer.                                                                */
    /* -   64:  Enables TRNG with   64 Bytes Buffer.                                                                */
    /* -  128:  Enables TRNG with  128 Bytes Buffer.                                                                */
    /* -  256:  Enables TRNG with  256 Bytes Buffer.                                                                */
    /* -  512:  Enables TRNG with  512 Bytes Buffer.                                                                */
    /* - 1024:  Enables TRNG with 1024 Bytes Buffer.                                                                */
    /****************************************************************************************************************/
    #define CFG_TRNG (1024)
    
    /****************************************************************************************************************/
    /* Creation of private and public keys using Elliptic Curve Diffie Hellman algorithms.                          */
    /* - defined:   Creation of ECDH keys and secure connection feature is enabled.                                 */
    /* - undefined: Creation of ECDH keys and secure connection feature is disabled. If application does not        */
    /*              support secure connections, it is reccomended to undefine CFG_ENABLE_SMP_SECURE in order to     */
    /*              enable faster start-up time and reduce code size.                                               */
    /****************************************************************************************************************/
    #undef CFG_ENABLE_SMP_SECURE
    
    /****************************************************************************************************************/
    /* Uses ChaCha20 random number generator instead of the C standard library random number generator.             */
    /****************************************************************************************************************/
    #undef CFG_USE_CHACHA20_RAND
    
    /****************************************************************************************************************/
    /* Custom heap sizes                                                                                            */
    /****************************************************************************************************************/
    // #define DB_HEAP_SZ              1024
    // #define ENV_HEAP_SZ             4928
    // #define MSG_HEAP_SZ             6880
    // #define NON_RET_HEAP_SZ         2048
    
    /****************************************************************************************************************/
    /* NVDS configuration                                                                                           */
    /* - CFG_NVDS_TAG_BD_ADDRESS            Default bdaddress. If bdaddress is written in OTP header this value is  */
    /*                                      ignored                                                                 */
    /* - CFG_NVDS_TAG_LPCLK_DRIFT           Low power clock drift. Permitted values in ppm are:                     */
    /*      + DRIFT_20PPM                                                                                           */
    /*      + DRIFT_30PPM                                                                                           */
    /*      + DRIFT_50PPM                                                                                           */
    /*      + DRIFT_75PPM                                                                                           */
    /*      + DRIFT_100PPM                                                                                          */
    /*      + DRIFT_150PPM                                                                                          */
    /*      + DRIFT_250PPM                                                                                          */
    /*      + DRIFT_500PPM                  Default value (500 ppm)                                                 */
    /* - CFG_NVDS_TAG_BLE_CA_TIMER_DUR      Channel Assessment Timer duration (Multiple of 10ms)                    */
    /* - CFG_NVDS_TAG_BLE_CRA_TIMER_DUR     Channel Reassessment Timer duration (Multiple of CA timer duration)     */
    /* - CFG_NVDS_TAG_BLE_CA_MIN_RSSI       Minimum RSSI Threshold                                                  */
    /* - CFG_NVDS_TAG_BLE_CA_NB_PKT         Number of packets to receive for statistics                             */
    /* - CFG_NVDS_TAG_BLE_CA_NB_BAD_PKT     Number  of bad packets needed to remove a channel                       */
    /****************************************************************************************************************/
    #define CFG_NVDS_TAG_BD_ADDRESS             {0x03, 0x00, 0x70, 0xCA, 0xEA, 0x80}
    
    #define CFG_NVDS_TAG_LPCLK_DRIFT            DRIFT_500PPM
    #define CFG_NVDS_TAG_BLE_CA_TIMER_DUR       2000
    #define CFG_NVDS_TAG_BLE_CRA_TIMER_DUR      6
    #define CFG_NVDS_TAG_BLE_CA_MIN_RSSI        0x40
    #define CFG_NVDS_TAG_BLE_CA_NB_PKT          100
    #define CFG_NVDS_TAG_BLE_CA_NB_BAD_PKT      50
    
    /****************************************************************************************************************/
    /* Enables the logging of heap memories usage. The feature can be used in development/debug mode.               */
    /* Application must be executed in Keil debugger environment and "da14585_586.lib" must be replaced with        */
    /* "da14585_586_with_heap_logging.lib" in project structure under sdk_arch. Developer must stop execution       */
    /* and type disp_heaplog() in debugger's command window. Heap memory statistics will be displayed on window     */
    /****************************************************************************************************************/
    #undef CFG_LOG_HEAP_USAGE
    
    /****************************************************************************************************************/
    /* Enables the BLE statistics measurement feature.                                                              */
    /****************************************************************************************************************/
    #undef CFG_BLE_METRICS
    
    /****************************************************************************************************************/
    /* Output the Hardfault arguments to serial/UART interface.                                                     */
    /****************************************************************************************************************/
    #undef CFG_PRODUCTION_DEBUG_OUTPUT
    
    /****************************************************************************************************************/
    /* Maximum supported TX data packet length (supportedMaxTxOctets value, as defined in 4.2 Specification).       */
    /* Range: 27 - 251 octets.                                                                                      */
    /* NOTE 1: Even number of octets are not supported. A selected even number will be automatically converted to   */
    /*         the next odd one.                                                                                    */
    /* NOTE 2: The supportedMaxTxTime value is automatically calculated by the ROM code, according to the following */
    /*         equation:                                                                                            */
    /*             supportedMaxTxTime = (supportedMaxTxOctets + 11 + 3 ) * 8                                        */
    /*         Range: 328 - 2120 usec.                                                                              */
    /****************************************************************************************************************/
    #define CFG_MAX_TX_PACKET_LENGTH        (251)
    
    /****************************************************************************************************************/
    /* Maximum supported RX data packet length (supportedMaxRxOctets value, as defined in 4.2 Specification).       */
    /* Range: 27 - 251 octets.                                                                                      */
    /* NOTE 1: Even number of octets are not supported. A selected even number will be automatically converted to   */
    /*         the next odd one.                                                                                    */
    /* NOTE 2: The supportedMaxRxTime value is automatically calculated by the ROM code, according to the following */
    /*         equation:                                                                                            */
    /*             supportedMaxRxTime = (supportedMaxRxOctets + 11 + 3 ) * 8                                        */
    /*         Range: 328 - 2120 usec.                                                                              */
    /****************************************************************************************************************/
    #define CFG_MAX_RX_PACKET_LENGTH        (251)
    
    /****************************************************************************************************************/
    /* Select external application/host transport layer:                                                            */
    /*     - 0 = GTL (auto)                                                                                         */
    /*     - 1 = HCI (auto)                                                                                         */
    /*     - 8 = GTL (fixed)                                                                                        */
    /*     - 9 = HCI (fixed)                                                                                        */
    /****************************************************************************************************************/
    #define CFG_USE_H4TL                    (0)
    
    /****************************************************************************************************************/
    /* Duplicate filter max value for the scan report list. The maximum value shall be 100.                         */
    /****************************************************************************************************************/
    #define CFG_BLE_DUPLICATE_FILTER_MAX    (10)
    
    /****************************************************************************************************************/
    /* Duplicate filter flag for the scan report list. This flag controls what will be reported if the              */
    /* CFG_BLE_DUPLICATE_FILTER_MAX number is exceeded.                                                             */
    /*     - If the flag is defined, the extra devices are considered to be in the list and will not be reported.   */
    /****************************************************************************************************************/
    #undef CFG_BLE_DUPLICATE_FILTER_FOUND
    
    /****************************************************************************************************************/
    /* Resolving list maximum size.                                                                                 */
    /****************************************************************************************************************/
    #define CFG_LLM_RESOLVING_LIST_MAX      LLM_RESOLVING_LIST_MAX
    
    /****************************************************************************************************************/
    /* Enables automatic data packet length negotiation.                                                            */
    /* NOTE: Enable only if peer device supports data length extension!!                                            */
    /****************************************************************************************************************/
    #undef AUTO_DATA_LENGTH_NEGOTIATION_UPON_NEW_CONNECTION
    
    /****************************************************************************************************************/
    /* Maximum retention memory in bytes. The base address of the retention data is calculated from the selected    */
    /* size.                                                                                                        */
    /****************************************************************************************************************/
    #define CFG_RET_DATA_SIZE    (2048)
    
    /****************************************************************************************************************/
    /* Maximum uninitialized retained data required by the application.                                             */
    /****************************************************************************************************************/
    #define CFG_RET_DATA_UNINIT_SIZE (0)
    
    /****************************************************************************************************************/
    /* The Keil scatter file may be provided by the user. If the user provides his own scatter file, the system has */
    /* to be aware which RAM blocks has to retain. The 4th RAM block is always retained, since it contains the ROM  */
    /* data.                                                                                                        */
    /*     - CFG_RETAIN_RAM_1_BLOCK: if defined, the 1st RAM block must be retained.                                */
    /*     - CFG_RETAIN_RAM_2_BLOCK: if defined, the 2nd RAM block must be retained.                                */
    /*     - CFG_RETAIN_RAM_3_BLOCK: if defined, the 3rd RAM block must be retained.                                */
    /*                                                                                                              */
    /* If the CFG_CUSTOM_SCATTER_FILE flag is undefined, the system knows which blocks to retain based on the       */
    /* default SDK scatter file.                                                                                    */
    /****************************************************************************************************************/
    #undef CFG_CUSTOM_SCATTER_FILE
    #ifdef CFG_CUSTOM_SCATTER_FILE
        #define CFG_RETAIN_RAM_1_BLOCK
        #define CFG_RETAIN_RAM_2_BLOCK
        #define CFG_RETAIN_RAM_3_BLOCK
    #endif
    
    /****************************************************************************************************************/
    /* Code location selection.                                                                                     */
    /*     - CFG_CODE_LOCATION_EXT: Code is loaded from SPI flash / I2C EEPROM / UART                               */
    /*     - CFG_CODE_LOCATION_OTP: Code is burned in the OTP                                                       */
    /* The above options are mutually exclusive and exactly one of them must be enabled.                            */
    /****************************************************************************************************************/
    #define CFG_CODE_LOCATION_EXT
    #undef CFG_CODE_LOCATION_OTP
    
    /****************************************************************************************************************/
    /* Temperature range selection.                                                                                 */
    /* - CFG_HIGH_TEMPERATURE:         Device is configured to operate at high temperature range (-40C to +105C).   */
    /* - CFG_AMB_TEMPERATURE:          Device is configured to operate at ambient temperature range (-40C to +40C). */
    /* - CFG_MID_TEMPERATURE:          Device is configured to operate at mid temperature range (-40C to +60C).     */
    /* - CFG_EXT_TEMPERATURE:          Device is configured to operate at ext temperature range (-40C to +85C).     */
    /* NOTE 1: High temperature support is not compatible with power optimizations. User shall undefine the         */
    /*         CFG_POWER_OPTIMIZATIONS flag, if device is to support the high temperature range feature.            */
    /****************************************************************************************************************/
    #define CFG_AMB_TEMPERATURE
    
    /****************************************************************************************************************/
    /* Enable power optimizations using the XTAL16M adaptive settling algorithm.                                    */
    /* NOTE: The XTAL16M adaptive settling algorithm works only with XTAL32K and not with RCX, as the LP clock.     */
    /****************************************************************************************************************/
    #define CFG_XTAL16M_ADAPTIVE_SETTLING
    
    
    
    #else
    
    
    
    /****************************************************************************************************************/
    /* Low Power clock selection.                                                                                   */
    /*      -LP_CLK_XTAL32      External XTAL32K oscillator                                                         */
    /*      -LP_CLK_RCX20       Internal RCX clock                                                                  */
    /*      -LP_CLK_FROM_OTP    Use the selection in the corresponding field of OTP Header                          */
    /****************************************************************************************************************/
    #define CFG_LP_CLK              LP_CLK_RCX20
    
    /****************************************************************************************************************/
    /* Periodic wakeup period to poll GTL iface. Time in msec.                                                      */
    /****************************************************************************************************************/
    #define CFG_MAX_SLEEP_DURATION_PERIODIC_WAKEUP_MS                  500  // 0.5s
    
    /****************************************************************************************************************/
    /* Periodic wakeup period if GTL iface is not enabled. Time in msec.                                            */
    /****************************************************************************************************************/
    #define CFG_MAX_SLEEP_DURATION_EXTERNAL_WAKEUP_MS              600000  // 600s
    
    /****************************************************************************************************************/
    /* Wakeup from external processor running host application.                                                     */
    /****************************************************************************************************************/
    #undef CFG_EXTERNAL_WAKEUP
    
    /****************************************************************************************************************/
    /* Wakeup external processor when a message is sent to GTL                                                      */
    /****************************************************************************************************************/
    #undef CFG_WAKEUP_EXT_PROCESSOR
    
    /****************************************************************************************************************/
    /* Enables True Random Number Generator. A true random number, generated at system initialization, is used to   */
    /* seed any random number generator (C standard library, ChaCha20, etc.).                                       */
    /****************************************************************************************************************/
    #define CFG_TRNG
    
    /****************************************************************************************************************/
    /* Creation of private and public keys using Elliptic Curve Diffie Hellman algorithms.                          */
    /* - defined:   Creation of ECDH keys and secure connection feature is enabled.                                 */
    /* - undefined: Creation of ECDH keys and secure connection feature is disabled. If application does not        */
    /*              support secure connections, it is reccomended to undefine CFG_ENABLE_SMP_SECURE in order to     */
    /*              enable faster start-up time and reduce code size.                                               */
    /****************************************************************************************************************/
    #undef CFG_ENABLE_SMP_SECURE
    
    /****************************************************************************************************************/
    /* Uses ChaCha20 random number generator instead of the C standard library random number generator.             */
    /****************************************************************************************************************/
    #undef CFG_USE_CHACHA20_RAND
    
    /****************************************************************************************************************/
    /* Custom heap sizes                                                                                            */
    /****************************************************************************************************************/
     #define DB_HEAP_SZ              2048 //buzz for SUOTA
    // #define ENV_HEAP_SZ             4928
    // #define MSG_HEAP_SZ             6880
    // #define NON_RET_HEAP_SZ         2048
    
    /****************************************************************************************************************/
    /* NVDS configuration                                                                                           */
    /* - CFG_NVDS_TAG_BD_ADDRESS            Default bdaddress. If bdaddress is written in OTP header this value is  */
    /*                                      ignored                                                                 */
    /* - CFG_NVDS_TAG_LPCLK_DRIFT           Low power clock drift. Permitted values in ppm are:                     */
    /*      + DRIFT_20PPM                                                                                           */
    /*      + DRIFT_30PPM                                                                                           */
    /*      + DRIFT_50PPM                                                                                           */
    /*      + DRIFT_75PPM                                                                                           */
    /*      + DRIFT_100PPM                                                                                          */
    /*      + DRIFT_150PPM                                                                                          */
    /*      + DRIFT_250PPM                                                                                          */
    /*      + DRIFT_500PPM                  Default value (500 ppm)                                                 */
    /* - CFG_NVDS_TAG_BLE_CA_TIMER_DUR      Channel Assessment Timer duration (Multiple of 10ms)                    */
    /* - CFG_NVDS_TAG_BLE_CRA_TIMER_DUR     Channel Reassessment Timer duration (Multiple of CA timer duration)     */
    /* - CFG_NVDS_TAG_BLE_CA_MIN_RSSI       Minimum RSSI Threshold                                                  */
    /* - CFG_NVDS_TAG_BLE_CA_NB_PKT         Number of packets to receive for statistics                             */
    /* - CFG_NVDS_TAG_BLE_CA_NB_BAD_PKT     Number  of bad packets needed to remove a channel                       */
    /****************************************************************************************************************/
    #define CFG_NVDS_TAG_BD_ADDRESS             {0x03, 0x00, 0x70, 0xCA, 0xEA, 0x80}
    
    #define CFG_NVDS_TAG_LPCLK_DRIFT            DRIFT_500PPM
    #define CFG_NVDS_TAG_BLE_CA_TIMER_DUR       2000
    #define CFG_NVDS_TAG_BLE_CRA_TIMER_DUR      6
    #define CFG_NVDS_TAG_BLE_CA_MIN_RSSI        0x40
    #define CFG_NVDS_TAG_BLE_CA_NB_PKT          100
    #define CFG_NVDS_TAG_BLE_CA_NB_BAD_PKT      50
    
    /****************************************************************************************************************/
    /* Enables the logging of heap memories usage. The feature can be used in development/debug mode.               */
    /* Application must be executed in Keil debugger environment and "da14531.lib" must be replaced with            */
    /* "da14531_with_heap_logging.lib" in project structure under sdk_arch. Developer must stop execution           */
    /* and type disp_heaplog() in debugger's command window. Heap memory statistics will be displayed on window     */
    /****************************************************************************************************************/
    #undef CFG_LOG_HEAP_USAGE
    
    /****************************************************************************************************************/
    /* Enables the BLE statistics measurement feature.                                                              */
    /****************************************************************************************************************/
    #undef CFG_BLE_METRICS
    
    /****************************************************************************************************************/
    /* Output the Hardfault arguments to serial/UART interface.                                                     */
    /****************************************************************************************************************/
    #undef CFG_PRODUCTION_DEBUG_OUTPUT
    
    /****************************************************************************************************************/
    /* Maximum supported TX data packet length (supportedMaxTxOctets value, as defined in 4.2 Specification).       */
    /* Range: 27 - 251 octets.                                                                                      */
    /* NOTE 1: Even number of octets are not supported. A selected even number will be automatically converted to   */
    /*         the next odd one.                                                                                    */
    /* NOTE 2: The supportedMaxTxTime value is automatically calculated by the ROM code, according to the following */
    /*         equation:                                                                                            */
    /*             supportedMaxTxTime = (supportedMaxTxOctets + 11 + 3 ) * 8                                        */
    /*         Range: 328 - 2120 usec.                                                                              */
    /****************************************************************************************************************/
    //buzz #define CFG_MAX_TX_PACKET_LENGTH        (251)
    #define CFG_MAX_TX_PACKET_LENGTH        (27)
    
    /****************************************************************************************************************/
    /* Maximum supported RX data packet length (supportedMaxRxOctets value, as defined in 4.2 Specification).       */
    /* Range: 27 - 251 octets.                                                                                      */
    /* NOTE 1: Even number of octets are not supported. A selected even number will be automatically converted to   */
    /*         the next odd one.                                                                                    */
    /* NOTE 2: The supportedMaxRxTime value is automatically calculated by the ROM code, according to the following */
    /*         equation:                                                                                            */
    /*             supportedMaxRxTime = (supportedMaxRxOctets + 11 + 3 ) * 8                                        */
    /*         Range: 328 - 2120 usec.                                                                              */
    /****************************************************************************************************************/
    //buzz #define CFG_MAX_RX_PACKET_LENGTH        (251)
    #define CFG_MAX_RX_PACKET_LENGTH        (27)
    
    /****************************************************************************************************************/
    /* Select external application/host transport layer:                                                            */
    /*     - 0 = GTL (auto)                                                                                         */
    /*     - 1 = HCI (auto)                                                                                         */
    /*     - 8 = GTL (fixed)                                                                                        */
    /*     - 9 = HCI (fixed)                                                                                        */
    /****************************************************************************************************************/
    #define CFG_USE_H4TL                    (0)
    
    /****************************************************************************************************************/
    /* Duplicate filter max value for the scan report list. The maximum value shall be 100.                         */
    /****************************************************************************************************************/
    #define CFG_BLE_DUPLICATE_FILTER_MAX    (10)
    
    /****************************************************************************************************************/
    /* Duplicate filter flag for the scan report list. This flag controls what will be reported if the              */
    /* CFG_BLE_DUPLICATE_FILTER_MAX number is exceeded.                                                             */
    /*     - If the flag is defined, the extra devices are considered to be in the list and will not be reported.   */
    /****************************************************************************************************************/
    #undef CFG_BLE_DUPLICATE_FILTER_FOUND
    
    /****************************************************************************************************************/
    /* Resolving list maximum size.                                                                                 */
    /****************************************************************************************************************/
    #define CFG_LLM_RESOLVING_LIST_MAX      LLM_RESOLVING_LIST_MAX
    
    /****************************************************************************************************************/
    /* Enables automatic data packet length negotiation.                                                            */
    /* NOTE: Enable only if peer device supports data length extension!!                                            */
    /****************************************************************************************************************/
    #undef AUTO_DATA_LENGTH_NEGOTIATION_UPON_NEW_CONNECTION
    
    /****************************************************************************************************************/
    /* Maximum retention memory in bytes. The base address of the retention data is calculated from the selected    */
    /* size.                                                                                                        */
    /****************************************************************************************************************/
    //buzz #define CFG_RET_DATA_SIZE    (2048)
    //#define CFG_RET_DATA_SIZE    (2200)
    #define CFG_RET_DATA_SIZE    (2048)
    
    /****************************************************************************************************************/
    /* Maximum uninitialized retained data required by the application.                                             */
    /****************************************************************************************************************/
    #define CFG_RET_DATA_UNINIT_SIZE (0)
    
    /****************************************************************************************************************/
    /* The Keil scatter file may be provided by the user. If the user provides his own scatter file, the system has */
    /* to be aware which RAM blocks has to retain. The 3rd RAM block is always retained, since it contains the ROM  */
    /* data.                                                                                                        */
    /*     - CFG_RETAIN_RAM_1_BLOCK: if defined, the 1st RAM block must be retained.                                */
    /*     - CFG_RETAIN_RAM_2_BLOCK: if defined, the 2nd RAM block must be retained.                                */
    /*                                                                                                              */
    /* If the CFG_CUSTOM_SCATTER_FILE flag is undefined, the system knows which blocks to retain based on the       */
    /* default SDK scatter file.                                                                                    */
    /****************************************************************************************************************/
    #undef CFG_CUSTOM_SCATTER_FILE
    #ifdef CFG_CUSTOM_SCATTER_FILE
        #define CFG_RETAIN_RAM_1_BLOCK
        #define CFG_RETAIN_RAM_2_BLOCK
    #endif
    
    /****************************************************************************************************************/
    /* Code location selection.                                                                                     */
    /*     - CFG_CODE_LOCATION_EXT: Code is loaded from SPI flash / I2C EEPROM / UART                               */
    /*     - CFG_CODE_LOCATION_OTP: Code is burned in the OTP                                                       */
    /* The above options are mutually exclusive and exactly one of them must be enabled.                            */
    /****************************************************************************************************************/
    #define CFG_CODE_LOCATION_EXT
    #undef CFG_CODE_LOCATION_OTP
    
    /****************************************************************************************************************/
    /* Temperature range selection.                                                                                 */
    /* - CFG_HIGH_TEMPERATURE:         Device is configured to operate at high temperature range (-40C to +105C).   */
    /* - CFG_AMB_TEMPERATURE:          Device is configured to operate at ambient temperature range (-40C to +40C). */
    /* - CFG_MID_TEMPERATURE:          Device is configured to operate at mid temperature range (-40C to +60C).     */
    /* - CFG_EXT_TEMPERATURE:          Device is configured to operate at ext temperature range (-40C to +85C).     */
    /****************************************************************************************************************/
    #define CFG_AMB_TEMPERATURE
    
    /****************************************************************************************************************/
    /* Disable quadrature decoder on start up. The quadrature decoder is by default enabled on system power up and  */
    /* it may count events. This leads to WKUP_QUADEC_IRQn pending interrupts.                                      */
    /****************************************************************************************************************/
    #define CFG_DISABLE_QUADEC_ON_START_UP
    
    #endif
    
    #endif // _DA1458X_CONFIG_ADVANCED_H_
    
    /**
     ****************************************************************************************
     *
     * @file user_config.h
     *
     * @brief User configuration file.
     *
     * Copyright (C) 2015-2020 Dialog Semiconductor.
     * This computer program includes Confidential, Proprietary Information
     * of Dialog Semiconductor. All Rights Reserved.
     *
     ****************************************************************************************
     */
    
    #ifndef _USER_CONFIG_H_
    #define _USER_CONFIG_H_
    
    /*
     * INCLUDE FILES
     ****************************************************************************************
     */
    
    #include "app_user_config.h"
    #include "arch_api.h"
    #include "app_default_handlers.h"
    #include "app_adv_data.h"
    #include "co_bt.h"
    
    /*
     * DEFINES
     ****************************************************************************************
     */
    
    /*
     ****************************************************************************************
     *
     * Privacy / Addressing configuration
     *
     ****************************************************************************************
     */
    
    /*************************************************************************
     * Privacy Capabilities and address configuration of local device:
     * - APP_CFG_ADDR_PUB               No Privacy, Public BDA
     * - APP_CFG_ADDR_STATIC            No Privacy, Random Static BDA
     * - APP_CFG_HOST_PRIV_RPA          Host Privacy, RPA, Public Identity
     * - APP_CFG_HOST_PRIV_NRPA         Host Privacy, NRPA (non-connectable ONLY)
     * - APP_CFG_CNTL_PRIV_RPA_PUB      Controller Privacy, RPA or PUB, Public Identity
     * - APP_CFG_CNTL_PRIV_RPA_RAND     Controller Privacy, RPA, Public Identity
     *
     * Select only one option for privacy / addressing configuration.
     **************************************************************************
     */
    #define USER_CFG_ADDRESS_MODE       APP_CFG_ADDR_PUB
    
    /*************************************************************************
     * Controller Privacy Mode:
     * - APP_CFG_CNTL_PRIV_MODE_NETWORK Controler Privacy Network mode (default)
     * - APP_CFG_CNTL_PRIV_MODE_DEVICE  Controler Privacy Device mode
     *
     * Select only one option for controller privacy mode configuration.
     **************************************************************************
     */
    #define USER_CFG_CNTL_PRIV_MODE     APP_CFG_CNTL_PRIV_MODE_NETWORK
    
    /*
     ****************************************************************************************
     *
     * Security configuration
     *
     ****************************************************************************************
     */
    
    /************************************************************
     * Device IO Capability (@see gap_io_cap)
     *
     * - GAP_IO_CAP_DISPLAY_ONLY          Display Only
     * - GAP_IO_CAP_DISPLAY_YES_NO        Display Yes No
     * - GAP_IO_CAP_KB_ONLY               Keyboard Only
     * - GAP_IO_CAP_NO_INPUT_NO_OUTPUT    No Input No Output
     * - GAP_IO_CAP_KB_DISPLAY            Keyboard Display
     *
     * Select only one option.
     ************************************************************
     */
    #define USER_CFG_FEAT_IO_CAP    GAP_IO_CAP_DISPLAY_YES_NO
    
    /************************************************************
     * OOB information (@see gap_oob)
     *
     * - GAP_OOB_AUTH_DATA_NOT_PRESENT    OOB Data not present
     * - GAP_OOB_AUTH_DATA_PRESENT        OOB data present
     *
     * Select only one option.
     * Note: OOB is only supported with Legacy Pairing
     ************************************************************
     */
    #define USER_CFG_FEAT_OOB       GAP_OOB_AUTH_DATA_NOT_PRESENT
    
    /************************************************************
     * Authentication Requirements (@see gap_auth_mask)
     *
     * - GAP_AUTH_NONE      None
     * - GAP_AUTH_BOND      Bond
     * - GAP_AUTH_MITM      MITM
     * - GAP_AUTH_SEC       Secure Connection
     * - GAP_AUTH_KEY       Keypress Notification (Not Supported)
     *
     * Any combination of the above.
     ************************************************************
     */
    #define USER_CFG_FEAT_AUTH_REQ  (GAP_AUTH_BOND | GAP_AUTH_MITM | GAP_AUTH_SEC)
    
    /************************************************************
     * Encryption Max key size (7 to 16) - USER_CFG_FEAT_KEY_SIZE
     ************************************************************
     */
    #define USER_CFG_FEAT_KEY_SIZE  KEY_LEN
    
    /************************************************************
     * Device security requirements (@see gap_sec_req)
     *
     * - GAP_NO_SEC                 No security (no authentication and encryption)
     * - GAP_SEC1_NOAUTH_PAIR_ENC   Unauthenticated pairing with encryption
     * - GAP_SEC1_AUTH_PAIR_ENC     Authenticated pairing with encryption
     * - GAP_SEC1_SEC_PAIR_ENC      Authenticated LE Secure Connections pairing with encryption
     * - GAP_SEC2_NOAUTH_DATA_SGN   Unauthenticated pairing with data signing
     * - GAP_SEC2_AUTH_DATA_SGN     Authentication pairing with data signing
     *
     * Select only one option.
     ************************************************************
     */
    #define USER_CFG_FEAT_SEC_REQ   GAP_SEC1_NOAUTH_PAIR_ENC
    
    /**************************************************************************************
     * Initiator key distribution (@see gap_kdist)
     *
     * - GAP_KDIST_NONE             No Keys to distribute
     * - GAP_KDIST_ENCKEY           LTK (Encryption key) in distribution
     * - GAP_KDIST_IDKEY            IRK (ID key)in distribution
     * - GAP_KDIST_SIGNKEY          CSRK (Signature key) in distribution
     *
     * Any combination of the above
     **************************************************************************************
     */
    #define USER_CFG_FEAT_INIT_KDIST (GAP_KDIST_ENCKEY | GAP_KDIST_IDKEY | GAP_KDIST_SIGNKEY)
    
    /**************************************************************************************
     * Responder key distribution (@see gap_kdist)
     *
     * - GAP_KDIST_NONE             No Keys to distribute
     * - GAP_KDIST_ENCKEY           LTK (Encryption key) in distribution
     * - GAP_KDIST_IDKEY            IRK (ID key)in distribution
     * - GAP_KDIST_SIGNKEY          CSRK (Signature key) in distribution
     *
     * Any combination of the above
     **************************************************************************************
     */
    #define USER_CFG_FEAT_RESP_KDIST (GAP_KDIST_ENCKEY | GAP_KDIST_IDKEY | GAP_KDIST_SIGNKEY)
    
    /*
     * VARIABLES
     ****************************************************************************************
     */
    
    /******************************************
     * Default sleep mode. Possible values are:
     *
     * - ARCH_SLEEP_OFF
     * - ARCH_EXT_SLEEP_ON
     * - ARCH_EXT_SLEEP_OTP_COPY_ON
     *
     ******************************************
     */
    //BUZZ static const sleep_state_t app_default_sleep_mode = ARCH_SLEEP_OFF;
    static const sleep_state_t app_default_sleep_mode = ARCH_EXT_SLEEP_ON;
    
    /*
     ****************************************************************************************
     *
     * Advertising configuration
     *
     ****************************************************************************************
     */
    static const struct advertise_configuration user_adv_conf = {
    
        .addr_src = APP_CFG_ADDR_SRC(USER_CFG_ADDRESS_MODE),
    
        /// Minimum interval for advertising
        .intv_min = MS_TO_BLESLOTS(687.5),                    // 687.5ms
    
        /// Maximum interval for advertising
        .intv_max = MS_TO_BLESLOTS(687.5),                    // 687.5ms
    
        /**
         *  Advertising channels map:
         * - ADV_CHNL_37_EN:   Advertising channel map for channel 37.
         * - ADV_CHNL_38_EN:   Advertising channel map for channel 38.
         * - ADV_CHNL_39_EN:   Advertising channel map for channel 39.
         * - ADV_ALL_CHNLS_EN: Advertising channel map for channel 37, 38 and 39.
         */
        .channel_map = ADV_ALL_CHNLS_EN,
    
        /*************************
         * Advertising information
         *************************
         */
    
        /// Host information advertising data (GAPM_ADV_NON_CONN and GAPM_ADV_UNDIRECT)
        /// Advertising mode :
        /// - GAP_NON_DISCOVERABLE: Non discoverable mode
        /// - GAP_GEN_DISCOVERABLE: General discoverable mode
        /// - GAP_LIM_DISCOVERABLE: Limited discoverable mode
        /// - GAP_BROADCASTER_MODE: Broadcaster mode
        .mode = GAP_GEN_DISCOVERABLE,
    
        /// Host information advertising data (GAPM_ADV_NON_CONN and GAPM_ADV_UNDIRECT)
        /// Advertising filter policy:
        /// - ADV_ALLOW_SCAN_ANY_CON_ANY: Allow both scan and connection requests from anyone
        /// - ADV_ALLOW_SCAN_ANY_CON_WLST: Allow both scan req from anyone and connection req from
        ///                                White List devices only
        .adv_filt_policy = ADV_ALLOW_SCAN_ANY_CON_ANY,
    
        /// Address of peer device
        /// NOTE: Meant for directed advertising (ADV_DIRECT_IND)
        .peer_addr = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6},
    
        /// Address type of peer device (0=public/1=random)
        /// NOTE: Meant for directed advertising (ADV_DIRECT_IND)
        .peer_addr_type = 0,
    };
    
    /*
     ****************************************************************************************
     *
     * 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.
     ****************************************************************************************
     */
    /// Advertising data
    /*
    #define USER_ADVERTISE_DATA         ("\x03"\
                                        ADV_TYPE_COMPLETE_LIST_16BIT_SERVICE_IDS\
    																		ADV_UUID_DEVICE_INFORMATION_SERVICE\
                                        "\x11"\
                                        ADV_TYPE_COMPLETE_LIST_128BIT_SERVICE_IDS\
                                        "\x59\x5A\x08\xE4\x86\x2A\x9E\x8F\xE9\x11\xBC\x7C\x98\x43\x42\x18")
    */
    
    #define USER_ADVERTISE_DATA         ("\x03"\
                                        ADV_TYPE_COMPLETE_LIST_16BIT_SERVICE_IDS\
                                        ADV_UUID_SUOTAR_SERVICE)
    																		
    /// Advertising data length - maximum 28 bytes, 3 bytes are reserved to set
    #define USER_ADVERTISE_DATA_LEN               (sizeof(USER_ADVERTISE_DATA)-1)
    
    /// Scan response data
    #define USER_ADVERTISE_SCAN_RESPONSE_DATA ""
    
    /// Scan response data length- maximum 31 bytes
    #define USER_ADVERTISE_SCAN_RESPONSE_DATA_LEN (sizeof(USER_ADVERTISE_SCAN_RESPONSE_DATA)-1)
    
    /*
     ****************************************************************************************
     *
     * Device name.
     *
     * - If there is space left in the advertising or scan response data the device name is
     *   copied there. The device name can be anytime read by a connected peer, if the
     *   application supports it.
     * - The Bluetooth device name can be up to 248 bytes.
     *
     ****************************************************************************************
     */
    /// Device name
    #define USER_DEVICE_NAME        "Black Box"
    
    /// Device name length
    #define USER_DEVICE_NAME_LEN    (sizeof(USER_DEVICE_NAME)-1)
    
    /*
     ****************************************************************************************
     *
     * GAPM configuration
     *
     ****************************************************************************************
     */
    static const struct gapm_configuration user_gapm_conf = {
        /// Device Role: Central, Peripheral, Observer, Broadcaster or All roles. (@see enum gap_role)
        .role = GAP_ROLE_PERIPHERAL,
    
        /// Maximal MTU. Shall be set to 23 if Legacy Pairing is used, 65 if Secure Connection is used,
        /// more if required by the application
    //buzz    .max_mtu = 23,
        .max_mtu = 65,
    
        /// Device Address Type
        .addr_type = APP_CFG_ADDR_TYPE(USER_CFG_ADDRESS_MODE),
        /// Duration before regenerating the Random Private Address when privacy is enabled
        .renew_dur = 15000,    // 15000 * 10ms = 150s is the minimum value
    
        /***********************
         * Privacy configuration
         ***********************
         */
    
        /// Random Static address
        // NOTE: The address shall comply with the following requirements:
        // - the two most significant bits of the address shall be equal to 1,
        // - all the remaining bits of the address shall NOT be equal to 1,
        // - all the remaining bits of the address shall NOT be equal to 0.
        // In case the {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} null address is used, a
        // random static address will be automatically generated.
        .addr = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    
        /// Device IRK used for Resolvable Private Address generation (LSB first)
        .irk = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f},
    
        /****************************
         * ATT database configuration
         ****************************
         */
    
        /// Attribute database configuration (@see enum gapm_att_cfg_flag)
        ///    7     6    5     4     3    2    1    0
        /// +-----+-----+----+-----+-----+----+----+----+
        /// | DBG | RFU | SC | PCP | APP_PERM |NAME_PERM|
        /// +-----+-----+----+-----+-----+----+----+----+
        /// - Bit [0-1]: Device Name write permission requirements for peer device (@see device_name_write_perm)
        /// - Bit [2-3]: Device Appearance write permission requirements for peer device (@see device_appearance_write_perm)
        /// - Bit [4]  : Slave Preferred Connection Parameters present
        /// - Bit [5]  : Service change feature present in GATT attribute database.
        /// - Bit [6]  : Reserved
        /// - Bit [7]  : Enable Debug Mode
        .att_cfg = GAPM_MASK_ATT_SVC_CHG_EN,
    
        /// GAP service start handle
        .gap_start_hdl = 0,
    
        /// GATT service start handle
        .gatt_start_hdl = 0,
    
        /**************************************************
         * Data packet length extension configuration (4.2)
         **************************************************
         */
    
        /// Maximal MPS
        .max_mps = 0,
    
        /// Maximal Tx octets (connInitialMaxTxOctets value, as defined in 4.2 Specification)
        .max_txoctets = 251,
    
        /// Maximal Tx time (connInitialMaxTxTime value, as defined in 4.2 Specification)
        .max_txtime = 2120,
    };
    
    /*
     ****************************************************************************************
     *
     * Parameter update configuration
     *
     ****************************************************************************************
     */
    static const struct connection_param_configuration user_connection_param_conf = {
        /// Connection interval minimum measured in ble double slots (1.25ms)
        /// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
        .intv_min = MS_TO_DOUBLESLOTS(10),
    
        /// Connection interval maximum measured in ble double slots (1.25ms)
        /// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
        .intv_max = MS_TO_DOUBLESLOTS(20),
    
        /// Latency measured in connection events
        .latency = 0,
    
        /// Supervision timeout measured in timer units (10 ms)
        /// use the macro MS_TO_TIMERUNITS to convert from milliseconds (ms) to timer units
        .time_out = MS_TO_TIMERUNITS(1250),
    
        /// Minimum Connection Event Duration measured in ble double slots (1.25ms)
        /// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
        .ce_len_min = MS_TO_DOUBLESLOTS(0),
    
        /// Maximum Connection Event Duration measured in ble double slots (1.25ms)
        /// use the macro MS_TO_DOUBLESLOTS to convert from milliseconds (ms) to double slots
        .ce_len_max = MS_TO_DOUBLESLOTS(0),
    };
    
    /*
     ****************************************************************************************
     *
     * Default handlers configuration (applies only for @app_default_handlers.c)
     *
     ****************************************************************************************
     */
    static const struct default_handlers_configuration  user_default_hnd_conf = {
        // Configure the advertise operation used by the default handlers
        // Possible values:
        //  - DEF_ADV_FOREVER
        //  - DEF_ADV_WITH_TIMEOUT
        .adv_scenario = DEF_ADV_FOREVER,
    
        // Configure the advertise period in case of DEF_ADV_WITH_TIMEOUT.
        // It is measured in timer units (3 min). Use MS_TO_TIMERUNITS macro to convert
        // from milliseconds (ms) to timer units.
        .advertise_period = MS_TO_TIMERUNITS(180000),
    
        // Configure the security start operation of the default handlers
        // if the security is enabled (CFG_APP_SECURITY)
        // Possible values:
        //  - DEF_SEC_REQ_NEVER
        //  - DEF_SEC_REQ_ON_CONNECT
        .security_request_scenario = DEF_SEC_REQ_NEVER
    };
    
    /*
     ****************************************************************************************
     *
     * Central configuration (not used by current example)
     *
     ****************************************************************************************
     */
    static const struct central_configuration user_central_conf = {
        /// GAPM requested operation:
        /// - GAPM_CONNECTION_DIRECT: Direct connection operation
        /// - GAPM_CONNECTION_AUTO: Automatic connection operation
        /// - GAPM_CONNECTION_SELECTIVE: Selective connection operation
        /// - GAPM_CONNECTION_NAME_REQUEST: Name Request operation (requires to start a direct
        ///   connection)
        .code = GAPM_CONNECTION_DIRECT,
    
        /// Own BD address source of the device:
        .addr_src = APP_CFG_ADDR_SRC(USER_CFG_ADDRESS_MODE),
    
        /// Scan interval
        .scan_interval = 0x180,
    
        /// Scan window size
        .scan_window = 0x160,
    
         /// Minimum of connection interval
        .con_intv_min = 100,
    
        /// Maximum of connection interval
        .con_intv_max = 100,
    
        /// Connection latency
        .con_latency = 0,
    
        /// Link supervision timeout
        .superv_to = 0x1F4,
    
         /// Minimum CE length
        .ce_len_min = 0,
    
        /// Maximum CE length
        .ce_len_max = 0x5,
    
        /**************************************************************************************
         * Peer device information (maximum number of peers = 8)
         **************************************************************************************
         */
    
        /// BD Address of device
        .peer_addr_0 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
    
        /// Address type of the device 0=public/1=random
        .peer_addr_0_type = 0,
    
        /// BD Address of device
        .peer_addr_1 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
    
        /// Address type of the device 0=public/1=random
        .peer_addr_1_type = 0,
    
        /// BD Address of device
        .peer_addr_2 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
    
        /// Address type of the device 0=public/1=random
        .peer_addr_2_type = 0,
    
        /// BD Address of device
        .peer_addr_3 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
    
        /// Address type of the device 0=public/1=random
        .peer_addr_3_type = 0,
    
        /// BD Address of device
        .peer_addr_4 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
    
        /// Address type of the device 0=public/1=random
        .peer_addr_4_type = 0,
    
        /// BD Address of device
        .peer_addr_5 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
    
        /// Address type of the device 0=public/1=random
        .peer_addr_5_type = 0,
    
        /// BD Address of device
        .peer_addr_6 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
    
        /// Address type of the device 0=public/1=random
        .peer_addr_6_type = 0,
    
        /// BD Address of device
        .peer_addr_7 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},
    
        /// Address type of the device 0=public/1=random
        .peer_addr_7_type = 0,
    };
    
    /*
     ****************************************************************************************
     *
     * Security related configuration
     *
     ****************************************************************************************
     */
    static const struct security_configuration user_security_conf = {
        // IO Capabilities
        #if defined (USER_CFG_FEAT_IO_CAP)
        .iocap          = USER_CFG_FEAT_IO_CAP,
        #else
        .iocap          = GAP_IO_CAP_NO_INPUT_NO_OUTPUT,
        #endif
    
        // OOB Capabilities
        #if defined (USER_CFG_FEAT_OOB)
        .oob            = USER_CFG_FEAT_OOB,
        #else
        .oob            = GAP_OOB_AUTH_DATA_NOT_PRESENT,
        #endif
    
        // Authentication Requirements
        #if defined (USER_CFG_FEAT_AUTH_REQ)
        .auth           = USER_CFG_FEAT_AUTH_REQ,
        #else
        .auth           = GAP_AUTH_NONE,
        #endif
    
        // LTK size
        #if defined (USER_CFG_FEAT_KEY_SIZE)
        .key_size       = USER_CFG_FEAT_KEY_SIZE,
        #else
        .key_size       = KEY_LEN,
        #endif
    
        // Initiator key distribution
        #if defined (USER_CFG_FEAT_INIT_KDIST)
        .ikey_dist      = USER_CFG_FEAT_INIT_KDIST,
        #else
        .ikey_dist      = GAP_KDIST_NONE,
        #endif
    
        // Responder key distribution
        #if defined (USER_CFG_FEAT_RESP_KDIST)
        .rkey_dist      = USER_CFG_FEAT_RESP_KDIST,
        #else
        .rkey_dist      = GAP_KDIST_ENCKEY,
        #endif
    
        // Security requirements (minimum security level)
        #if defined (USER_CFG_FEAT_SEC_REQ)
        .sec_req        = USER_CFG_FEAT_SEC_REQ,
        #else
        .sec_req        = GAP_NO_SEC,
        #endif
    };
    
    #endif // _USER_CONFIG_H_
    
  • Hi Kumar,

    Thank you for the reply and the clarifications.
    When you have enabled Extended Sleep mode, the Watchdog timer is being handled automatically.
    When you have disabled Extended Sleep mode and there is no Advertising/Scanning (general activity of the BLE core) you will have to handle the Watchdog manually.
    You can use the following APIs:

    /**
     ****************************************************************************************
     * @brief     Watchdog resume.
     * About: Start the Watchdog
     ****************************************************************************************
     */
    __STATIC_INLINE void  wdg_resume(void)
    {
    #if (USE_WDOG)
        // Start WDOG
        SetWord16(RESET_FREEZE_REG, FRZ_WDOG);
    #endif
    }
    
    /**
    ****************************************************************************************
    * @brief     Freeze Watchdog. Call wdg_resume() to resume operation.
    * About: Freeze the Watchdog
    ****************************************************************************************
    */
    __STATIC_INLINE void  wdg_freeze(void)
    {
        // Freeze WDOG
        SetWord16(SET_FREEZE_REG, FRZ_WDOG);
    }
    
    /**
     ****************************************************************************************
     * @brief     Watchdog reload.
     * @param[in] period measured in 10.24ms units.
     * About: Load the default value and resume the watchdog
     ****************************************************************************************
     */
    __STATIC_INLINE void  wdg_reload(const int period)
    {
    #if (USE_WDOG)
        // WATCHDOG_DEFAULT_PERIOD * 10.24ms
        SetWord16(WATCHDOG_REG, WATCHDOG_DEFAULT_PERIOD);
    #endif
    }
    


    With Heap increased are you still witnessing the same behavior? Did you try to increase it further?

    Best Regards,
    OV_Renesas

  • Hi Renesas,
     
    In the last testing heap size was defined as ---> #define DB_HEAP_SZ  2048. Then After 15 minutes the device rebooted. I mean crashed after 15 min
     
    After you suggested again, I changed the heap size --->  #define DB_HEAP_SZ  4096. Then After 30 minutes the device rebooted. I mean crashed after 30 min
     
    You mean to say to call the WATCHDOG ? Where should I call these APIs? please suggest it to me.
     
    Note:- In this my custom app i am using Connectable, Disconnectable, app_easy_timer, iBeacon, Battery reading, Passkey security, SUOTA profiles enabled.
    Profiles enabled:
     
    #define CFG_PRF_DISS
    #define CFG_PRF_CUST1

    #define CFG_PRF_SUOTAR
    Modules Enabled:
    #define EXCLUDE_DLG_GAP (0)
    #define EXCLUDE_DLG_TIMER (0)
    #define EXCLUDE_DLG_MSG (0)
    #define EXCLUDE_DLG_SEC (0)
    #define EXCLUDE_DLG_DISS (0)
    #define EXCLUDE_DLG_PROXR (1)
    #define EXCLUDE_DLG_BASS (1)
    #define EXCLUDE_DLG_FINDL (1)
    #define EXCLUDE_DLG_FINDT (1)
    #define EXCLUDE_DLG_SUOTAR (0)
    #define EXCLUDE_DLG_CUSTS1 (0)
    #define EXCLUDE_DLG_CUSTS2 (1)
    How to optimize to rectify my issue, please recommend.
    My compilation code as below size: 
    linking...
    Program Size: Code=28776 RO-data=2588 RW-data=20 ZI-data=11372
    Thanks,
    Kumar
  • Hi Kumar,

    Thank you for the reply.

    After you suggested again, I changed the heap size --->  #define DB_HEAP_SZ  4096. Then After 30 minutes the device rebooted. I mean crashed after 30 min

    This means that the device was actually crashing due to heap exhaustion.
    Somewhere in side your code workflow there should be an issue that prevents the scheduler from freeing this memory space.


    You mean to say to call the WATCHDOG ? Where should I call these APIs? please suggest it to me.

    What I mean by handling WatchDog:
    1) Include the arch_wdg.h file in your project
    2) When you disable Extended Sleep mode, then use the wdg_freeze API, and before you re-enable the Extended Sleep mode, then use the wdg_resume API.

    I still need to understand if you are utilizing Extended or Deep Sleep mode.
    If you could share the whole project in a zip file it would be easier for us to go through it and try to debug it on our side.

    Best Regards,
    OV_Renesas

  • Hi Renesas,

    Thanks for your email.
    Due to the large size, I uploaded the zip file from the link below please download it.
    Regards,
    Kumar
Reply Children
  • Hi Kumar,

    Thank you for providing the project.
    I am not able to recreate the issue on my side. 
    I have left the project running for over 30 minutes on the Dev Kit Pro and I have connected multiple times via the SmartBond mobile application.
    After disconnect the device does not go into any Sleep mode or non-connectable advertising.
    Could you please share a high level explanation of how this project should work?
    i.e. 
    1) Advertise with Extended Sleep mode
    2) Connect
    3) Pair with LE Secure Connections
    4) Disconnect
    5) Start advertising with non-connectable mode and Extended Sleep
    6)etc.

    Best Regards,
    OV_Renesas

  • Hi Renesas,

    Can you share your device BT MAC address for sharing the pass key to access the device.

    Regards,

    Kumar

  • Hi Kumar,

    Can you share your device BT MAC address for sharing the pass key to access the device.



    BR,
    OV_Renesas

  • Hi Renesas,

     

    Your MAC passkey displayed over the console. First you connect Bonding with this passkey enter.

     

    Then you read the service Like major or minor etec and disconnect, then it will broadcast the ibeacon for every 30sec interval it is forever. I tried the last heap change but it crashed after 30 minutes.

     

    Step1# Scan and connect with passkey (Bonding, If already bonding delete and again Bond it). Note: try to input within 10 secs.

     

    Step2# Read the services

     

     MAJOR {0x9e, 0x9c, 0xdf, 0x4f, 0xe0, 0xf3, 0x3e, 0x99, 0x6f, 0x46, 0x5a, 0xbf, 0x81, 0x5a, 0x00, 0x10}

     

    MINOR {0x9a, 0x8c, 0xdf, 0x4f, 0xe0, 0xf3, 0x3e, 0x99, 0x6f, 0x46, 0x5a, 0xbf, 0x81, 0x5a, 0x00, 0x10}

     

    Step3# Disconnect and go to non-connectable mode.

     

    Step4# After 30 secs check the iBeacon data displaying.

     

    Step5# After advertising over goes to Extended Sleep and again wakeup

     

    Regards,

    Kumar

  • Hi Kumar,

    Thank you for the reply.

     

    Step3# Disconnect and go to non-connectable mode.

    I am not able to see the exact behavior you described. 
    Specifically, the firmware you sent does not go into non-connectable mode after disconnect on my side. 

    Best Regards,
    OV_Renesas

  • Hi Renesas,

    I tried with the same Firmware shared which is working for me. Find the snapshot for your reference. Download from the below link:

     https://we.tl/t-oY90HIeNCH

    Step#1 -> Click nRF Connect android app à Enable Bluetooth -à Enable Location

    Step#2 -> Scan and check the device shows like BlackBox -- > Before connecting check Bonded or Not. If already bonded please click ---> “Delete bond information” (click this option at right connect 3 dots). Once it delete it shows NOT BONDED

    Step#3 -> Now click on ---> Connect ----> try to read last service /characteristic (xxxx000002a19) click ---> it will ask Bluetooth pairing request ----> Enter the your password PIN as :: 177408 ---> If it PIN correct it read the characteristics values >>> NOTE >>> If you are not entering within 15 sec PIN then it will repeat the Step#3 until it success.

    Step#4 -> Now click on ---> DISCONNECT ----> Close the MAC tab ----> click / go to SCANNER ---> Refresh ---> You will see Black Box (Non-connectable) ---> It shows BLE information ----> Ery 30sec iBeacon advertisement displayed.

    And the below serial print logs can be seen.

    ----------------------------------------------------------------------------------------------------------------------------------

    637440

    => ..user_app_adv_start (FIRST)..  <=

    => user_app_disconnect  <=

    => ..user_app_adv_start (FIRST)..  <=

     ......default_app_on_pairing_succeeded............

    => ..user_app_adv_start (FIRST)..  <=

    => ..user_app_adv_start (SECOND)..  <=(((.....user_app_adv_undirect_complete.....)))

     

    => ..ibeacon_adv_data_update_timer_cb (FIRST)..  <=

    => ..acc_app_resume_system_from_sleep (1)..  <=

    => ..user_app_adv_start_new (THREE)..  <=

    => ..user_app_adv_start (SECOND)..  <=

    => ..user_app_adv_start (SECOND)..  <=(((.....user_app_adv_undirect_complete.....)))

     

    => ..ibeacon_adv_data_update_timer_cb (FIRST)..  <=

    => ..acc_app_resume_system_from_sleep (1)..  <=

    => ..user_app_adv_start_new (THREE)..  <=

    => ..user_app_adv_start (SECOND)..  <=

    => ..user_app_adv_start (SECOND)..  <=(((.....user_app_adv_undirect_complete.....)))

    ----------------------------------------------------------------------------------------------------------------------------------

    Please check the same process and let us know. Please check with other Android app nRF Connect.

    Thanks,

    Francis

  • Hi Renesas,

    I tried with the Firmware shared which is working for me. Find the snapshot for your reference. Download from the below link:

    https://we.tl/t-sN5oWe3MxD

    Step#1 -> Click nRF Connect android app Enable Bluetooth Enable Location

    Step#2 -> Scan and check the device shows like BlackBox -- > Before connecting check Bonded or Not. If already bonded please click ---> “Delete bond information” (click this option at right connect 3 dots). Once it delete it shows NOT BONDED

    Step#3 -> Now click on ---> Connect ----> try to read last service /characteristic (xxxx000002a19) click ---> it will ask Bluetooth pairing request ----> Enter the your password PIN as :: 177408 ---> If it PIN correct it read the characteristics values >>> NOTE >>> If you are not entering within 15 sec PIN then it will repeat the Step#3 until it success.

    Step#4 -> Now click on ---> DISCONNECT ----> Close the MAC tab ----> click / go to SCANNER ---> Refresh ---> You will see Black Box (Non-connectable) ---> It shows BLE information ----> Ery 30sec iBeacon advertisement displayed.

    And the below serial print logs can be seen.

    -------------------------------------------------------------------------------------
    637440
    => ..user_app_adv_start (FIRST).. <=
    => user_app_disconnect <=
    => ..user_app_adv_start (FIRST).. <=
    ......default_app_on_pairing_succeeded............
    => ..user_app_adv_start (FIRST).. <=
    => ..user_app_adv_start (SECOND).. <=(((.....user_app_adv_undirect_complete.....)))

    => ..ibeacon_adv_data_update_timer_cb (FIRST).. <=
    => ..acc_app_resume_system_from_sleep (1).. <=
    => ..user_app_adv_start_new (THREE).. <=
    => ..user_app_adv_start (SECOND).. <=
    => ..user_app_adv_start (SECOND).. <=(((.....user_app_adv_undirect_complete.....)))

    => ..ibeacon_adv_data_update_timer_cb (FIRST).. <=
    => ..acc_app_resume_system_from_sleep (1).. <=
    => ..user_app_adv_start_new (THREE).. <=
    => ..user_app_adv_start (SECOND).. <=
    => ..user_app_adv_start (SECOND).. <=(((.....user_app_adv_undirect_complete.....)))
    -------------------------------------------------------------------------------------

    Thanks,

    Kumar

  • Hi Renesas,

    Please let us know your feedback or suggestions.

    Regards,

    Kumar

  • Hi Kumar,

    Thank you for the replies and apologies for the delay.
    Let me look into this and I will get back to you as soon as possible.

    Best Regards,
    OV_Renesas

  • Hi Renesas,
    Thanks for your support.
    I am in a little hurry to deploy these beacons under the customer place. 
    Please check the flow and share your feedback to fix the rebooting issue.
    Regards,
    Kumar