当前位置: 首页>>代码示例>>C++>>正文


C++ sd_ble_gatts_service_add函数代码示例

本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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