• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ sd_ble_gatts_service_add函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中sd_ble_gatts_service_add函数的典型用法代码示例。如果您正苦于以下问题:C++ sd_ble_gatts_service_add函数的具体用法?C++ sd_ble_gatts_service_add怎么用?C++ sd_ble_gatts_service_add使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sd_ble_gatts_service_add函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ble_bas_init

uint32_t ble_bas_init(ble_bas_t * p_bas, const ble_bas_init_t * p_bas_init)
{
    if (p_bas == NULL || p_bas_init == NULL)
    {
        return NRF_ERROR_NULL;
    }

    uint32_t   err_code;
    ble_uuid_t ble_uuid;

    // Initialize service structure
    p_bas->evt_handler               = p_bas_init->evt_handler;
    p_bas->conn_handle               = BLE_CONN_HANDLE_INVALID;
    p_bas->is_notification_supported = p_bas_init->support_notification;
    p_bas->battery_level_last        = INVALID_BATTERY_LEVEL;

    // Add service
    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BATTERY_SERVICE);

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_bas->service_handle);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    // Add battery level characteristic
    return battery_level_char_add(p_bas, p_bas_init);
}
开发者ID:etx,项目名称:Espruino,代码行数:28,代码来源:ble_bas.c


示例2: initBlePHYSEN

uint32_t initBlePHYSEN(ble_pss_t * p_pss, const ble_pss_init_t * p_pss_init)
{   /// init BLE physical sensor service
    uint32_t   err_code;
    ble_uuid_t ble_uuid;

    // initialize service structure
    p_pss->evt_handler               = p_pss_init->evt_handler;
    p_pss->conn_handle               = BLE_CONN_HANDLE_INVALID;
    p_pss->is_notification_supported = p_pss_init->support_notification;

    // add service
    ble_uuid128_t base_uuid= {PHY_SENSOR_UUID_BASE};
    err_code = sd_ble_uuid_vs_add(&base_uuid, &p_pss->uuid_type);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    ble_uuid.type = p_pss->uuid_type;
    ble_uuid.uuid = BLE_UUID_PHY_SENSOR_SERVICE;

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_pss->service_handle);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    // Add physics sensor characteristic
    return addCharPHYSEN(p_pss, p_pss_init);
}
开发者ID:jonguillemette,项目名称:Sensor_Embedded,代码行数:30,代码来源:ble_phy.c


示例3: ble_qodome_init

uint32_t ble_qodome_init(void)
{
    uint32_t   err_code;
    ble_uuid_t ble_uuid;
    // Initialize service structure
    ble_qodome_t  * p_qodome = &m_qodome;

    p_qodome->conn_handle = BLE_CONN_HANDLE_INVALID;
    // Add service
    BLE_UUID_BLE_ASSIGN(ble_uuid, QODOME_PUBLIC_SERVICE);

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_qodome->service_handle);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
    // Add memory dump characteristic
    err_code = hts_qodome_char_add(p_qodome);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    return NRF_SUCCESS;
}
开发者ID:qodome,项目名称:Firmware,代码行数:25,代码来源:ble_qodome_public.c


示例4: cch_service_init

void cch_service_init(ble_cch_t * p_cch_service)
{
    uint32_t   err_code; // Variable to hold return codes from library and softdevice functions

    //Declare 16-bit service and 128-bit base UUIDs and add them to the BLE stack
    ble_uuid_t        service_uuid;
    ble_uuid128_t     base_uuid = BLE_UUID_CCH_BASE_UUID;
    
		service_uuid.uuid = BLE_UUID_CCH_SERVICE_UUID;
    err_code = sd_ble_uuid_vs_add(&base_uuid, &service_uuid.type);
    APP_ERROR_CHECK(err_code);    
    
    // Set our service connection handle to default value. I.e. an invalid handle since we are not yet in a connection.
    p_cch_service->conn_handle = BLE_CONN_HANDLE_INVALID;

    // Add our service
    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                        &service_uuid,
                                        &p_cch_service->service_handle);
    
    APP_ERROR_CHECK(err_code);
    
    // Call the function our_char_add() to add our new characteristic to the service. 
    cch_char_add(p_cch_service);
}
开发者ID:stelios26,项目名称:Julius,代码行数:25,代码来源:stepper.c


示例5: mesh_gatt_init

/*****************************************************************************
 * Interface functions
 *****************************************************************************/
uint32_t mesh_gatt_init(uint32_t access_address, uint8_t channel,
		uint32_t interval_min_ms) {
	uint32_t error_code;
	mesh_metadata_char_t md_char;
	md_char.mesh_access_addr = access_address;
	md_char.mesh_interval_min_ms = interval_min_ms;
	md_char.mesh_channel = channel;

	ble_uuid_t ble_srv_uuid;
	ble_srv_uuid.type = BLE_UUID_TYPE_BLE;
	ble_srv_uuid.uuid = MESH_SRV_UUID;

	error_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
			&ble_srv_uuid, &m_mesh_service.service_handle);
	if (error_code != NRF_SUCCESS) {
		return NRF_ERROR_INTERNAL;
	}

	error_code = sd_ble_uuid_vs_add(&m_mesh_base_uuid, &m_mesh_base_uuid_type);
	if (error_code != NRF_SUCCESS) {
		return error_code;
	}

	error_code = mesh_md_char_add(&md_char);
	if (error_code != NRF_SUCCESS) {
		return error_code;
	}

	error_code = mesh_value_char_add();
	if (error_code != NRF_SUCCESS) {
		return error_code;
	}

	return NRF_SUCCESS;
}
开发者ID:AlexDM0,项目名称:bluenet,代码行数:38,代码来源:mesh_gatt.c


示例6: ble_bps_init

uint32_t ble_bps_init(ble_bps_t * p_bps, const ble_bps_init_t * p_bps_init)
{
    uint32_t   err_code;
    ble_uuid_t ble_uuid;

    // Initialize service structure
    p_bps->evt_handler = p_bps_init->evt_handler;
    p_bps->conn_handle = BLE_CONN_HANDLE_INVALID;
    p_bps->feature     = p_bps_init->feature;

    // Add service
    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BLOOD_PRESSURE_SERVICE);

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_bps->service_handle);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
    
    // Add measurement characteristic
    err_code = bps_measurement_char_add(p_bps, p_bps_init);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
    
    // Add feature characteristic
    err_code = bps_feature_char_add(p_bps, p_bps_init);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
    
    return NRF_SUCCESS;
}
开发者ID:451506709,项目名称:automated_machine,代码行数:35,代码来源:ble_bps.c


示例7: ble_lbs_init

uint32_t ble_lbs_init(ble_lbs_t * p_lbs, const ble_lbs_init_t * p_lbs_init)
{
    uint32_t   err_code;
    ble_uuid_t ble_uuid;

    // Initialize service structure.
    p_lbs->conn_handle       = BLE_CONN_HANDLE_INVALID;
    p_lbs->led_write_handler = p_lbs_init->led_write_handler;

    // Add service.
    ble_uuid128_t base_uuid = {LBS_UUID_BASE};
    err_code = sd_ble_uuid_vs_add(&base_uuid, &p_lbs->uuid_type);
    VERIFY_SUCCESS(err_code);

    ble_uuid.type = p_lbs->uuid_type;
    ble_uuid.uuid = LBS_UUID_SERVICE;

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_lbs->service_handle);
    VERIFY_SUCCESS(err_code);

    // Add characteristics.
    err_code = button_char_add(p_lbs, p_lbs_init);
    VERIFY_SUCCESS(err_code);

    err_code = led_char_add(p_lbs, p_lbs_init);
    VERIFY_SUCCESS(err_code);

    return NRF_SUCCESS;
}
开发者ID:etx,项目名称:Espruino,代码行数:29,代码来源:ble_lbs.c


示例8: ble_achs_init

uint32_t ble_achs_init(ble_achs_t * p_achs, const ble_achs_init_t * p_achs_init)
{
    VERIFY_NOT_NULL_PARAM(p_achs);
    VERIFY_NOT_NULL_PARAM(p_achs_init);

    uint32_t   err_code;
    ble_uuid_t service_uuid;

    // Invalidate any previous existing connection handle.
    p_achs->conn_handle = BLE_CONN_HANDLE_INVALID;

    service_uuid.uuid = LOCAL_SERVICE_UUID;

    err_code = sd_ble_uuid_vs_add(&m_base_uuid128, &service_uuid.type);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &service_uuid, &m_service_handle);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    err_code = ach_report_char_add(service_uuid.type);

    if (err_code == NRF_SUCCESS)
    {
        m_module_initialized = true;
    }

    return err_code;
}
开发者ID:451506709,项目名称:automated_machine,代码行数:34,代码来源:ble_controllable_hub.c


示例9: ble_acc_init

uint32_t ble_acc_init(ble_acc_t * p_acc, const ble_acc_init_t * p_acc_init)
{
    uint32_t   err_code;
    ble_uuid_t ble_uuid;
    ble_uuid128_t acc_acce_uuid = {{0xAA, 0xCA, 0x55, 0xAC, 0xEE, 0xEF, 0xFE, 0xDE, 0xEE, 0xAF, 0xBE, 0xA0, 0x00, 0x00, 0xA0, 0xEF}}; //nb bytes 12 and 13 are ignored

    // Initialize service structure
    p_acc->evt_handler               = p_acc_init->evt_handler;
    p_acc->conn_handle               = BLE_CONN_HANDLE_INVALID;
    p_acc->is_notification_supported = p_acc_init->support_notification;
    p_acc->accel_level_last        = INVALID_accel_LEVEL;

    // Add service
    // Add uuid to p_acc struct and add to sd stack
    err_code = sd_ble_uuid_vs_add(&acc_acce_uuid, &p_acc->uuid_type);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    ble_uuid.type = p_acc->uuid_type;
    ble_uuid.uuid = BLE_UUID_TYPE_VENDOR_BEGIN;

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_acc->service_handle);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    // Add accel level characteristic
    return accel_level_char_add(p_acc, p_acc_init);
}
开发者ID:AveryLouie,项目名称:flashware,代码行数:32,代码来源:ble_accel_svc.c


示例10: conn_mw_ble_gatts_service_add

uint32_t conn_mw_ble_gatts_service_add(uint8_t const * const p_rx_buf,
                                       uint32_t              rx_buf_len,
                                       uint8_t * const       p_tx_buf,
                                       uint32_t * const      p_tx_buf_len)
{
    SER_ASSERT_NOT_NULL(p_rx_buf);
    SER_ASSERT_NOT_NULL(p_tx_buf);
    SER_ASSERT_NOT_NULL(p_tx_buf_len);

    uint8_t      type;
    ble_uuid_t   uuid   = {0};
    ble_uuid_t * p_uuid = &uuid;
    uint16_t     handle;
    uint16_t *   p_handle = &handle;

    uint32_t err_code = NRF_SUCCESS;
    uint32_t sd_err_code;

    err_code = ble_gatts_service_add_req_dec(p_rx_buf, rx_buf_len, &type, &p_uuid, &p_handle);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    sd_err_code = sd_ble_gatts_service_add(type, p_uuid, p_handle);

    err_code = ble_gatts_service_add_rsp_enc(sd_err_code, p_tx_buf, p_tx_buf_len, p_handle);
    SER_ASSERT(err_code == NRF_SUCCESS, err_code);

    return err_code;
}
开发者ID:IOIOI,项目名称:nRF51,代码行数:28,代码来源:conn_mw_ble_gatts.c


示例11: ble_lc_init

// Function for initializing the Light Control Service
uint32_t ble_lc_init(ble_lc_t * p_lc, const ble_lc_init_t * p_lc_init, ble_uuid_t * ble_uuid_service, ble_uuid_t * ble_uuid_char_status, ble_uuid_t * ble_uuid_char_cmd)
{
	uint32_t err_code;
	
	// Initialize service structure
	p_lc->conn_handle								= BLE_CONN_HANDLE_INVALID;
	p_lc->data_handler_cmd					= p_lc_init->data_handler_cmd;
	p_lc->data_handler_status				= p_lc_init->data_handler_status;
	p_lc->is_notification_enabled		= false;
	
	// Add the Light Control service
	err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
																			ble_uuid_service,
																			&p_lc->service_handle);
	if (err_code != NRF_SUCCESS)
  {
			return err_code;
  }
	
	// Add the Light Status characteristic
	err_code = light_status_char_add(p_lc, p_lc_init, ble_uuid_char_status);
	if (err_code != NRF_SUCCESS)
  {
			return err_code;
  }
	
	// Add the Light Command characteristic
	err_code = light_cmd_char_add(p_lc, p_lc_init, ble_uuid_char_cmd);
	if (err_code != NRF_SUCCESS)
  {
			return err_code;
  }
	
	return NRF_SUCCESS;	
}
开发者ID:erlendrm,项目名称:LightBlu,代码行数:36,代码来源:Light_Control.c


示例12: ble_blinkys_init

uint32_t ble_blinkys_init(ble_blinkys_t * p_blinkys, const ble_blinkys_init_t * p_blinkys_init)
{
    uint32_t   err_code;
    ble_uuid_t ble_uuid;

    // Initialize service structure
    p_blinkys->conn_handle		= BLE_CONN_HANDLE_INVALID;
    p_blinkys->write_handler 	= p_blinkys_init->write_handler;

    // Add base UUID to softdevice's internal list.
    ble_uuid128_t base_uuid = {BLINKY_UUID_BASE};
    err_code = sd_ble_uuid_vs_add(&base_uuid, &p_blinkys->uuid_type);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    ble_uuid.type = p_blinkys->uuid_type;
    ble_uuid.uuid = BLINKY_UUID_SERVICE;

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_blinkys->service_handle);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    err_code = blinky_char_add(p_blinkys, p_blinkys_init);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    return NRF_SUCCESS;
}
开发者ID:iotbees,项目名称:EHAL,代码行数:34,代码来源:BlinkyBleService.c


示例13: ble_rcmon_init

uint32_t ble_rcmon_init(ble_rcmon_t * p_rcmon, const ble_rcmon_init_t * p_rcmon_init) {
    app_trace_log("\r\nrcmon_init\r\n");

    uint32_t err_code;
    ble_uuid_t ble_uuid;

    // Initialize service structure.
    p_rcmon->conn_handle = BLE_CONN_HANDLE_INVALID;

    // Add service.
    ble_uuid128_t base_uuid = {RCMON_UUID_BASE};
    err_code = sd_ble_uuid_vs_add(&base_uuid, &p_rcmon->uuid_type);
    APP_ERROR_CHECK(err_code);

    ble_uuid.type = p_rcmon->uuid_type;
    ble_uuid.uuid = RCMON_UUID_SERVICE;

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_rcmon->service_handle);
    APP_ERROR_CHECK(err_code);

    p_rcmon_init->pdata->accelerometer[0] = 1000;
    p_rcmon_init->pdata->accelerometer[1] = 2000;
    p_rcmon_init->pdata->accelerometer[2] = 3000;

    // Add characteristics.
    err_code = data_char_add(p_rcmon, p_rcmon_init);
    APP_ERROR_CHECK(err_code);

    err_code = config_char_add(p_rcmon, p_rcmon_init);
    APP_ERROR_CHECK(err_code);

    app_trace_log("added chars\r\n");

    return NRF_SUCCESS;
}
开发者ID:mru00,项目名称:mobile_telemetry,代码行数:35,代码来源:ble_rcmon.c


示例14: ble_ias_init

uint32_t ble_ias_init(ble_ias_t * p_ias, const ble_ias_init_t * p_ias_init)
{
    uint32_t   err_code;
    ble_uuid_t ble_uuid;

    // Initialize service structure
    if (p_ias_init->evt_handler == NULL)
    {
        return NRF_ERROR_INVALID_PARAM;
    }
    p_ias->evt_handler = p_ias_init->evt_handler;

    // Add service
    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_IMMEDIATE_ALERT_SERVICE);

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                        &ble_uuid,
                                        &p_ias->service_handle);

    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    // Add alert level characteristic
    return alert_level_char_add(p_ias);
}
开发者ID:TanekLiang,项目名称:rt-thread,代码行数:27,代码来源:ble_ias.c


示例15: service_doorlock_init

void service_doorlock_init(void)
{
    uint32_t             err_code;
    ble_uuid_t           ble_uuid;
    ble_doorlock_t      *p_doorlock = &m_doorlock;
    ble_doorlock_init_t *p_doorlock_init = &m_doorlock_init;
    
    m_doorlock_init.lock_control_handler = lock_control_handler;

    // Initialize service structure
    p_doorlock->conn_handle          = BLE_CONN_HANDLE_INVALID;
    p_doorlock->lock_control_handler = p_doorlock_init->lock_control_handler;
    
    // Add service
    ble_uuid128_t base_uuid = {DOORLOCK_UUID_BASE};
    err_code = sd_ble_uuid_vs_add(&base_uuid, &p_doorlock->uuid_type);
    APP_ERROR_CHECK(err_code);
    
    ble_uuid.type = p_doorlock->uuid_type;
    ble_uuid.uuid = DOORLOCK_UUID_SERVICE;

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_doorlock->service_handle);
    APP_ERROR_CHECK(err_code);

    err_code = lock_char_add(p_doorlock, p_doorlock_init);
    APP_ERROR_CHECK(err_code);
}
开发者ID:albert361,项目名称:nRF51_Beacon_Peripheral_DualRole,代码行数:27,代码来源:ble_srv_doorlock.c


示例16: ble_cscs_init

uint32_t ble_cscs_init(ble_cscs_t * p_cscs, const ble_cscs_init_t * p_cscs_init)
{
    uint32_t   err_code;
    ble_uuid_t ble_uuid;
    ble_cs_ctrlpt_init_t sc_ctrlpt_init;

    // Initialize service structure
    p_cscs->evt_handler = p_cscs_init->evt_handler;
    p_cscs->conn_handle = BLE_CONN_HANDLE_INVALID;
    p_cscs->feature     = p_cscs_init->feature;

    // Add service
    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_CYCLING_SPEED_AND_CADENCE);

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                        &ble_uuid,
                                        &p_cscs->service_handle);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
    
    // Add cycling speed and cadence measurement characteristic
    err_code = csc_measurement_char_add(p_cscs, p_cscs_init);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
    
    // Add cycling speed and cadence feature characteristic
    err_code = csc_feature_char_add(p_cscs, p_cscs_init);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }
    
    // Add Sensor Location characteristic (optional)
    if (p_cscs_init->sensor_location != NULL)
    {
        err_code = csc_sensor_loc_char_add(p_cscs, p_cscs_init);
        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
    }


    //Add speed and cadence control point characteristic
    sc_ctrlpt_init.error_handler                 = p_cscs_init->error_handler;
    sc_ctrlpt_init.size_list_supported_locations = p_cscs_init->size_list_supported_locations;
    sc_ctrlpt_init.supported_functions           = p_cscs_init->ctrplt_supported_functions;
    sc_ctrlpt_init.evt_handler                   = p_cscs_init->ctrlpt_evt_handler;
    sc_ctrlpt_init.list_supported_locations      = p_cscs_init->list_supported_locations;
    sc_ctrlpt_init.sc_ctrlpt_attr_md             = p_cscs_init->csc_ctrlpt_attr_md;
    sc_ctrlpt_init.sensor_location_handle        = p_cscs->sensor_loc_handles.value_handle;
    sc_ctrlpt_init.service_handle                = p_cscs->service_handle;

    return ble_sc_ctrlpt_init(&p_cscs->ctrl_pt, &sc_ctrlpt_init);
}
开发者ID:Aidan-zhang,项目名称:nRF51SDK,代码行数:59,代码来源:ble_cscs.c


示例17: custom_convert_to_nordic_uuid

ble_error_t nRF51GattServer::addService(GattService &service)
{
    /* ToDo: Make sure we don't overflow the array, etc. */
    /* ToDo: Make sure this service UUID doesn't already exist (?) */
    /* ToDo: Basic validation */

    /* Add the service to the nRF51 */
    ble_uuid_t nordicUUID;
    nordicUUID = custom_convert_to_nordic_uuid(service.getUUID());

    uint16_t serviceHandle;
    // ASSERT( ERROR_NONE ==      //_modify
            // sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                     // &nordicUUID,
                                     // &serviceHandle),
            // BLE_ERROR_PARAM_OUT_OF_RANGE );
    nrf_err_check(sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                     &nordicUUID,
                                     &serviceHandle) );        
            
    service.setHandle(serviceHandle);

    /* Add characteristics to the service */
    for (uint8_t i = 0; i < service.getCharacteristicCount(); i++) {
        GattCharacteristic *p_char = service.getCharacteristic(i);

        nordicUUID = custom_convert_to_nordic_uuid(p_char->getUUID());

        // ASSERT ( ERROR_NONE ==    //_modify
                 // custom_add_in_characteristic(service.getHandle(),
                                              // &nordicUUID,
                                              // p_char->getProperties(),
                                              // NULL,
                                              // p_char->getInitialLength(),
                                              // p_char->getMaxLength(),
                                              // &nrfCharacteristicHandles[characteristicCount]),
                 // BLE_ERROR_PARAM_OUT_OF_RANGE );
        nrf_err_check(custom_add_in_characteristic(service.getHandle(),
                                              &nordicUUID,
                                              p_char->getProperties(),
                                              NULL,
                                              p_char->getInitialLength(),
                                              p_char->getMaxLength(),
                                              &nrfCharacteristicHandles[characteristicCount]));
                 
        /* Update the characteristic handle */
        uint16_t charHandle = characteristicCount;
        p_characteristics[characteristicCount++] = p_char;

        p_char->setHandle(charHandle);
        if ((p_char->getValuePtr() != NULL) && (p_char->getInitialLength() > 0)) {
            updateValue(charHandle, p_char->getValuePtr(), p_char->getInitialLength(), false /* localOnly */);
        }
    }

    serviceCount++;

    return BLE_ERROR_NONE;
}
开发者ID:A-L-E-X,项目名称:nRF51822-Arduino,代码行数:59,代码来源:nRF51GattServer.cpp


示例18: gatts_service_add_handle

/**@brief Function for decoding a command packet with RPC_SD_BLE_GATTS_SERVICE_ADD opcode.
 *
 * This function will decode the command, call the BLE Stack API, and also send command response
 * to the peer through the the transport layer.
 *
 * @param[in] p_command         The encoded structure that needs to be decoded and passed on
 *                              to the BLE Stack API.
 * @param[in] command_len       The length of the encoded command read from transport layer.
 *
 * @retval NRF_SUCCESS               If the decoding of the command was successful, the SoftDevice
 *                                   API was called, and the command response was sent to peer,
 *                                   otherwise an error code.
 * @retval NRF_ERROR_INVALID_LENGTH  If the content length of the packet is not conforming to the
 *                                   codec specification.
 */
static uint32_t gatts_service_add_handle(const uint8_t * const p_command, uint32_t command_len)
{
    uint8_t      type;
    uint16_t *   p_handle;
    uint32_t     err_code;
    ble_uuid_t   uuid;
    ble_uuid_t * p_uuid;
    uint8_t      resp_data[sizeof(uint16_t)];

    uint32_t index  = 0;
    uint16_t handle = 0;

    type = p_command[index++];
    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SERVICE_ADD);

    // Service UUID field is present.
    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        uuid.uuid = uint16_decode(&p_command[index]);
        index    += sizeof(uint16_t);
        uuid.type = p_command[index++];
        p_uuid    = &uuid;
        RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SERVICE_ADD);
    }
    else
    {
        RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SERVICE_ADD);
        p_uuid = NULL;
    }

    // Handle present.
    if (p_command[index++] == RPC_BLE_FIELD_PRESENT)
    {
        p_handle = &handle;
    }
    else
    {
        p_handle = NULL;
    }

    RPC_DECODER_LENGTH_CHECK(command_len, index, SD_BLE_GATTS_SERVICE_ADD);

    err_code = sd_ble_gatts_service_add(type, p_uuid, p_handle);

    if (err_code == NRF_SUCCESS)
    {
        UNUSED_VARIABLE(uint16_encode(handle, resp_data));
        return ble_rpc_cmd_resp_data_send(SD_BLE_GATTS_SERVICE_ADD,
                                          err_code,
                                          resp_data,
                                          sizeof(resp_data));
    }
    else
    {
        return ble_rpc_cmd_resp_send(SD_BLE_GATTS_SERVICE_ADD, err_code);
    }
}
开发者ID:Aidan-zhang,项目名称:nRF51SDK,代码行数:72,代码来源:ble_rpc_cmd_decoder_gatts.c


示例19: ble_nus_init

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;
}
开发者ID:Dalsoo,项目名称:Project2_20151023,代码行数:56,代码来源:ble_nus.c


示例20: add_vendor_service

uint32_t add_vendor_service(VendorService* service){
    if(ble_device->vendor_service_count >= MAX_VENDOR_SERVICE_COUNT)
        return 1;
    create_uuid_for_vendor_service(&service->uuid, ble_device->vendor_service_count);
    uint32_t error_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &service->uuid, &service->handle);
    APP_ERROR_CHECK(error_code);
    ble_device->vendor_services[ble_device->vendor_service_count] = service;
    ble_device->vendor_service_count++;
    return 0;
}
开发者ID:nsec,项目名称:nsec_badge,代码行数:10,代码来源:ble_device.c



注:本文中的sd_ble_gatts_service_add函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ sd_ble_gatts_sys_attr_set函数代码示例发布时间:2022-05-30
下一篇:
C++ sd_ble_gatts_characteristic_add函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap