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

C++ sd_ble_gatts_characteristic_add函数代码示例

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

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



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

示例1: init_characteristic_set_led_color

/**
 * @brief Initialize the set_led_color characteristic
 */
void init_characteristic_set_led_color()
{
    ble_gatts_char_md_t characteristic_metadata;
    ble_gatts_attr_md_t attribute_metadata;
    ble_gatts_attr_t    gatt_attribute;

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

    characteristic_metadata.char_props.write            = 1;
    characteristic_metadata.char_props.write_wo_resp    = 1;
    characteristic_metadata.p_char_user_desc            = NULL;
    characteristic_metadata.p_char_pf                   = NULL;
    characteristic_metadata.p_user_desc_md              = NULL;
    characteristic_metadata.p_cccd_md                   = NULL;
    characteristic_metadata.p_sccd_md                   = NULL;

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

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attribute_metadata.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attribute_metadata.write_perm);

    attribute_metadata.vloc     = BLE_GATTS_VLOC_STACK;
    attribute_metadata.rd_auth  = 0;
    attribute_metadata.wr_auth  = 0;
    attribute_metadata.vlen     = 1;

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

    tree_service.characteristic_set_led_color_uuid.uuid = BLE_UUID_SET_LED_COLOR_CHARACTERISTIC;
    tree_service.characteristic_set_led_color_uuid.type = tree_service.uuid.type;

    gatt_attribute.p_uuid       = &tree_service.characteristic_set_led_color_uuid;
    gatt_attribute.p_attr_md    = &attribute_metadata;
    gatt_attribute.init_len     = 1;
    gatt_attribute.init_offs    = 0;
    gatt_attribute.max_len      = 20;

    uint32_t retval =
        sd_ble_gatts_characteristic_add(
            tree_service.service_handle,
            &characteristic_metadata,
            &gatt_attribute,
            &tree_service.characteristic_set_led_color_handles
            );
    APP_ERROR_CHECK(retval);
}
开发者ID:interoberlin,项目名称:Baum-Modell-Firmware,代码行数:49,代码来源:bluetooth.c


示例2: protocol_mode_char_add

/**@brief Function for adding Protocol Mode characteristics.
 *
 * @param[in]   p_hids       HID Service structure.
 * @param[in]   p_sec_mode   Characteristic security settings.
 *
 * @return      NRF_SUCCESS on success, otherwise an error code.
 */
static uint32_t protocol_mode_char_add(ble_hids_t                    * p_hids,
                                       const ble_srv_security_mode_t * p_sec_mode)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;
    uint8_t             initial_protocol_mode;
    
    memset(&char_md, 0, sizeof(char_md));
    
    char_md.char_props.read          = 1;
    char_md.char_props.write_wo_resp = 1;
    char_md.p_char_user_desc         = NULL;
    char_md.p_char_pf                = NULL;
    char_md.p_user_desc_md           = NULL;
    char_md.p_cccd_md                = NULL;
    char_md.p_sccd_md                = NULL;
    
    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_PROTOCOL_MODE_CHAR);
    
    memset(&attr_md, 0, sizeof(attr_md));

    attr_md.read_perm  = p_sec_mode->read_perm;
    attr_md.write_perm = p_sec_mode->write_perm;
    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 0;
    
    memset(&attr_char_value, 0, sizeof(attr_char_value));
    
    initial_protocol_mode = DEFAULT_PROTOCOL_MODE;
    
    attr_char_value.p_uuid       = &ble_uuid;
    attr_char_value.p_attr_md    = &attr_md;
    attr_char_value.init_len     = sizeof(uint8_t);
    attr_char_value.init_offs    = 0;
    attr_char_value.max_len      = sizeof(uint8_t);
    attr_char_value.p_value      = &initial_protocol_mode;
    
    return sd_ble_gatts_characteristic_add(p_hids->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_hids->protocol_mode_handles);
}
开发者ID:1072258106,项目名称:duband,代码行数:53,代码来源:ble_hids.c


示例3: read_char_add

//eric-han:for wehcat fec9
static uint32_t read_char_add(uint16_t  uuid,uint8_t len,uint8_t * p_value,
                         const ble_srv_security_mode_t * step_attr_md,
                         ble_gatts_char_handles_t      * p_handles,ble_step_t * p_step)
{
    ble_uuid_t          ble_uuid;
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_gatts_attr_md_t attr_md;
	uint8_t temp=100;

    //APP_ERROR_CHECK_BOOL(p_char_value != NULL);
    //APP_ERROR_CHECK_BOOL(char_len > 0);

    // The ble_gatts_char_md_t structure uses bit fields. So we reset the memory to zero.
    memset(&char_md, 0, sizeof(char_md));

    char_md.char_props.read  = 1;
    char_md.p_char_user_desc = NULL;
    char_md.p_char_pf        = NULL;
    char_md.p_user_desc_md   = NULL;
    char_md.p_cccd_md        = NULL;
    char_md.p_sccd_md        = NULL;

    BLE_UUID_BLE_ASSIGN(ble_uuid, uuid);

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

    attr_md.read_perm  = step_attr_md->read_perm;
    attr_md.write_perm = step_attr_md->write_perm;
    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 0;

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

    attr_char_value.p_uuid    = &ble_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = len;
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = len;
    attr_char_value.p_value   = p_value;

    return sd_ble_gatts_characteristic_add(p_step->service_handle, &char_md, &attr_char_value, p_handles);
}
开发者ID:hlmpost,项目名称:code_backup,代码行数:46,代码来源:ble_step.c


示例4: bps_feature_char_add

/**@brief Function for adding Blood Pressure Feature characteristics.
 *
 * @param[in]   p_bps        Blood Pressure Service structure.
 * @param[in]   p_bps_init   Information needed to initialize the service.
 *
 * @return      NRF_SUCCESS on success, otherwise an error code.
 */
static uint32_t bps_feature_char_add(ble_bps_t * p_bps, const ble_bps_init_t * p_bps_init)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;
    uint8_t             init_value_encoded[2];
    uint8_t             init_value_len;
    
    memset(&char_md, 0, sizeof(char_md));
    
    char_md.char_props.read  = 1;
    char_md.p_char_user_desc = NULL;
    char_md.p_char_pf        = NULL;
    char_md.p_user_desc_md   = NULL;
    char_md.p_cccd_md        = NULL;
    char_md.p_sccd_md        = NULL;
    
    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_BLOOD_PRESSURE_FEATURE_CHAR);
    
    memset(&attr_md, 0, sizeof(attr_md));

    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.read_perm  = p_bps_init->bps_feature_attr_md.read_perm;
    attr_md.write_perm = p_bps_init->bps_feature_attr_md.write_perm;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 0;
    
    memset(&attr_char_value, 0, sizeof(attr_char_value));
    
    init_value_len = uint16_encode(p_bps_init->feature, init_value_encoded);

    attr_char_value.p_uuid       = &ble_uuid;
    attr_char_value.p_attr_md    = &attr_md;
    attr_char_value.init_len     = init_value_len;
    attr_char_value.init_offs    = 0;
    attr_char_value.max_len      = init_value_len;
    attr_char_value.p_value      = init_value_encoded;
    
    return sd_ble_gatts_characteristic_add(p_bps->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_bps->feature_handles);
}
开发者ID:451506709,项目名称:automated_machine,代码行数:52,代码来源:ble_bps.c


示例5: lock_char_add

/**@brief Function for adding the LED characteristic. 
 * 
 */ 
static uint32_t lock_char_add(ble_doorlock_t * p_doorlock, const ble_doorlock_init_t * p_lbs_init) 
{ 
    ble_gatts_char_md_t char_md; 
    ble_gatts_attr_t    attr_char_value; 
    ble_uuid_t          ble_uuid; 
    ble_gatts_attr_md_t attr_md; 


    memset(&char_md, 0, sizeof(char_md)); 
     
    char_md.char_props.read   = 1; 
    char_md.char_props.write  = 1; 
    char_md.p_char_user_desc  = NULL; 
    char_md.p_char_pf         = NULL; 
    char_md.p_user_desc_md    = NULL; 
    char_md.p_cccd_md         = NULL; 
    char_md.p_sccd_md         = NULL; 
     
    ble_uuid.type = p_doorlock->uuid_type; 
    ble_uuid.uuid = DOORLOCK_UUID_LOCK_CHAR; 
      
     memset(&attr_md, 0, sizeof(attr_md)); 
 

     BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm); 
     BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm); 
     attr_md.vloc       = BLE_GATTS_VLOC_STACK; 
     attr_md.rd_auth    = 0; 
     attr_md.wr_auth    = 0; 
     attr_md.vlen       = 0; 
      
     memset(&attr_char_value, 0, sizeof(attr_char_value)); 
 

     attr_char_value.p_uuid       = &ble_uuid; 
     attr_char_value.p_attr_md    = &attr_md; 
     attr_char_value.init_len     = sizeof(uint8_t); 
     attr_char_value.init_offs    = 0; 
     attr_char_value.max_len      = sizeof(uint8_t); 
     attr_char_value.p_value      = NULL; 
      
     return sd_ble_gatts_characteristic_add(p_doorlock->service_handle, &char_md, 
                                                &attr_char_value, 
                                                &p_doorlock->lock_char_handles); 
 } 
开发者ID:albert361,项目名称:nRF51_Beacon_Peripheral_DualRole,代码行数:48,代码来源:ble_srv_doorlock.c


示例6: light_status_char_add

// Function for adding the Light Status characteristic
static uint32_t light_status_char_add(ble_lc_t * p_lc, const ble_lc_init_t * p_lc_init, ble_uuid_t * ble_uuid)
{
		ble_gatts_char_md_t		char_md;
		ble_gatts_attr_md_t		cccd_md;
		ble_gatts_attr_t			attr_char_value;
		ble_gatts_attr_md_t		attr_md;
	
		memset(&cccd_md, 0, sizeof(cccd_md));
	
		BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
		BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);
		
		cccd_md.vloc	= BLE_GATTS_VLOC_STACK;
	
		memset(&char_md, 0, sizeof(char_md));
	
		char_md.char_props.notify		= NULL;
		char_md.char_props.read			= 1;
		char_md.p_char_user_desc		= NULL;
		char_md.p_char_pf						= NULL;
		char_md.p_user_desc_md			= NULL;
		char_md.p_cccd_md						= &cccd_md;
		char_md.p_sccd_md						= NULL;
		
		BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
		BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm);
		
		attr_md.vloc				= BLE_GATTS_VLOC_STACK;
		attr_md.rd_auth			= 1;
		attr_md.wr_auth			= 0;
		attr_md.vlen				= 1;
		
		memset(&attr_char_value, 0, sizeof(attr_char_value));
		
		attr_char_value.p_uuid			= ble_uuid;
		attr_char_value.p_attr_md		= &attr_md;
		attr_char_value.init_len		= sizeof(uint8_t);
		attr_char_value.init_offs		= 0;
		attr_char_value.max_len			= BLE_LC_MAX_DATA_LEN;
		
		return sd_ble_gatts_characteristic_add(p_lc->service_handle,
																					 &char_md,
																					 &attr_char_value,
																					 &p_lc->light_status_handles);
}
开发者ID:erlendrm,项目名称:LightBlu,代码行数:46,代码来源:Light_Control.c


示例7: dfu_ctrl_pt_add

/**@brief       Function for adding DFU Control Point characteristic to the BLE Stack.
 *
 * @param[in]   p_dfu DFU Service structure.
 *
 * @return      NRF_SUCCESS on success. Otherwise an error code.
 */
static uint32_t dfu_ctrl_pt_add(ble_dfu_t * const p_dfu)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          char_uuid;
    ble_gatts_attr_md_t attr_md;

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

    char_md.char_props.write  = 1;
    char_md.char_props.notify = 1;
    char_md.p_char_user_desc  = NULL;
    char_md.p_char_pf         = NULL;
    char_md.p_user_desc_md    = NULL;
    char_md.p_cccd_md         = NULL;
    char_md.p_sccd_md         = NULL;

    char_uuid.type = p_dfu->uuid_type;
    char_uuid.uuid = BLE_DFU_CTRL_PT_UUID;

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

    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);

    attr_md.vloc    = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth = 0;
    attr_md.wr_auth = 1;
    attr_md.vlen    = 1;

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

    attr_char_value.p_uuid    = &char_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = 0;
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = BLE_L2CAP_MTU_DEF;
    attr_char_value.p_value   = NULL;

    return sd_ble_gatts_characteristic_add(p_dfu->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_dfu->dfu_ctrl_pt_handles);
}
开发者ID:ChristianRiesen,项目名称:Smoothie2,代码行数:50,代码来源:ble_dfu.c


示例8: tx_power_level_char_add

/**@brief Function for adding TX Power Level characteristics.
 *
 * @param[in]   p_tps        TX Power Service structure.
 * @param[in]   p_tps_init   Information needed to initialize the service.
 *
 * @return      NRF_SUCCESS on success, otherwise an error code.
 */
static uint32_t tx_power_level_char_add(ble_tps_t            * p_tps,
                                        const ble_tps_init_t * p_tps_init)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;

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

    char_md.char_props.read  = 1;
    char_md.p_char_user_desc = NULL;
    char_md.p_char_pf        = NULL;
    char_md.p_user_desc_md   = NULL;
    char_md.p_cccd_md        = NULL;
    char_md.p_sccd_md        = NULL;

    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_TX_POWER_LEVEL_CHAR);

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

    attr_md.read_perm  = p_tps_init->tps_attr_md.read_perm;
    attr_md.write_perm = p_tps_init->tps_attr_md.write_perm;
    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 0;

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

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

    attr_char_value.p_uuid    = &ble_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = sizeof (int8_t);
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = sizeof (uint8_t);
    attr_char_value.p_value   = (uint8_t*)&p_tps_init->initial_tx_power_level;

    return sd_ble_gatts_characteristic_add(p_tps->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_tps->tx_power_level_handles);
}
开发者ID:AaltoNEPPI,项目名称:nRF52_dev,代码行数:51,代码来源:ble_tps.c


示例9: hid_control_point_char_add

/**@brief Function for adding HID Control Point characteristics.
 *
 * @param[in]   p_hids       HID Service structure.
 * @param[in]   p_sec_mode   Characteristic security settings.
 *
 * @return      NRF_SUCCESS on success, otherwise an error code.
 */
static uint32_t hid_control_point_char_add(ble_hids_t                    * p_hids,
                                           const ble_srv_security_mode_t * p_sec_mode)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;
    uint8_t             initial_hid_control_point;

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

    char_md.char_props.write_wo_resp = 1;
    char_md.p_char_user_desc         = NULL;
    char_md.p_char_pf                = NULL;
    char_md.p_user_desc_md           = NULL;
    char_md.p_cccd_md                = NULL;
    char_md.p_sccd_md                = NULL;

    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HID_CONTROL_POINT_CHAR);

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

    attr_md.read_perm  = p_sec_mode->read_perm;
    attr_md.write_perm = p_sec_mode->write_perm;
    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 0;

    initial_hid_control_point = INITIAL_VALUE_HID_CONTROL_POINT;

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

    attr_char_value.p_uuid    = &ble_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = sizeof(uint8_t);
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = sizeof(uint8_t);
    attr_char_value.p_value   = &initial_hid_control_point;

    return sd_ble_gatts_characteristic_add(p_hids->service_handle, &char_md, 
                                           &attr_char_value, 
                                           &p_hids->hid_control_point_handles);
}
开发者ID:451506709,项目名称:automated_machine,代码行数:51,代码来源:ble_hids.c


示例10: hid_information_char_add

/**@brief Function for adding HID Information characteristics.
 *
 * @param[in]   p_hids        HID Service structure.
 * @param[in]   p_hids_init   Service initialization structure.
 *
 * @return      NRF_SUCCESS on success, otherwise an error code.
 */
static uint32_t hid_information_char_add(ble_hids_t * p_hids, const ble_hids_init_t * p_hids_init)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;
    uint8_t             encoded_hid_information[ENCODED_HID_INFORMATION_LEN];
    uint8_t             hid_info_len;

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

    char_md.char_props.read  = 1;
    char_md.p_char_user_desc = NULL;
    char_md.p_char_pf        = NULL;
    char_md.p_user_desc_md   = NULL;
    char_md.p_cccd_md        = NULL;
    char_md.p_sccd_md        = NULL;

    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HID_INFORMATION_CHAR);

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

    attr_md.read_perm  = p_hids_init->hid_information.security_mode.read_perm;
    attr_md.write_perm = p_hids_init->hid_information.security_mode.write_perm;
    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 0;

    hid_info_len = encode_hid_information(encoded_hid_information, &p_hids_init->hid_information);

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

    attr_char_value.p_uuid    = &ble_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = hid_info_len;
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = attr_char_value.init_len;
    attr_char_value.p_value   = encoded_hid_information;

    return sd_ble_gatts_characteristic_add(p_hids->service_handle, &char_md,
                                           &attr_char_value,
                                           &p_hids->hid_information_handles);
}
开发者ID:451506709,项目名称:automated_machine,代码行数:51,代码来源:ble_hids.c


示例11: alert_level_char_add

/**@brief Function for adding Alert Level characteristics.
 *
 * @param[in]   p_ias        Immediate Alert Service structure.
 * @param[in]   p_ias_init   Information needed to initialize the service.
 *
 * @return      NRF_SUCCESS on success, otherwise an error code.
 */
static uint32_t alert_level_char_add(ble_ias_t * p_ias)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;
    uint8_t             initial_alert_level;

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

    char_md.char_props.write_wo_resp = 1;
    char_md.p_char_user_desc         = NULL;
    char_md.p_char_pf                = NULL;
    char_md.p_user_desc_md           = NULL;
    char_md.p_cccd_md                = NULL;
    char_md.p_sccd_md                = NULL;

    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_ALERT_LEVEL_CHAR);

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

    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(&attr_md.write_perm);

    attr_md.vloc    = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth = 0;
    attr_md.wr_auth = 0;
    attr_md.vlen    = 0;

    memset(&attr_char_value, 0, sizeof(attr_char_value));
    initial_alert_level = INITIAL_ALERT_LEVEL;

    attr_char_value.p_uuid    = &ble_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = sizeof (uint8_t);
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = sizeof (uint8_t);
    attr_char_value.p_value   = &initial_alert_level;

    return sd_ble_gatts_characteristic_add(p_ias->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_ias->alert_level_handles);
}
开发者ID:TanekLiang,项目名称:rt-thread,代码行数:51,代码来源:ble_ias.c


示例12: tx_char_add

/**@brief       Function for adding TX characteristic.
 *
 * @param[in]   p_nus        Nordic UART Service structure.
 * @param[in]   p_nus_init   Information needed to initialize the service.
 *
 * @return      NRF_SUCCESS on success, otherwise an error code.
 */
static uint32_t tx_char_add(ble_nus_t * p_nus, const ble_nus_init_t * p_nus_init)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;
    
    memset(&char_md, 0, sizeof(char_md));
    
    char_md.char_props.write            = 1;
    char_md.char_props.write_wo_resp    = 1;
    char_md.p_char_user_desc            = NULL;
    char_md.p_char_pf                   = NULL;
    char_md.p_user_desc_md              = NULL;
    char_md.p_cccd_md                   = NULL;
    char_md.p_sccd_md                   = NULL;
    
    ble_uuid.type                       = p_nus->uuid_type;
    ble_uuid.uuid                       = BLE_UUID_NUS_TX_CHARACTERISTIC;
    
    memset(&attr_md, 0, sizeof(attr_md));

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);
    
    attr_md.vloc                        = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth                     = 0;
    attr_md.wr_auth                     = 0;
    attr_md.vlen                        = 1;
    
    memset(&attr_char_value, 0, sizeof(attr_char_value));

    attr_char_value.p_uuid              = &ble_uuid;
    attr_char_value.p_attr_md           = &attr_md;
    attr_char_value.init_len            = 1;
    attr_char_value.init_offs           = 0;
    attr_char_value.max_len             = BLE_NUS_MAX_TX_CHAR_LEN;
    
    
    return sd_ble_gatts_characteristic_add(p_nus->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_nus->tx_handles);
}
开发者ID:Dalsoo,项目名称:Project2_20151023,代码行数:51,代码来源:ble_nus.c


示例13: ble_led_sta_char_add

// This function allows to add a Characteristic in our Service
static uint32_t ble_led_sta_char_add(ble_led_t * const p_led)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          char_uuid;
    ble_gatts_attr_md_t attr_md;
    uint8_t initial_led_status = 0;

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

    // set the Characteristic type to Write Without Response
    // it means Central won't except any acknowledgment from the Peripheral
    char_md.char_props.write_wo_resp = 1;

    // Here we set the Characteristic UUID
    char_uuid.type = p_led->uuid_type;
    char_uuid.uuid = BLE_LED_STA_CHAR_UUID;

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

    // add write permission
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);

    // Attribute configuration, the data is stored in stack memory space
    attr_md.vloc    = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth = 0;
    attr_md.wr_auth = 0;
    attr_md.vlen    = 0;

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

    // setup Attribute default value
    attr_char_value.p_uuid    = &char_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = sizeof(uint8_t);
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = sizeof(uint8_t);
    attr_char_value.p_value   = &initial_led_status;

    return sd_ble_gatts_characteristic_add(p_led->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_led->led_status_handles);
}
开发者ID:PolarState,项目名称:nrf51,代码行数:45,代码来源:ble_led.c


示例14: rgb_char_add

/**@brief Function for adding the LED characteristic.
 *
 */
static uint32_t rgb_char_add(ble_rgb_btn_t * p_rgb_btn, const ble_rgb_btn_init_t * p_rgb_btn_init)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;
    
    uint8_t default_rgb[3] = {0, 0, 0};

    memset(&char_md, 0, sizeof(char_md));
    
    char_md.char_props.read   = 1;
    char_md.char_props.write  = 1;
    char_md.p_char_user_desc  = NULL;
    char_md.p_char_pf         = NULL;
    char_md.p_user_desc_md    = NULL;
    char_md.p_cccd_md         = NULL;
    char_md.p_sccd_md         = NULL;
    
    ble_uuid.type = p_rgb_btn->uuid_type;
    ble_uuid.uuid = RGB_BTN_UUID_LED_CHAR;
    
    memset(&attr_md, 0, sizeof(attr_md));

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);
    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 0;
    
    memset(&attr_char_value, 0, sizeof(attr_char_value));

    attr_char_value.p_uuid       = &ble_uuid;
    attr_char_value.p_attr_md    = &attr_md;
    attr_char_value.init_len     = sizeof(uint8_t)*3;
    attr_char_value.init_offs    = 0;
    attr_char_value.max_len      = sizeof(uint8_t)*3;
    attr_char_value.p_value      = default_rgb;
    
    return sd_ble_gatts_characteristic_add(p_rgb_btn->service_handle, &char_md,
                                               &attr_char_value,
                                               &p_rgb_btn->rgb_char_handles);
}
开发者ID:joakimtoe,项目名称:nrf5-ble-rgb-btn,代码行数:47,代码来源:ble_rgb_btn.c


示例15: statistics_init

void statistics_init(void)
{
  uint32_t err_code;

  static const ble_gatts_attr_md_t metadata =
  {
      .read_perm = { 1, 2 },
      .vlen = 1,
      .vloc = BLE_GATTS_VLOC_USER
  };
  static const ble_uuid_t uuid =
  {
      .type = UUIDS_BASE_TYPE,
      .uuid = MESH_STATISTICS_UUID
  };
  static const ble_gatts_attr_t attr =
  {
      .p_uuid = (ble_uuid_t*)&uuid,
      .p_attr_md = (ble_gatts_attr_md_t*)&metadata,
      .init_len = sizeof(stats),
      .max_len = sizeof(stats),
      .p_value = (uint8_t*)&stats
  };
  static const ble_gatts_char_md_t characteristic =
  {
      .char_props.read = 1,
      .p_char_user_desc = "Stats",
      .char_user_desc_max_size = 5,
      .char_user_desc_size = 5
  };
  ble_gatts_char_handles_t newhandle;
  err_code = sd_ble_gatts_characteristic_add(primary_service_handle, &characteristic, &attr, &newhandle);
  APP_ERROR_CHECK(err_code);
}

uint32_t statistics_get_time(void)
{
  uint32_t err_code;
  uint32_t ticks;
  err_code = app_timer_cnt_get(&ticks);
  APP_ERROR_CHECK(err_code);
  return ticks;
}
开发者ID:aanon4,项目名称:BLEMP,代码行数:43,代码来源:statistics.c


示例16: dfu_rev_char_add

/**@brief       Function for adding DFU Revision characteristic to the BLE Stack.
 *
 * @param[in]   p_dfu DFU Service structure.
 *
 * @return      NRF_SUCCESS on success. Otherwise an error code.
 */
static uint32_t dfu_rev_char_add(ble_dfu_t * const p_dfu, ble_dfu_init_t const * const p_dfu_init)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          char_uuid;
    ble_gatts_attr_md_t attr_md;

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

    char_md.char_props.read          = 1;
    char_md.p_char_user_desc         = NULL;
    char_md.p_char_pf                = NULL;
    char_md.p_user_desc_md           = NULL;
    char_md.p_cccd_md                = NULL;
    char_md.p_sccd_md                = NULL;

    char_uuid.type = p_dfu->uuid_type;
    char_uuid.uuid = BLE_DFU_REV_CHAR_UUID;

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

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.write_perm);

    attr_md.vloc    = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth = 0;
    attr_md.wr_auth = 0;
    attr_md.vlen    = 1;

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

    attr_char_value.p_uuid    = &char_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = sizeof(uint16_t);
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = sizeof(uint16_t);
    attr_char_value.p_value   = (uint8_t *)&p_dfu_init->revision;

    return sd_ble_gatts_characteristic_add(p_dfu->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_dfu->dfu_rev_handles);
}
开发者ID:ChristianRiesen,项目名称:Smoothie2,代码行数:49,代码来源:ble_dfu.c


示例17: indicate_char_add

//------------------------------------------------------------
//eric-han:for wehcat fea2
static uint32_t indicate_char_add(uint16_t  uuid,uint8_t len,uint8_t * p_value,
                         const ble_srv_security_mode_t * step_attr_md,
                         ble_gatts_char_handles_t      * p_handles,ble_step_t * p_step)
{
    ble_uuid_t          ble_uuid;
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_gatts_attr_md_t attr_md;
	uint8_t temp=100;

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

	char_md.char_props.write = 1;
	char_md.char_props.indicate= 1;
    char_md.char_props.read  = 1;
    char_md.p_char_user_desc = NULL;
    char_md.p_char_pf        = NULL;
    char_md.p_user_desc_md   = NULL;
    char_md.p_cccd_md        = NULL;
    char_md.p_sccd_md        = NULL;

    BLE_UUID_BLE_ASSIGN(ble_uuid, uuid);

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

    attr_md.read_perm  = step_attr_md->read_perm;
    attr_md.write_perm = step_attr_md->write_perm;
    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 0;

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

    attr_char_value.p_uuid    = &ble_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = len;
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = len;
    attr_char_value.p_value   = p_value;

    return sd_ble_gatts_characteristic_add(p_step->service_handle, &char_md, &attr_char_value, p_handles);
}
开发者ID:hlmpost,项目名称:code_backup,代码行数:45,代码来源:ble_step.c


示例18: iqo_identify_char_add

// Intermediate temperature
static uint32_t iqo_identify_char_add(ble_iqo_t * p_iqo)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;

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

    char_md.char_props.read  = 1;
    char_md.char_props.write = 1;
    char_md.p_char_user_desc = NULL;
    char_md.p_char_pf        = NULL;
    char_md.p_user_desc_md   = NULL;
    char_md.p_cccd_md        = NULL;
    char_md.p_sccd_md        = NULL;

    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_IQO_IDENTIFY_CHAR);

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

    attr_md.vloc       = BLE_GATTS_VLOC_STACK;
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 1;

    memset(&iqo_tgt_identify, 0, sizeof(ble_iqo_id_t));
    memcpy(&(iqo_tgt_identify.id[0]), "Ting's ACC1", 11);

    attr_char_value.p_uuid    = &ble_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = 20;
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = 20;
    attr_char_value.p_value   = (uint8_t *)&iqo_tgt_identify;

    return sd_ble_gatts_characteristic_add(p_iqo->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_iqo->iqo_identify_handle);
}
开发者ID:qodome,项目名称:Firmware,代码行数:44,代码来源:ble_iqo.c


示例19: hts_qodome_char_add

static uint32_t hts_qodome_char_add(ble_qodome_t * p_qodome)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;

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

    char_md.char_props.write  = 1;
    char_md.p_char_user_desc = NULL;
    char_md.p_char_pf        = NULL;
    char_md.p_user_desc_md   = NULL;
    char_md.p_cccd_md        = NULL;
    char_md.p_sccd_md        = NULL;

    BLE_UUID_BLE_ASSIGN(ble_uuid, QODOME_PUBLIC_SET_NAME);

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

    attr_md.vloc       = BLE_GATTS_VLOC_STACK;

    BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&attr_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);
    attr_md.rd_auth    = 0;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 0;

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

    attr_char_value.p_uuid    = &ble_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = 0;
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = 4;
    attr_char_value.p_value   = NULL;

    return sd_ble_gatts_characteristic_add(p_qodome->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_qodome->qodome_handles);
}
开发者ID:qodome,项目名称:Firmware,代码行数:42,代码来源:ble_qodome_public.c


示例20: iqo_peer_status_char_add

static uint32_t iqo_peer_status_char_add(ble_iqo_t * p_iqo)
{
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_t    attr_char_value;
    ble_uuid_t          ble_uuid;
    ble_gatts_attr_md_t attr_md;
    uint8_t 			initial_v = 0;

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

    char_md.char_props.read  = 1;
    char_md.char_props.write = 0;
    char_md.p_char_user_desc = NULL;
    char_md.p_char_pf        = NULL;
    char_md.p_user_desc_md   = NULL;
    char_md.p_cccd_md        = NULL;
    char_md.p_sccd_md        = NULL;

    BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_IQO_PEER_STATUS);

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

    attr_md.vloc = BLE_GATTS_VLOC_STACK;

    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
    attr_md.rd_auth    = 1;
    attr_md.wr_auth    = 0;
    attr_md.vlen       = 1;

    attr_char_value.p_uuid    = &ble_uuid;
    attr_char_value.p_attr_md = &attr_md;
    attr_char_value.init_len  = 1;
    attr_char_value.init_offs = 0;
    attr_char_value.max_len   = 20;
    attr_char_value.p_value   = &initial_v;

    return sd_ble_gatts_characteristic_add(p_iqo->service_handle,
                                           &char_md,
                                           &attr_char_value,
                                           &p_iqo->iqo_peer_status_handle);
}
开发者ID:qodome,项目名称:Firmware,代码行数:41,代码来源:ble_iqo.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ sd_ble_gatts_service_add函数代码示例发布时间:2022-05-30
下一篇:
C++ sd_ble_gap_sec_params_reply函数代码示例发布时间: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