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

nrf51822 can't sleep

my project can't goto sysoff mode, (desktop2)( project based on mouse demo)

m_prw_mgmt_set_sysoff_timeout(DEFAULT_BTLE_INACTIVITY_DISCONNECT_PERIOD);//can't sleep here!

my code.DEFAULT_BTLE_INACTIVITY_DISCONNECT_PERIOD //10s The default: 1hour

when timeout,system goto off,

m_coms_ble_wakeup_prepare

goto↓

m_coms_ble_disable

goto↓

/ /Save bond information to flash
    err_code = ble_bondmngr_bonded_centrals_store();
    APP_ERROR_CHECK(err_code);

goto↓

// Save System Attributes, if changed.
if(sys_attr_changed())//==1

M_cmd_queue.conut change "1" from "0"

:goto↓

pstorage_access_wait()

do
    {
             app_sched_execute();        
               err_code = pstorage_access_status_get(&count);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }        
    }
    while(count != 0);//***can't pass***

my steps:

1, download the hex 2, power on mouse 3, try to connect 4, not found any host
5, connect timeout 6, error

: System Attributes in RAM is different from that in flash.

is this ↑cause the proble? how to fix it?

Parents
    1. The issue is caused by a global variable from Desktop 2 v2.2.1 not initialized and hence result in FW triggering a flash erase command due to sys_attr_changed() function returning incorrect status.

    To fix this issue we need to add 1 line of code (!!!!!!!!!!) in ble_bondmngr_init() function @ ble_bondmngr.c file:

    /*********************************************************************/ uint32_t ble_bondmngr_init(ble_bondmngr_init_t

    • p_init) { pstorage_module_param_t param; uint32_t err_code;

      if (p_init->error_handler == NULL) { return NRF_ERROR_INVALID_PARAM; }

      if (BLE_BONDMNGR_MAX_BONDED_CENTRALS > MAX_BONDS_IN_FLASH) { return NRF_ERROR_DATA_SIZE; } : : :

      m_central.bond.central_handle = INVALID_CENTRAL_HANDLE; m_conn_handle = BLE_CONN_HANDLE_INVALID; m_centrals_in_db_count = 0; m_bond_info_in_flash_count = 0; m_sys_attr_in_flash_count = 0;

      m_crc_sys_attr = crc16_compute( NULL, 0, NULL );//!!!!!!!!!!

    SECURITY_STATUS_RESET();

    : : : } /**********************************************************************/

    This will initialize the global variable “m_crc_sys_attr” and prevent “sys_attr_changed() function from returning incorrect status.

    1. It is also inappropriate for customer to set the DEFAULT_BLE_INACTIVITY_DISCONNECT_PERIOD to be shorter then advertising timeout period. Customer should configure this inactivity period to expire after BLE advertising has timeout and system is really idle.
  • I cannot seem to reproduce the issue you are seeing wrt. to bonding information. I've tested it with MasterControlPanel, and the CRC/m_crc_sys_attr is correctly calculated at my end, causing no erase-operation.

    1. Are you testing with an unchanged example? If not, do you see the same behavior then?
    2. What central are you connecting to? Win8/android/iOS?
Reply Children
No Data
Related