uint32_t iot_context_manager_table_free(const iot_interface_t * p_interface) { VERIFY_MODULE_IS_INITIALIZED(); NULL_PARAM_CHECK(p_interface); uint32_t err_code = NRF_SUCCESS; CM_ENTRY(); SDK_MUTEX_INIT(m_iot_context_manager_mutex); CM_MUTEX_LOCK(); const uint32_t table_id = context_table_find(p_interface); if (table_id != IOT_CONTEXT_MANAGER_MAX_TABLES) { // Clear context table. CM_TRC("Found context table assigned to interface."); context_table_init(table_id); } else { // No free context table found. CM_ERR("No context table found."); err_code = (NRF_ERROR_NOT_FOUND | IOT_CONTEXT_MANAGER_ERR_BASE); } CM_MUTEX_UNLOCK(); CM_EXIT(); return err_code; }
uint32_t nrf_mem_init(void) { NRF_LOG_DEBUG("[MM]: >> nrf_mem_init.\r\n"); SDK_MUTEX_INIT(m_mm_mutex); MM_MUTEX_LOCK(); uint32_t block_index = 0; for (block_index = 0; block_index < TOTAL_BLOCK_COUNT; block_index++) { block_init(block_index); } #if (MEM_MANAGER_DISABLE_API_PARAM_CHECK == 0) m_module_initialized = true; #endif // MEM_MANAGER_DISABLE_API_PARAM_CHECK #ifdef MEM_MANAGER_ENABLE_DIAGNOSTICS nrf_mem_diagnose(); #endif // MEM_MANAGER_ENABLE_DIAGNOSTICS MM_MUTEX_UNLOCK(); NRF_LOG_DEBUG("[MM]: << nrf_mem_init.\r\n"); return NRF_SUCCESS; }
uint32_t ipv6_init(const ipv6_init_t * p_init) { uint32_t index; uint32_t err_code; ble_6lowpan_init_t init_params; NULL_PARAM_CHECK(p_init); NULL_PARAM_CHECK(p_init->p_eui64); NULL_PARAM_CHECK(p_init->event_handler); SDK_MUTEX_INIT(m_ipv6_mutex); IPV6_MUTEX_LOCK(); IPV6_ENTRY(); // Initialize related modules. UNUSED_VARIABLE(nrf_mem_init()); UNUSED_VARIABLE(iot_pbuffer_init()); // Initialize submodules of IPv6 stack. UNUSED_VARIABLE(udp_init()); UNUSED_VARIABLE(icmp6_init()); // Initialize context manager. UNUSED_VARIABLE(iot_context_manager_init()); IPV6_ADDRESS_INITIALIZE(IPV6_ADDR_ANY); // Set application event handler. m_event_handler = p_init->event_handler; // Clear number of interfaces. m_interfaces_count = 0; // Clear network interfaces. for (index = 0; index < IPV6_MAX_INTERFACE; index++) { interface_reset(&m_interfaces[index]); } // Clear all addresses. for (index = 0; index < IPV6_MAX_ADDRESS_COUNT; index++) { addr_free(index, false); } // 6LoWPAN module initialization. init_params.p_eui64 = p_init->p_eui64; init_params.event_handler = ble_6lowpan_evt_handler; err_code = ble_6lowpan_init(&init_params); IPV6_EXIT(); IPV6_MUTEX_UNLOCK(); return err_code; }
uint32_t icmp6_init(void) { SDK_MUTEX_INIT(m_ipv6_mutex); SDK_MUTEX_LOCK(); ICMP6_TRC("[ICMP6]: >> icmp6_init\r\n"); // Set application event handler. m_event_handler = NULL; // Indicate initialization of module. m_initialization_state = true; ICMP6_TRC("[ICMP6]: << icmp6_init\r\n"); SDK_MUTEX_UNLOCK(); return NRF_SUCCESS; }
uint32_t iot_context_manager_init(void) { uint32_t index; CM_ENTRY(); SDK_MUTEX_INIT(m_iot_context_manager_mutex); CM_MUTEX_LOCK(); for (index = 0; index < IOT_CONTEXT_MANAGER_MAX_TABLES; index++) { context_table_init(index); } m_initialization_state = true; CM_MUTEX_UNLOCK(); CM_EXIT(); return NRF_SUCCESS; }
uint32_t lwm2m_init(void) { SDK_MUTEX_INIT(m_coap_mutex); LWM2M_MUTEX_LOCK(); uint32_t err_code; err_code = internal_lwm2m_register_init(); if (err_code != NRF_SUCCESS) { LWM2M_MUTEX_UNLOCK(); return err_code; } err_code = internal_lwm2m_bootstrap_init(); if (err_code != NRF_SUCCESS) { LWM2M_MUTEX_UNLOCK(); return err_code; } err_code = coap_error_handler_register(coap_error_handler); if (err_code != NRF_SUCCESS) { LWM2M_MUTEX_UNLOCK(); return err_code; } internal_coap_handler_init(); err_code = coap_request_handler_register(lwm2m_coap_handler_handle_request); LWM2M_MUTEX_UNLOCK(); return err_code; }