I cannot seem to get pstorage working using the S210 softdevice. I can get it to work using the S130. I was not able to find any info on pstorage using S210.
I used the example here :
When trying to use it with ant, the problem as traced back to the softdevice_sys_evt_handler_set. That seems to require softdevice_handler.h. When I include this with all its dependencies, I get an error because it needs ble.h and I cannot include that when using the S210 (I tried it with S310 too)
I then tried using softdevice_ant_evt_handler_set, and just including "ant_stack_handler_type.h" but there is a type mismatch.
I can't get the the softdevice_sys_evt_handler_set(sys_evt_dispatch) to work because of the ble.h requirement.
Is there a good example on setting up the event handler properly for the S210? I cannot seem to get it to work with the S210.
//TEST CODE BEGIN/
#include "pstorage.h"
//#include "ant_stack_handler_types.h"
#include "softdevice_handler.h"
static uint8_t ps_flag = 0;
uint8_t test_data[4] __attribute__((aligned(4)));
uint8_t test_data[4] = {0x01,0x02,0x03,0x04};
static void sys_evt_dispatch(uint32_t sys_evt)
{
pstorage_sys_event_handler(sys_evt);
}
static void softdevice_setup(void)
{
uint32_t err_code;
err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback);
APP_ERROR_CHECK(err_code);
// Configure application-specific interrupts.
// Set application IRQ to lowest priority and
// enable application IRQ (triggered from ANT protocol stack)
err_code = sd_nvic_SetPriority(SD_EVT_IRQn, NRF_APP_PRIORITY_LOW);
APP_ERROR_CHECK(err_code);
err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn);
APP_ERROR_CHECK(err_code);
err_code = softdevice_ant_evt_handler_set(sys_evt_dispatch);
APP_ERROR_CHECK(err_code);
// If I replace softdevice_ant_evt_handler_set(sys_evt_dispatch)
//with softdevice_sys_evt_handler_set(sys_evt_dispatch)
//it still does not work because of the ble.h requirement
}
static void dm_pstorage_cb_handler(pstorage_handle_t * p_handle,
uint8_t op_code,
uint32_t result,
uint8_t * p_data,
uint32_t data_len)
{
switch(op_code)
{
case PSTORAGE_ERROR_OP_CODE:
ps_flag = 1;
break;
case PSTORAGE_STORE_OP_CODE:
ps_flag = 2;
break;
case PSTORAGE_LOAD_OP_CODE:
ps_flag = 3;
break;
case PSTORAGE_CLEAR_OP_CODE:
ps_flag = 4;
break;
case PSTORAGE_UPDATE_OP_CODE:
ps_flag = 5;
break;
default:
ps_flag = 6;
break;
}
}
static void pstorage_test(void)
{
pstorage_module_param_t flashparam;
pstorage_handle_t flashhandle;
pstorage_handle_t flash_block_handle;
uint32_t retval;
flashparam.block_size = 20;
flashparam.block_count = 1;
flashparam.cb = dm_pstorage_cb_handler;
retval = pstorage_init();
retval = pstorage_register(&flashparam, &flashhandle);
retval = pstorage_clear(&flashhandle, 20);
retval = pstorage_block_identifier_get(&flashhandle, 0, &flash_block_handle);
retval = pstorage_store(&flash_block_handle, test_data, 4, 0);
retval = pstorage_block_identifier_get(&flashhandle, 0, &flash_block_handle);
uint8_t load_data[4];
retval = pstorage_load(load_data, &flash_block_handle, 4, 0);
while(ps_flag == 0);
ps_flag = 0;
if (retval == NRF_SUCCESS)
{
if ((load_data[0] == 0x01)&(load_data[1] == 0x02)&(load_data[2] == 0x03)&(load_data[3] == 0x04))
{
ps_flag = 100;
}
}
}
// Test code end
Here is the error when I include softdevice_handler.h
C:...\softdevice_handler\ble_stack_handler_types.h(28): error: #5: cannot open source input file "ble.h": No such file or directory #include "ble.h"
This is because it is Ant and not BLE. Any suggestions on how to incoporate the softdevice_ant_evt_handler_set(sys_evt_dispatch); using S210?
Thanks!