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

pstorage example/issues

Does sample code exist for the pstorage module?

I am calling this code right before advertising_start() in the heart rate monitor application for the newest SDK. It doesn't seem to return from this function (from what I believe stem's from pstorage_clear(...)).

Can you spot any mistakes?

    static pstorage_handle_t       blockHandle;

void initFlash(void)
{
    

	uint32_t errCode;
    pstorage_handle_t       flashHandle;
    pstorage_module_param_t flashParam;

    

    errCode = pstorage_init();  //init the flash module API
    APP_ERROR_CHECK(errCode);



    flashParam.block_size  = PSTORAGE_MAX_BLOCK_SIZE;//sizeof(testresultstruct); //make a block the size of a test structure
    flashParam.block_count = 1;//MAX_NUMBER_OF_RESULTS; //give enough blocks to store 
    flashParam.cb          = flashCallBack;
        
    errCode = pstorage_register(&flashParam, &flashHandle);
    APP_ERROR_CHECK(errCode);



    errCode = pstorage_block_identifier_get( &flashHandle, 0, &blockHandle);
    APP_ERROR_CHECK(errCode);




    errCode = pstorage_clear(&flashHandle, NULL);
    APP_ERROR_CHECK(errCode);

}
Parents
  • Hi Ole,

    I am not seeing any error codes in the function I posted above, but I am getting an error code in:

    static void hrs_event_handler(ble_hrs_t * p_hrs, ble_hrs_evt_t * p_evt)
    {
        uint32_t err_code;
        
        switch(p_evt->evt_type)
        {
            case BLE_HRS_EVT_NOTIFICATION_ENABLED:     // Fall through
            case BLE_HRS_EVT_NOTIFICATION_DISABLED:
                
                // Try to store system attributes
                err_code = ble_bondmngr_sys_attr_store();
                if (err_code == NRF_SUCCESS)
                {
                    // System attribute store successfully requested.
                }
                else if (err_code == NRF_ERROR_INVALID_STATE)
                {
                    // System attributes already updated, cannot update again.
                }
                else
                {
                    APP_ERROR_HANDLER(err_code); //the error is being called from here
                }
                    
                break;
            default:            
                break;
        }
    }
    

    I believe the reason for this is because the heart rate application uses pstorage and when I init it for my own application it messes something up with the heart rate application. I was wondering how I could integrate with the pstorage implementation in the heart rate app?

    Would you know what I have to modify?

Reply
  • Hi Ole,

    I am not seeing any error codes in the function I posted above, but I am getting an error code in:

    static void hrs_event_handler(ble_hrs_t * p_hrs, ble_hrs_evt_t * p_evt)
    {
        uint32_t err_code;
        
        switch(p_evt->evt_type)
        {
            case BLE_HRS_EVT_NOTIFICATION_ENABLED:     // Fall through
            case BLE_HRS_EVT_NOTIFICATION_DISABLED:
                
                // Try to store system attributes
                err_code = ble_bondmngr_sys_attr_store();
                if (err_code == NRF_SUCCESS)
                {
                    // System attribute store successfully requested.
                }
                else if (err_code == NRF_ERROR_INVALID_STATE)
                {
                    // System attributes already updated, cannot update again.
                }
                else
                {
                    APP_ERROR_HANDLER(err_code); //the error is being called from here
                }
                    
                break;
            default:            
                break;
        }
    }
    

    I believe the reason for this is because the heart rate application uses pstorage and when I init it for my own application it messes something up with the heart rate application. I was wondering how I could integrate with the pstorage implementation in the heart rate app?

    Would you know what I have to modify?

Children
No Data
Related