Example #1
0
/**@brief Function for initializing services that will be used by the application.
 *
 */
static void services_init(void)
{
    uint32_t       err_code;

    ble_dfu_init_t dfus_init;

    // Initialize the Device Firmware Update Service.
    memset(&dfus_init, 0, sizeof(dfus_init));

    dfus_init.evt_handler   = dfu_app_on_dfu_evt;
    dfus_init.error_handler = NULL;
    dfus_init.evt_handler   = dfu_app_on_dfu_evt;
    dfus_init.revision      = DFU_REVISION;

    err_code = ble_dfu_init(&m_dfus, &dfus_init);
    APP_ERROR_CHECK(err_code);

    dfu_app_reset_prepare_set(reset_prepare);
    dfu_app_dm_appl_instance_set(m_app_handle);

    // Initialize the Nordic Uart Service.
    ble_nus_init_t   nus_init;
    
    memset(&nus_init, 0, sizeof(nus_init));

    nus_init.data_handler = nus_data_handler;
    
    err_code = ble_nus_init(&m_nus, &nus_init);
    APP_ERROR_CHECK(err_code);

}
Example #2
0
static void services_init(void)
{
    uint32_t err_code;
    ble_nus_init_t nus_init;           //Nordic UART Service - for emulating a UART over BLE
    memset(&nus_init,0,sizeof(nus_init));
    
    nus_init.data_handler = BLEonReceive;
    
    err_code = ble_nus_init(&m_nus, &nus_init);
    BLE_ERROR_CHECK(err_code);
    
    
    /*
    ble_bas_init_t bas_init;           //Battery service  (part of BLE standard)
    memset(&bas_init,0,sizeof(bas_init));

    bas_init.evt_handler          = NULL;
    bas_init.support_notification = false;
    bas_init.p_report_ref         = NULL;
    bas_init.initial_batt_level   = 100;

    err_code = ble_bas_init(&m_bas, &bas_init);
    BLE_ERROR_CHECK(err_code);
    */
    
}
Example #3
0
static void services_init(void){
    uint32_t       err_code;
    ble_bas_init_t bas_init;
    ble_nus_init_t nus_init;
	
    /* Initialize Battery Service */
    memset(&bas_init, 0, sizeof(bas_init));

    /* Here the sec level for the Battery Service can be changed/increased. */
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.cccd_write_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_char_attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&bas_init.battery_level_char_attr_md.write_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&bas_init.battery_level_report_read_perm);

    bas_init.evt_handler          = NULL;
    bas_init.support_notification = true;
    bas_init.p_report_ref         = NULL;
    bas_init.initial_batt_level   = 0;

    err_code = ble_bas_init(&m_bas, &bas_init);
    APP_ERROR_CHECK(err_code);

    //Initialize nordic UART service
    memset(&nus_init, 0, sizeof(nus_init));

    nus_init.data_handler = nus_data_handler;

    err_code = ble_nus_init(&m_nus, &nus_init);
    APP_ERROR_CHECK(err_code);
}
Example #4
0
void services_init (void) {
  uint32_t err_code;
  ble_nus_init_t nus_init;
  memset(&nus_init, 0, sizeof(nus_init));
  nus_init.data_handler = nus_data_handler;
  err_code = ble_nus_init(&m_nus, &nus_init);
  APP_ERROR_CHECK(err_code);
}
Example #5
0
/**@brief Initialize services that will be used by the application.
 */
static void services_init(void)
{
    uint32_t err_code;
    static ble_nus_init_t nus_init;
    
    memset(&nus_init, 0, sizeof nus_init);
    nus_init.data_handler = commandAPI_handler;
    
    err_code = ble_nus_init(&m_nus, &nus_init);
    APP_ERROR_CHECK(err_code);
}
void BLETransceiver::servicesInit(void)
{
	uint32_t         err_code;
	ble_nus_init_t   nus_init;

	memset(&nus_init, 0, sizeof(nus_init));

	nus_init.data_handler.ble_nus_data_cb = (ble_nus_data_cb_t)&onBLERX;
	nus_init.data_handler.ble_nus_data_cb_payload = (void*)this;

	/** initialize UART service */
	err_code = ble_nus_init(&nus, &nus_init);
	APP_ERROR_CHECK(err_code);
}
Example #7
0
/**@brief Function for initializing services that will be used by the application.
 */
void services_init(void)
{
    uint32_t       err_code;
    ble_nus_init_t nus_init;

    memset(&nus_init, 0, sizeof(nus_init));

    nus_init.data_handler = nus_data_handler;

    err_code = ble_nus_init(&m_nus, &nus_init);
    APP_ERROR_CHECK(err_code);

    m_nus_data = malloc(sizeof(uint8_t) * BLE_NUS_MAX_DATA_LEN);
}
Example #8
0
/**@brief Function for initializing services that will be used by the application.
 */
static void services_init(void)
{
    uint32_t       err_code;
    ble_nus_init_t nus_init;
#if ENABLE_NEW_SERVECE
    new_service_nus_init_t nus_init_2;
    memset(&nus_init_2, 0, sizeof(nus_init_2));
#endif
    memset(&nus_init, 0, sizeof(nus_init));

    nus_init.data_handler = nus_data_handler;  
    err_code = ble_nus_init(&m_nus, &nus_init);
    APP_ERROR_CHECK(err_code);
#if ENABLE_NEW_SERVECE
    nus_init_2.data_handler = new_serve_nus_data_handler;
    err_code = new_server_nus_init(&new_m_nus, &nus_init_2);
    APP_ERROR_CHECK(err_code);
#endif

#ifdef BLE_DFU_APP_SUPPORT
    /** @snippet [DFU BLE Service initialization] */
    ble_dfu_init_t   dfus_init;

    // Initialize the Device Firmware Update Service.
    memset(&dfus_init, 0, sizeof(dfus_init));

    dfus_init.evt_handler   = dfu_app_on_dfu_evt;
    dfus_init.error_handler = NULL;
    dfus_init.evt_handler   = dfu_app_on_dfu_evt;
    dfus_init.revision      = DFU_REVISION;

    err_code = ble_dfu_init(&m_dfus, &dfus_init);
    APP_ERROR_CHECK(err_code);

    dfu_app_reset_prepare_set(reset_prepare);
    dfu_app_dm_appl_instance_set(m_app_handle);
    /** @snippet [DFU BLE Service initialization] */
#endif // BLE_DFU_APP_SUPPORT

}