BLE配置文件帮助14681

⚠️
嗨,...感谢您来论坛。令人兴奋的消息!我们现在正在迁至我们的新论坛平台,将提供更好的功能,并包含在主对话框网站中。所有帖子和帐户都已迁移。我们现在只接受新论坛上的流量 - 请发布任何新线程https://www.dialog-seminile.com/support.。我们将在未来几天修复错误/优化搜索和标记。
5个帖子/ 0新
最后一篇
匿名(未经验证)
BLE配置文件帮助14681

你好,

我正在尝试创建一个BLE配置文件,用于通过BLE链接发送传感器数据。你能指向我的方向,我可以找到这个例子吗?是否有一个文档,我可以在实现自定义配置文件中阅读?

问候

设备:
JK_DIALOG.
离线
最后一次露面:3周4天前
职员
加入:2016-08-22 23:07
嗨瓦拉希尔,

嗨瓦拉希尔,

最终,我们将有一个应用笔记来描述这个过程 - 但是在平均时间,您可以使用位于演示中的BLE_Peripheral来获得您入门或PXP报告者。至于客户服务,在SDK 1.0.8中,您可以引用位于BLE_Services文件夹中的串行端口服务(SPS.C)。SPS是一种自定义服务,它使用SDKS API的构造来创建自定义服务。在SDK的流程之后,在应用程序层中,您可以使用以下两行初始化服务:

ble_service_t * svc;

svc = my_service_init(回调CB);
ble_service_add(SVC);

-----------------------------------------------------------------

然后,您可以从init函数中遵循其他服务的流 - 从sps_init函数中:

ble_service_t * sps_init(sps_callbacks_t * cb)
{
Uint16_t num_attr,sps_tx_desc_h,sps_rx_desc_h,sps_flow_ctrl_desc_h;
sp_service_t * sps;
ATT_UUID_T UUID;

sps = os_malloc(sizeof(* sps));
MEMSET(SPS,0,SIZEOF(* SPS));

num_attr = ble_gatts_get_num_attr(0,3,5);

ble_uuid_from_string(UUID_SPS,&UUID);
ble_gatts_add_service(&uuid,gatt_service_primary,num_attr);

/ * SPS服务器TX * /
ble_uuid_from_string(UUID_SPS_SERVER_TX,&UUID);
BLE_GATTS_ADD_CHAROURATION(&UUID,GATT_PROP_NOTIFY,ATT_PERM_NONE,
sps_server_tx_size,0,null,sps-> sps_tx_val_h);

ble_uuid_create16(UUID_Gatt_Client_Char_Char_Configuration,&UUID);
ble_gatts_add_descriptor(&uuid,att_perm_rw,2,0,sps-> sps_tx_ccc_h);

BLE_UUID_CREATE16(UUID_GATT_CHAR_USER_DESCRIPTION,&UUID);
ble_gatts_add_descriptor(&uuid,att_perm_read,sizeof(sps_tx_desc),0,&sps_tx_desc_h);

/ * sps server rx * /
ble_uuid_from_string(UUID_SPS_SERVER_RX,&UUID);
ble_gatts_add_Charactery(&UUID,GATT_PROP_WRITE_NO_RESP,ATT_PERM_WRITE,
sps_server_rx_size,0,null,&sps-> sps_rx_val_h);

BLE_UUID_CREATE16(UUID_GATT_CHAR_USER_DESCRIPTION,&UUID);
ble_gatts_add_descriptor(&uuid,att_perm_read,sizeof(sps_rx_desc),0,&sps_rx_desc_h);

/ * SPS流量控制* /
ble_uuid_from_string(UUID_SPS_FLOW_CTRL,&UUID);
BLE_GATTS_ADD_CHAROURATIC(&UUID,GATT_PROP_WRITE_NO_RESP | GATT_PROP_NOTIFY,ATT_PERM_WRITE,
1,0,null,sps-> sps_flow_ctrl_val_h);

ble_uuid_create16(UUID_Gatt_Client_Char_Char_Configuration,&UUID);
ble_gatts_add_descriptor(&uuid,att_perm_rw,2,0,&sps-> sps_flow_ctrl_ccc_h);

BLE_UUID_CREATE16(UUID_GATT_CHAR_USER_DESCRIPTION,&UUID);
ble_gatts_add_descriptor(&uuid,att_perm_read,sizeof(sps_flow_control_desc),0,&sps_flow_ctrl_desc_h);

/ *注册SPS服务* /
ble_gatts_register_service(&sps-> svc.start_h,&sps-> sps_tx_val_h,sps-> sps_tx_ccc_h,
&sps_tx_desc_h,&sps-> sps_rx_val_h,&sps_rx_desc_h,
&sps-> sps_flow_ctrl_val_h,&sps-> sps_flow_ctrl_ccc_h,
&sps_flow_ctrl_desc_h,0);

/ *设定特征描述的值* /
ble_gatts_set_value(sps_tx_desc_h,sizeof(sps_tx_desc),sps_tx_desc);
ble_gatts_set_value(sps_rx_desc_h,sizeof(sps_rx_desc),sps_rx_desc);
ble_gatts_set_value(sps_flow_ctrl_desc_h,sizeof(sps_flow_control_desc),
sps_flow_control_desc);

sps-> svc.end_h = sps-> svc.start_h + num_attr;
sps-> svc.write_req = handle_write_req;
sps-> svc.read_req = handle_read_req;
sps-> svc.event_sent = handle_event_sent;
SPS-> CB = CB;

返回和SPS-> SVC;
}

Mutahir(未经验证)
谢谢你的广泛

感谢您的广泛答复,非常感谢。返回BLE_PERITITAL如何修改MY_SERVICE以具有我可以定期更新的可读数据值。

JK_DIALOG.
离线
最后一次露面:3周4天前
职员
加入:2016-08-22 23:07
请参阅SPS.C

再次,请参阅该示例的SPS.c(或任何其他BLE配置文件)。yy_service_init此时没有任何内容,但可以修改。您可以更改有关Gatt_Prop_read的特性,然后注册读取回调。在SPS.C的第287行中注册读取呼叫,并说明了设置该值。

/ *设定特征描述的值* /
ble_gatts_set_value(sps_tx_desc_h,sizeof(sps_tx_desc),sps_tx_desc);
ble_gatts_set_value(sps_rx_desc_h,sizeof(sps_rx_desc),sps_rx_desc);
ble_gatts_set_value(sps_flow_ctrl_desc_h,sizeof(sps_flow_control_desc),
sps_flow_control_desc);

sps-> svc.end_h = sps-> svc.start_h + num_attr;
sps-> svc.write_req = handle_write_req;
sps-> svc.read_req = handle_read_req;
sps-> svc.event_sent = handle_event_sent;
SPS-> CB = CB;

返回和SPS-> SVC;

Mutahir(未经验证)
谢谢真的帮助了

谢谢真的帮助了