/********************************************************************* * @fn gapRole_init * * @brief Initialization function for the GAP Role Task. * * @param none * * @return none */ static void gapRole_init(void) { // Register the current thread as an ICall dispatcher application // so that the application can send and receive messages. ICall_registerApp(&selfEntity, &sem); // Get link DB maximum number of connections linkDBNumConns = linkDB_NumConns(); // Setup timers as one-shot timers Util_constructClock(&startAdvClock, gapRole_clockHandler, 0, 0, false, START_ADVERTISING_EVT); Util_constructClock(&updateTimeoutClock, gapRole_clockHandler, 0, 0, false, CONN_PARAM_TIMEOUT_EVT); // Initialize the Profile Advertising and Connection Parameters gapRole_profileRole = GAP_PROFILE_PERIPHERAL | GAP_PROFILE_CENTRAL; VOID memset(gapRole_IRK, 0, KEYLEN); VOID memset(gapRole_SRK, 0, KEYLEN); gapRole_signCounter = 0; gapRole_AdvEventType = GAP_ADTYPE_ADV_IND; gapRole_AdvDirectType = ADDRTYPE_PUBLIC; gapRole_AdvChanMap = GAP_ADVCHAN_ALL; gapRole_AdvFilterPolicy = GAP_FILTER_POLICY_ALL; // Restore Items from NV VOID osal_snv_read(BLE_NVID_IRK, KEYLEN, gapRole_IRK); VOID osal_snv_read(BLE_NVID_CSRK, KEYLEN, gapRole_SRK); VOID osal_snv_read(BLE_NVID_SIGNCOUNTER, sizeof(uint32_t), &gapRole_signCounter); }
/** * @brief Central Profile Task initialization function. * * @param none * * @return none */ static void gapCentralRole_init(void) { // Register the current thread as an ICall dispatcher application // so that the application can send and receive messages. ICall_registerApp(&selfEntity, &sem); // Get link DB maximum number of connections linkDBNumConns = linkDB_NumConns(); // Initialize parameters // Restore items from NV VOID osal_snv_read(BLE_NVID_IRK, KEYLEN, gapCentralRoleIRK); VOID osal_snv_read(BLE_NVID_CSRK, KEYLEN, gapCentralRoleSRK); VOID osal_snv_read(BLE_NVID_SIGNCOUNTER, sizeof(uint32_t), &gapCentralRoleSignCounter); }