本文整理汇总了C++中BLE_UUID_BLE_ASSIGN函数的典型用法代码示例。如果您正苦于以下问题:C++ BLE_UUID_BLE_ASSIGN函数的具体用法?C++ BLE_UUID_BLE_ASSIGN怎么用?C++ BLE_UUID_BLE_ASSIGN使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BLE_UUID_BLE_ASSIGN函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: ble_ans_c_init
uint32_t ble_ans_c_init(ble_ans_c_t * p_ans, const ble_ans_c_init_t * p_ans_init)
{
VERIFY_PARAM_NOT_NULL(p_ans);
VERIFY_PARAM_NOT_NULL(p_ans_init);
VERIFY_PARAM_NOT_NULL(p_ans_init->evt_handler);
// clear all handles
memset(p_ans, 0, sizeof(ble_ans_c_t));
memset(m_tx_buffer, 0, TX_BUFFER_SIZE);
p_ans->conn_handle = BLE_CONN_HANDLE_INVALID;
p_ans->evt_handler = p_ans_init->evt_handler;
p_ans->error_handler = p_ans_init->error_handler;
p_ans->message_buffer_size = p_ans_init->message_buffer_size;
p_ans->p_message_buffer = p_ans_init->p_message_buffer;
BLE_UUID_BLE_ASSIGN(p_ans->service.service.uuid, BLE_UUID_ALERT_NOTIFICATION_SERVICE);
BLE_UUID_BLE_ASSIGN(p_ans->service.new_alert.uuid, BLE_UUID_NEW_ALERT_CHAR);
BLE_UUID_BLE_ASSIGN(p_ans->service.alert_notif_ctrl_point.uuid,
BLE_UUID_ALERT_NOTIFICATION_CONTROL_POINT_CHAR);
BLE_UUID_BLE_ASSIGN(p_ans->service.unread_alert_status.uuid, BLE_UUID_UNREAD_ALERT_CHAR);
BLE_UUID_BLE_ASSIGN(p_ans->service.suported_new_alert_cat.uuid,
BLE_UUID_SUPPORTED_NEW_ALERT_CATEGORY_CHAR);
BLE_UUID_BLE_ASSIGN(p_ans->service.suported_unread_alert_cat.uuid,
BLE_UUID_SUPPORTED_UNREAD_ALERT_CATEGORY_CHAR);
BLE_UUID_BLE_ASSIGN(p_ans->service.new_alert_cccd.uuid, BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG);
BLE_UUID_BLE_ASSIGN(p_ans->service.unread_alert_cccd.uuid,
BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG);
return ble_db_discovery_evt_register(&p_ans->service.service.uuid);
}
开发者ID:IOIOI,项目名称:nRF51,代码行数:32,代码来源:ble_ans_c.c
示例2: 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
示例3: 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
示例4: 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
示例5: 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
示例6: 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
示例7: indication_char_add
static uint32_t indication_char_add(uint16_t uuid,
uint8_t *p_char_value,
uint16_t char_len,
const ble_srv_cccd_security_mode_t* idc_char_attr_md,
ble_gatts_char_handles_t* p_handles)
{
ble_gatts_char_md_t char_md;
ble_gatts_attr_md_t cccd_md;
ble_gatts_attr_md_t attr_md;
ble_gatts_attr_t attr_char_value;
ble_uuid_t ble_uuid;
APP_ERROR_CHECK_BOOL(p_char_value != NULL);
APP_ERROR_CHECK_BOOL(char_len > 0);
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;
cccd_md.write_perm = idc_char_attr_md->cccd_write_perm;
memset(&char_md, 0, sizeof(char_md));
char_md.char_props.indicate = 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_UUID_BLE_ASSIGN(ble_uuid, uuid);
memset(&attr_md, 0, sizeof(attr_md));
attr_md.vloc = BLE_GATTS_VLOC_STACK;
attr_md.read_perm = idc_char_attr_md->read_perm;
attr_md.write_perm = idc_char_attr_md->write_perm;
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 = char_len;
attr_char_value.init_offs = 0;
attr_char_value.max_len = char_len;
attr_char_value.p_value = p_char_value;
return sd_ble_gatts_characteristic_add(service_handle, \
&char_md, \
&attr_char_value, \
p_handles);
}
开发者ID:slkyff,项目名称:Children_Wireless_Thermometer,代码行数:57,代码来源:user_drv_self_def_service.c
示例8: boot_inp_rep_char_add
/**@brief Function for adding Input Report characteristics.
*
* @param[in] p_hids HID Service structure.
* @param[in] uuid UUID of report characteristic to be added.
* @param[in] max_data_len Maximum length of report value.
* @param[in] p_sec_mode Characteristic security settings.
* @param[out] p_char_handles Handles of new characteristic.
*
* @return NRF_SUCCESS on success, otherwise an error code.
*/
static uint32_t boot_inp_rep_char_add(ble_hids_t * p_hids,
uint16_t uuid,
uint16_t max_data_len,
const ble_srv_cccd_security_mode_t * p_sec_mode,
ble_gatts_char_handles_t * p_char_handles)
{
ble_gatts_char_md_t char_md;
ble_gatts_attr_md_t cccd_md;
ble_gatts_attr_t attr_char_value;
ble_uuid_t ble_uuid;
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);
cccd_md.write_perm = p_sec_mode->cccd_write_perm;
cccd_md.vloc = BLE_GATTS_VLOC_STACK;
memset(&char_md, 0, sizeof(char_md));
char_md.char_props.read = 1;
char_md.char_props.write = (p_sec_mode->write_perm.sm) ? 1 : 0;
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 = &cccd_md;
char_md.p_sccd_md = NULL;
BLE_UUID_BLE_ASSIGN(ble_uuid, uuid);
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));
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 = max_data_len;
attr_char_value.p_value = NULL;
return sd_ble_gatts_characteristic_add(p_hids->service_handle,
&char_md,
&attr_char_value,
p_char_handles);
}
开发者ID:451506709,项目名称:automated_machine,代码行数:64,代码来源:ble_hids.c
示例9: on_connect
/**@brief Function for handling the Connect event.
*
* @param[in] p_ias_c Immediate Alert Service client structure.
* @param[in] p_ble_evt Event received from the BLE stack.
*/
static uint32_t on_connect(ble_ias_c_t * p_ias_c, ble_evt_t const * p_ble_evt)
{
ble_uuid_t ias_uuid;
p_ias_c->conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
// Discover Immediate alert service
BLE_UUID_BLE_ASSIGN(ias_uuid, BLE_UUID_IMMEDIATE_ALERT_SERVICE);
return sd_ble_gattc_primary_services_discover(p_ias_c->conn_handle, START_HANDLE, &ias_uuid);
}
开发者ID:CorBiNO,项目名称:Atomwear,代码行数:16,代码来源:ble_ias_c.c
示例10: heart_rate_measurement_char_add
/**@brief Function for adding the Heart Rate Measurement characteristic.
*
* @param[in] p_hrs Heart Rate Service structure.
* @param[in] p_hrs_init Information needed to initialize the service.
*
* @return NRF_SUCCESS on success, otherwise an error code.
*/
static uint32_t heart_rate_measurement_char_add(ble_hrs_t * p_hrs,
const ble_hrs_init_t * p_hrs_init)
{
simple_uart_putstring("add heart rate measurement");
ble_gatts_char_md_t char_md;
ble_gatts_attr_md_t cccd_md;
ble_gatts_attr_t attr_char_value;
ble_uuid_t ble_uuid;
ble_gatts_attr_md_t attr_md;
uint8_t encoded_initial_hrm[MAX_HRM_LEN];
memset(&cccd_md, 0, sizeof(cccd_md));
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
cccd_md.write_perm = p_hrs_init->hrs_hrm_attr_md.cccd_write_perm;
cccd_md.vloc = BLE_GATTS_VLOC_STACK;
memset(&char_md, 0, sizeof(char_md));
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 = &cccd_md;
char_md.p_sccd_md = NULL;
BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_HEART_RATE_MEASUREMENT_CHAR);
memset(&attr_md, 0, sizeof(attr_md));
attr_md.read_perm = p_hrs_init->hrs_hrm_attr_md.read_perm;
attr_md.write_perm = p_hrs_init->hrs_hrm_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 = hrm_encode(p_hrs, INITIAL_VALUE_HRM, encoded_initial_hrm);
attr_char_value.init_offs = 0;
attr_char_value.max_len = MAX_HRM_LEN;
attr_char_value.p_value = encoded_initial_hrm;
return sd_ble_gatts_characteristic_add(p_hrs->service_handle,
&char_md,
&attr_char_value,
&p_hrs->hrm_handles);
}
开发者ID:vikev,项目名称:SLIP,代码行数:58,代码来源:ble_hrs.c
示例11: hts_measurement_char_add
/**@brief Add Health Thermometer Measurement characteristic.
*
* @param[in] p_hts Health Thermometer Service structure.
* @param[in] p_hts_init Information needed to initialize the service.
*
* @return NRF_SUCCESS on success, otherwise an error code.
*/
static uint32_t hts_measurement_char_add(ble_hts_t * p_hts, const ble_hts_init_t * p_hts_init)
{
ble_gatts_char_md_t char_md;
ble_gatts_attr_md_t cccd_md;
ble_gatts_attr_t attr_char_value;
ble_uuid_t ble_uuid;
ble_gatts_attr_md_t attr_md;
ble_hts_meas_t initial_htm;
uint8_t encoded_htm[MAX_HTM_LEN];
memset(&cccd_md, 0, sizeof(cccd_md));
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
cccd_md.vloc = BLE_GATTS_VLOC_STACK;
cccd_md.write_perm = p_hts_init->hts_meas_attr_md.cccd_write_perm;
memset(&char_md, 0, sizeof(char_md));
char_md.char_props.indicate = 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_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_TEMPERATURE_MEASUREMENT_CHAR);
memset(&attr_md, 0, sizeof(attr_md));
attr_md.vloc = BLE_GATTS_VLOC_STACK;
attr_md.read_perm = p_hts_init->hts_meas_attr_md.read_perm;
attr_md.write_perm = p_hts_init->hts_meas_attr_md.write_perm;
attr_md.rd_auth = 0;
attr_md.wr_auth = 0;
attr_md.vlen = 1;
memset(&attr_char_value, 0, sizeof(attr_char_value));
memset(&initial_htm, 0, sizeof(initial_htm));
attr_char_value.p_uuid = &ble_uuid;
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_len = hts_measurement_encode(p_hts, &initial_htm, encoded_htm);
attr_char_value.init_offs = 0;
attr_char_value.max_len = MAX_HTM_LEN;
attr_char_value.p_value = encoded_htm;
return sd_ble_gatts_characteristic_add(p_hts->service_handle,
&char_md,
&attr_char_value,
&p_hts->meas_handles);
}
开发者ID:amurlynx,项目名称:rf-nordic,代码行数:58,代码来源:ble_hts.c
示例12: dp_otp_char_add
/**@brief Digipass OTP characteristic.
*
* @param[in] p_dp Digipass Service structure.
* @param[in] p_dp_init Information needed to initialize the service.
*
* @return NRF_SUCCESS on success, otherwise an error code.
*/
static uint32_t dp_otp_char_add(ble_dp_t * p_dp, const ble_dp_init_t * p_dp_init)
{
ble_gatts_char_md_t char_md;
//ble_gatts_attr_md_t cccd_md;
ble_gatts_attr_t attr_char_value;
ble_uuid_t ble_uuid;
ble_gatts_attr_md_t attr_md;
uint8_t initial_otp;
memset(&char_md, 0, sizeof(char_md));
char_md.char_props.read = 1; //Reading value permitted.
//char_md.char_properties.notify = (p_bas->is_notification_supported) ? 1 : 0;
char_md.p_char_user_desc = NULL; //Pointer to a UTF-8, NULL if the descriptor is not required.
char_md.p_char_pf = NULL; //Pointer to a presentation format structure or NULL if the descriptor is not required.
char_md.p_user_desc_md = NULL; //Attribute Metadata for the User Description descriptor, or NULL for default values.
//char_md.p_cccd_md = (p_bas->is_notification_supported) ? &cccd_md : NULL;
char_md.p_cccd_md = NULL;
//Attribute Metadata for the Client Characteristic Configuration Descriptor, or NULL for default values.
char_md.p_sccd_md = NULL;
//Attribute Metadata for the Server Characteristic Configuration Descriptor, or NULL for default values.
BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_DP_OTP); //Assing Digipass OTP UUID
memset(&attr_md, 0, sizeof(attr_md));
attr_md.read_perm = p_dp_init->dp_otp_char_attr_md.read_perm; //Read permissions.
attr_md.write_perm = p_dp_init->dp_otp_char_attr_md.write_perm; //Write permissions.
attr_md.vloc = BLE_GATTS_VLOC_STACK; /**< Value is located in stack memory. */
attr_md.rd_auth = 0; //Value will be requested from application on every read. OFF
attr_md.wr_auth = 0; //Value will be reported to application on every write. OFF
attr_md.vlen = 0; //Variable length attribute. OFF
initial_otp = p_dp_init->initial_otp;
memset(&attr_char_value, 0, sizeof(attr_char_value));
attr_char_value.p_uuid = &ble_uuid; //Pointer to the attribute UUID.
attr_char_value.p_attr_md = &attr_md; //Pointer to the attribute metadata structure.
attr_char_value.init_len = sizeof(uint8_t); //Initial attribute value length in bytes.
attr_char_value.init_offs = 0;
//Initial attribute value offset in bytes. If different from zero, the first init_offs bytes of the attribute value will be left uninitialized.
attr_char_value.max_len = sizeof(uint8_t); //Maximum attribute value length in bytes.
attr_char_value.p_value = &initial_otp; //Pointer to the attribute data.
return sd_ble_gatts_characteristic_add(p_dp->service_handle,
&char_md,
&attr_char_value,
&p_dp->dp_otp_handles);
}
开发者ID:claesmathias,项目名称:ble_app_hrs,代码行数:57,代码来源:ble_dp.c
示例13: csc_sensor_loc_char_add
/**@brief Function for adding CSC Sensor Location characteristic.
*
* @param[in] p_cscs Cycling Speed and Cadence Service structure.
* @param[in] p_cscs_init Information needed to initialize the service.
*
* @return NRF_SUCCESS on success, otherwise an error code.
*/
static uint32_t csc_sensor_loc_char_add(ble_cscs_t * p_cscs, const ble_cscs_init_t * p_cscs_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_len;
uint8_t encoded_init_value[1];
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_SENSOR_LOCATION_CHAR);
memset(&attr_md, 0, sizeof(attr_md));
attr_md.read_perm = p_cscs_init->csc_sensor_loc_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 = 0;
memset(&attr_char_value, 0, sizeof(attr_char_value));
init_value_len = sizeof(uint8_t);
if (p_cscs_init->sensor_location != NULL)
{
encoded_init_value[0] = *p_cscs_init->sensor_location;
}
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 = encoded_init_value;
return sd_ble_gatts_characteristic_add(p_cscs->service_handle,
&char_md,
&attr_char_value,
&p_cscs->sensor_loc_handles);
}
开发者ID:Aidan-zhang,项目名称:nRF51SDK,代码行数:56,代码来源:ble_cscs.c
示例14: ble_ias_c_init
uint32_t ble_ias_c_init(ble_ias_c_t * p_ias_c, ble_ias_c_init_t const * p_ias_c_init)
{
if (p_ias_c_init->evt_handler == NULL)
{
return NRF_ERROR_INVALID_PARAM;
}
p_ias_c->evt_handler = p_ias_c_init->evt_handler;
p_ias_c->error_handler = p_ias_c_init->error_handler;
p_ias_c->conn_handle = BLE_CONN_HANDLE_INVALID;
p_ias_c->alert_level_handle = BLE_GATT_HANDLE_INVALID;
BLE_UUID_BLE_ASSIGN(m_alert_level_uuid, BLE_UUID_ALERT_LEVEL_CHAR);
return NRF_SUCCESS;
}
开发者ID:CorBiNO,项目名称:Atomwear,代码行数:16,代码来源:ble_ias_c.c
示例15: ble_tps_init
uint32_t ble_tps_init(ble_tps_t * p_tps, const ble_tps_init_t * p_tps_init)
{
uint32_t err_code;
ble_uuid_t ble_uuid;
// Add service
BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_TX_POWER_SERVICE);
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_tps->service_handle);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
// Add TX Power Level characteristic
return tx_power_level_char_add(p_tps, p_tps_init);
}
开发者ID:1072258106,项目名称:duband,代码行数:17,代码来源:ble_tps.c
示例16: 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:451506709,项目名称:automated_machine,代码行数:53,代码来源:ble_hids.c
示例17: hts_temp_type_char_add
/**@brief Add Temperature Type characteristic.
*
* @param[in] p_hts Health Thermometer Service structure.
* @param[in] p_hts_init Information needed to initialize the service.
*
* @return NRF_SUCCESS on success, otherwise an error code.
*/
static uint32_t hts_temp_type_char_add(ble_hts_t * p_hts, const ble_hts_init_t * p_hts_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_temp_type;
uint8_t init_value_encoded[1];
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_TEMPERATURE_TYPE_CHAR);
memset(&attr_md, 0, sizeof(attr_md));
attr_md.vloc = BLE_GATTS_VLOC_STACK;
attr_md.read_perm = p_hts_init->hts_temp_type_attr_md.read_perm;
attr_md.write_perm = p_hts_init->hts_temp_type_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_temp_type = p_hts_init->temp_type;
init_value_encoded[0] = init_value_temp_type;
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 = init_value_encoded;
return sd_ble_gatts_characteristic_add(p_hts->service_handle,
&char_md,
&attr_char_value,
&p_hts->temp_type_handles);
}
开发者ID:amurlynx,项目名称:rf-nordic,代码行数:53,代码来源:ble_hts.c
示例18: char_add
/**@brief Function for adding the Characteristic.
*
* @param[in] uuid UUID of characteristic to be added.
* @param[in] p_char_value Initial value of characteristic to be added.
* @param[in] char_len Length of initial value. This will also be the maximum value.
* @param[in] dis_attr_md Security settings of characteristic to be added.
* @param[out] p_handles Handles of new characteristic.
*
* @return NRF_SUCCESS on success, otherwise an error code.
*/
static uint32_t char_add(uint16_t uuid,
uint8_t * p_char_value,
uint16_t char_len,
const ble_srv_security_mode_t * dis_attr_md,
ble_gatts_char_handles_t * p_handles)
{
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;
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 = dis_attr_md->read_perm;
attr_md.write_perm = dis_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 = char_len;
attr_char_value.init_offs = 0;
attr_char_value.max_len = char_len;
attr_char_value.p_value = p_char_value;
return sd_ble_gatts_characteristic_add(service_handle, &char_md, &attr_char_value, p_handles);
}
开发者ID:BlueSkyGjj,项目名称:nRF52,代码行数:56,代码来源:ble_dis.c
示例19: ble_step_init
//--------------------------------------------------
uint32_t ble_step_init(ble_step_t * p_step, const ble_step_init_t * p_step_init)
{
if (p_step == NULL || p_step_init == NULL)
{
return NRF_ERROR_NULL;
}
uint32_t err_code;
ble_uuid_t ble_uuid;
uint8_t target[4]={0};
// Initialize service structure
p_step->evt_handler = p_step_init->evt_handler;
p_step->conn_handle = BLE_CONN_HANDLE_INVALID;
p_step->is_notification_supported = p_step_init->support_notification;
p_step->step_count_last = INVALID_BATTERY_LEVEL;
// Add service
BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_WECHAT_SERVICE);
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_step->service_handle);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
get_mac_addr(mac_address);
//mac address Characteristic
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&mac_address_attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&mac_address_attr_md.write_perm);
read_char_add(BLE_UUID_WECHAT_MACADD,BLE_GAP_ADDR_LEN,mac_address,
&mac_address_attr_md,
&mac_address_handles,p_step);
//target Characteristic
target[0]=1;
target[1]=0x10;
target[2]=0x27;
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&target_attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(&target_attr_md.write_perm);
indicate_char_add(BLE_UUID_WECHAT_TARGET,4,target,
&target_attr_md,
&target_handles,p_step);
// Add battery level characteristic
return step_count_char_add(p_step, p_step_init);
}
开发者ID:hlmpost,项目名称:code_backup,代码行数:46,代码来源:ble_step.c
示例20: ble_iqo_init
uint32_t ble_iqo_init(ble_iqo_t * p_iqo)
{
uint32_t err_code;
ble_uuid_t ble_uuid;
iqo_ptr = p_iqo;
// Initialize service structure
p_iqo->conn_handle = BLE_CONN_HANDLE_INVALID;
// Add service
BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_IQO_SERVICE);
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &ble_uuid, &p_iqo->service_handle);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
// Add memory dump characteristic
err_code = iqo_cmd_char_add(p_iqo);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
err_code = iqo_identify_char_add(p_iqo);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
err_code = iqo_wifi_status_char_add(p_iqo);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
err_code = iqo_peer_status_char_add(p_iqo);
if (err_code != NRF_SUCCESS)
{
return err_code;
}
return NRF_SUCCESS;
}
开发者ID:qodome,项目名称:Firmware,代码行数:45,代码来源:ble_iqo.c
注:本文中的BLE_UUID_BLE_ASSIGN函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论