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

pm_peer_new() causing "PM_EVT_ERROR_UNEXPECTED"

Hi,

I want to add new peer to peer manager using pm_peer_new().

pm_peer_id_t p1 = 0;

pm_peer_new(&p1,&bond_info,NULL);

there are no peers, so trying to add as peer_id 0. but this causing "PM_EVT_ERROR_UNEXPECTED" error in pm_evt_handler() function.

bond_info is filled with information.

Parents Reply Children
  • void peer_add()
    {
    memcpy(&bondData,samsung,sizeof(pm_peer_data_bonding_t));
    //bRet = peer_is_irk(&bondData.peer_ble_id.id_info);
    APP_ERROR_CHECK(pm_peer_new(&p1,&bondData,NULL));


    }

    static bool bFDSInitialized = false;

    static void fds_evt_handler(fds_evt_t const * const p_evt)
    {
        if (p_evt->id == FDS_EVT_GC)
        {
           NRF_LOG_DEBUG("GC completed\n");
        }
        else if(p_evt->id == FDS_EVT_INIT)
        { 
           bFDSInitialized = true;
        }
    }

    #include "nrf_delay.h"
    /**@brief Function for application main entry.
    */
    int main(void)
    {
    bool erase_bonds;

    // Initialize.
    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    power_management_init();
    ble_stack_init();
    scheduler_init();
    gap_params_init();
    gatt_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();
    peer_manager_init();
    //nrf_delay_ms(25000);

    // Start execution.
    NRF_LOG_INFO("HID Mouse example started.");
    timers_start();
    advertising_start(erase_bonds);
    bool bOnce = true;
    /* for (int i=0;i<100000;i++)
    {
    app_sched_execute();
    }*/
    while(!bFDSInitialized)
    {
    app_sched_execute();
    }
    nrf_delay_ms(200);

    //Testing
    peer_add();

    // Enter main loop.
    for (;;)
    {

    idle_state_handle();
    }
    }

  • Thanks for posting the code. 'bFDSInitialized ' should be declared 'volatile'. Can you try that? 

Related