uint32_t ble_nus_init(ble_nus_t * p_nus, const ble_nus_init_t * p_nus_init) { uint32_t err_code; ble_uuid_t ble_uuid; ble_uuid128_t nus_base_uuid = {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}}; if ((p_nus == NULL) || (p_nus_init == NULL)) { return NRF_ERROR_NULL; } // Initialize service structure. p_nus->conn_handle = BLE_CONN_HANDLE_INVALID; p_nus->data_handler = p_nus_init->data_handler; p_nus->is_notification_enabled = false; /**@snippet [Adding proprietary Service to S110 SoftDevice] */ // Add custom base UUID. err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type); if (err_code != NRF_SUCCESS) { return err_code; } ble_uuid.type = p_nus->uuid_type; ble_uuid.uuid = BLE_UUID_NUS_SERVICE; // Add service. err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_nus->service_handle); /**@snippet [Adding proprietary Service to S110 SoftDevice] */ if (err_code != NRF_SUCCESS) { return err_code; } // Add RX Characteristic. err_code = rx_char_add(p_nus, p_nus_init); if (err_code != NRF_SUCCESS) { return err_code; } // Add TX Characteristic. err_code = tx_char_add(p_nus, p_nus_init); if (err_code != NRF_SUCCESS) { return err_code; } return NRF_SUCCESS; }
uint32_t ble_lss_init(ble_lss_t * p_lss, const ble_lss_init_t * p_lss_init) { uint32_t err_code; ble_uuid_t ble_uuid; ble_uuid128_t lss_base_uuid = LSS_BASE_UUID; if ((p_lss == NULL) || (p_lss_init == NULL)) { return NRF_ERROR_NULL; } // Initialize the service structure. p_lss->conn_handle = BLE_CONN_HANDLE_INVALID; p_lss->data_handler = p_lss_init->data_handler; p_lss->is_notification_enabled = false; /**@snippet [Adding proprietary Service to S110 SoftDevice] */ // Add a custom base UUID. err_code = sd_ble_uuid_vs_add(&lss_base_uuid, &p_lss->uuid_type); if (err_code != NRF_SUCCESS) { return err_code; } ble_uuid.type = p_lss->uuid_type; ble_uuid.uuid = BLE_UUID_LSS_SERVICE; // Add the service. err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_lss->service_handle); /**@snippet [Adding proprietary Service to S110 SoftDevice] */ if (err_code != NRF_SUCCESS) { return err_code; } // Add the RX Characteristic. err_code = rx_char_add(p_lss, p_lss_init); if (err_code != NRF_SUCCESS) { return err_code; } // Add the TX Characteristic. err_code = tx_char_add(p_lss, p_lss_init); if (err_code != NRF_SUCCESS) { return err_code; } return NRF_SUCCESS; }
uint32_t ble_dfu_init(ble_dfu_t * p_dfu, const ble_dfu_init_t * p_dfu_init) { uint32_t err_code; ble_uuid_t ble_uuid; ble_uuid128_t nus_base_uuid = BLE_DFU_BASE_UUID; VERIFY_PARAM_NOT_NULL(p_dfu); VERIFY_PARAM_NOT_NULL(p_dfu_init); p_m_dfu = p_dfu; // TODO: find a nicer solution to this // Initialize the service structure. p_dfu->conn_handle = BLE_CONN_HANDLE_INVALID; p_dfu->evt_handler = p_dfu_init->evt_handler; p_dfu->is_waiting_for_disconnection = false; p_dfu->is_ctrlpt_notification_enabled = false; /**@snippet [Adding proprietary Service to S110 SoftDevice] */ // Add a custom base UUID. err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_dfu->uuid_type); VERIFY_SUCCESS(err_code); ble_uuid.type = p_dfu->uuid_type; ble_uuid.uuid = BLE_UUID_DFU_SERVICE; // Add the service. err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_dfu->service_handle); /**@snippet [Adding proprietary Service to S110 SoftDevice] */ VERIFY_SUCCESS(err_code); // Add the RX Characteristic. err_code = rx_char_add(p_dfu, p_dfu_init); VERIFY_SUCCESS(err_code); err_code = nrf_dfu_flash_init(true); VERIFY_SUCCESS(err_code); nrf_dfu_settings_init(); return NRF_SUCCESS; }
uint32_t ble_nus_init(ble_nus_t * p_nus, const ble_nus_init_t * p_nus_init) { uint32_t err_code; ble_uuid_t ble_uuid; ble_uuid128_t nus_base_uuid = NUS_BASE_UUID; if ((p_nus == NULL) || (p_nus_init == NULL)) { return NRF_ERROR_NULL; } // Initialize the service structure. p_nus->conn_handle = BLE_CONN_HANDLE_INVALID; p_nus->data_handler = p_nus_init->data_handler; p_nus->is_notification_enabled = false; /**@snippet [Adding proprietary Service to S110 SoftDevice] */ // Add a custom base UUID. err_code = sd_ble_uuid_vs_add(&nus_base_uuid, &p_nus->uuid_type); if (err_code != NRF_SUCCESS) { return err_code; } ble_uuid.type = p_nus->uuid_type; ble_uuid.uuid = BLE_UUID_NUS_SERVICE; // Add the service. err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_nus->service_handle); //#if ((DEBUG_UART_EN) && (ENABLE_BLE_DEBUG)) // DbgPrintf("service1_handle=%x\r\n",p_nus->service_handle); //#endif /**@snippet [Adding proprietary Service to S110 SoftDevice] */ if (err_code != NRF_SUCCESS) { return err_code; } // Add the TX Characteristic. err_code = tx_char_add(p_nus, p_nus_init); if (err_code != NRF_SUCCESS) { return err_code; } // Add the RX Characteristic. err_code = rx_char_add(p_nus, p_nus_init); if (err_code != NRF_SUCCESS) { return err_code; } #if(ENABLE_OLD_UUID==0) // Add the TX2 Characteristic. /* err_code = tx2_char_add(p_nus, p_nus_init); if (err_code != NRF_SUCCESS) { return err_code; } // Add the RX2 Characteristic. err_code = rx2_char_add(p_nus, p_nus_init); if (err_code != NRF_SUCCESS) { return err_code; }*/ #endif return NRF_SUCCESS; }