I'm currently facing a problem while using FreeRTOS.
I've created a task, but that tasks freezes the board at this line :
for (int i = 0; i < currentEncounters_number; i++) {
ble_gap_addr_t addr;
memcpy(addr.addr, currentEncounters[i].addr, 6); //Code breaks here!
/* Check if address is valid */
if (!isAddrValid(addr)) {
NRF_LOG_INFO("INVALD ADDRESS - on Current Encounters");
continue;
}
}without FreeRTOS this piece of code works perfectly. A few things :
- addr is defined Localy
- currentEncounters is defined globaly
I tried to follow the ble_app_hrs_freertos code in order to build this task (I have two of them, one scanner and one advertising)
My frist question in the advertising would be: is this right?
and finally, this is the scanner code (the problem is happening here) :
I tried to follow the ble_app_hrs_freertos code in order to build this task (I have two of them, one scanner and one advertising)
/* Original Code */
/**@brief Function for starting advertising. */
static void advertising_start(void * p_erase_bonds)
{
bool erase_bonds = *(bool*)p_erase_bonds;
if (erase_bonds)
{
delete_bonds();
// Advertising is started by PM_EVT_PEERS_DELETE_SUCCEEDED event.
}
else
{
ret_code_t err_code = ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST);
APP_ERROR_CHECK(err_code);
}
}
nrf_sdh_freertos_init(advertising_start, &erase_bonds);
/* my Code */
/** @brief Function for starting advertising. */
void startAdvertising() {
/* Create a FreeRTOS task for the BLE stack. */
nrf_sdh_freertos_init(taskAdvertising, NULL);
}
/** @brief task for start Advertising */
static void taskAdvertising() {
/* Declaration of Error Code */
ret_code_t err_code;
/* Start advertising */
err_code = sd_ble_gap_adv_start(m_adv_handle, APP_BLE_CONN_CFG_TAG);
APP_ERROR_CHECK(err_code);
}My frist question in the advertising would be: is this right?
and finally, this is the scanner code (the problem is happening here) :
static void taskScanner() {
/* Declare Error Code */
ret_code_t err_code;
/* Stop Scanner if running*/
(void)sd_ble_gap_scan_stop();
/* Start Scanner */
err_code = sd_ble_gap_scan_start(&m_scan_param, &m_scan_buffer);
if (err_code != NRF_ERROR_INVALID_STATE) {
APP_ERROR_CHECK(err_code);
}
}
/** @brief Function for initializing the scanning. */
void startScanner() {
nrf_sdh_freertos_init(taskScanner, NULL);
}Thank you for your time!