连接问题with unknown bug, but advtising works well

6 posts / 0 new
Last post
Alex Luo
Offline
Last seen:1年3个月前
专家
Joined:2014-02-28 19:16
连接问题with unknown bug, but advtising works well

嗨支持团队,

I met a problem again for connection issue, which is not easy to duplicate and reported before.

I modified from sample-128 to be a peripheral, and works well for my application. Recently the advertising data is updated by sensor detection, that works well too. But occasionally the connection can't be responded!!

今天,当我的应用程序/ iPhone尝试向DA14580设备发送命令时,根本没有回复,但我可以看到来自广告的数据。在另一个词,广告很好地运作。我试图使用LightBlue来测试它,结果相同(这意味着我的应用程序运作良好)。LightBlue的报告“在被询问时的外围断开连接”。重置DA14580后,它再次运行得很好,这种情况非常难以复制,但它是产品的致命问题。

I can't find any issue from my side. I think there may be a bug somewhere for disconnection. I'm not sure if there is any problem from advertising data updated by stop_advertising and start_adverting, but the advertising data is sent and can be received well by my app. Please help!

谢谢!

TR_Dialog
Offline
Last seen:3个月2天前
Staff
Joined:2014-06-30 23:52
嗨,亚历克斯:

嗨,亚历克斯:

我怀疑您的示例128配置文件不是正确的,特别是例程“Sample128_Create_db_req_handler”。你能发布你的日常生活吗?

谢谢,

TR_DIALOG

Alex Luo
Offline
Last seen:1年3个月前
专家
Joined:2014-02-28 19:16
Hi TR,

Hi TR,

该代码在大部分时间内运作良好,问题很少发生。如果发生这种情况,则无法一直在进行连接,并将其修复其重置DA14580的唯一方法 - 这是致命的问题。请查看下面的例程。

静态int sample128_create_db_req_handler(ke_msg_id_t const msgid,
struct sample128_create_db_req const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
//Database Creation Status
UINT8_T状态;
uint8_t nb_att_16;
uint8_t nb_att_128;
uint8_t nb_att_32;
uint16_t att_decl_svc = ATT_DECL_PRIMARY_SERVICE;
UINT16_T ATT_DECL_CHAR = ATT_DECL_CHAROMATION;
uint16_t att_decl_cfg = ATT_DESC_CLIENT_CHAR_CFG;
uint16_t val_hdl;
uint16_t char_hdl;

//保存配置文件ID
sample128_env.con_info.prf_id = task_sample128;

/ *---------------------------------------------------*
* Sample128服务创建
*---------------------------------------------------*/

//Add Service Into Database
nb_att_16 = 6;
/ * 1主要服务属性

char1的+ 1值属性

char2的+ 1值属性
+ 1 Client Characterisitic Configuration attribute for char 2

char3的+ 1值属性
+ 1 Client Characterisitic Configuration attribute for char 3

= 6
*/
nb_att_32 = 0;// No UUID32 attributes

nb_att_128 = 3; //3 UUID128 attribute types, one for each of the three custom characteristics

status = attmdb_add_service(&(sample128_env.sample128_shdl), TASK_SAMPLE128,
nb_att_16, nb_att_32, nb_att_128, 106); // 106: changed from 1B to 20Byte, 87 bytes total size

/ *
16 bytes value for the service UUID

+ 19 bytes declaration of the first characteristic (1 Byte properties + 2 bytes value handle + 16 bytes UUID = 19 bytes)
+ 20/1数据的第一个特征的字节
+ 0 bytes client configuration of the first characteristic (no notify or indicate on the first char)

+ 19字节的第二个特征声明(1字节属性+ 2字节值句柄+ 16字节UUID = 19字节)
+ 1 byte of data for the second characteristic
+ 2字节客户端配置的第一个特征(第二个特征上允许通知)

+ 19 bytes declaration of the third characteristic (1 Byte properties + 2 bytes value handle + 16 bytes UUID = 19 bytes)
第三个特征+ 8个字节的数据
+ 2 bytes client configuration of the third characteristic (Notify is permitted on the third characteristic)

= 106 bytes

*/

if(status == att_err_no_error)
{
//添加SVC value属性
status = attmdb_add_attribute(sample128_env.sample128_shdl,att_uuid_128_len,// data size = 16(att_uuid_128_len)
ATT_UUID_16_LEN,(UINT8_T *)&ATT_DECL_SVC,PERM(RD,ENABLE),
&(sample128_env.sample128_shdl));

status = attmdb_att_set_value(sample128_env.sample128_shdl,att_uuid_128_len,(uint8_t *)sample128_svc.uuid);

//////字符1
//添加char1属性
= attmdb_add_attribute (sample128_env.sample地位128_shdl, ATT_UUID_128_LEN + 3, //Data size = 19 (ATT_UUID_128_LEN + 3)
ATT_UUID_16_LEN,(UINT8_T *)&ATT_DECL_CHAR,PERM(RD,ENABLE),
&(char_hdl));

//add char1 val attribute
= attmdb_add_attribute (sample128_env.sample地位128_shdl, 20, //sizeof(uint8_t); Data size = 1
ATT_UUID_128_LEN, (uint8_t*)&sample128_1_val.uuid, PERM(RD, ENABLE) | PERM(WR, ENABLE),
&(val_hdl));

memcpy(sample128_1_char.attr_hdl, &val_hdl, sizeof(uint16_t));

status = attmdb_att_set_value(char_hdl, sizeof(sample128_1_char), (uint8_t *)&sample128_1_char);

//////字符2
//添加char属性,第二个特征
= attmdb_add_attribute (sample128_env.sample地位128_shdl, ATT_UUID_128_LEN + 3, //Data size = 19 (ATT_UUID_128_LEN + 3)
ATT_UUID_16_LEN,(UINT8_T *)&ATT_DECL_CHAR,PERM(RD,ENABLE),
&(char_hdl));

//add val attribute, Second characteristic
= attmdb_add_attribute (sample128_env.sample地位128_shdl, sizeof(uint8_t), //Data size = 1
ATT_UUID_128_LEN, (uint8_t*)&sample128_2_val.uuid, PERM(RD, ENABLE) | PERM(NTF, ENABLE),
&(val_hdl));

memcpy(sample128_2_char.attr_hdl,&val_hdl,sizeof(uint16_t));

status = attmdb_att_set_value(char_hdl, sizeof(sample128_2_char), (uint8_t *)&sample128_2_char);

//add cfg attribute, Second characteristic
status = attmdb_add_attribute(sample128_env.sample128_shdl,sizeof(uint16_t),
ATT_UUID_16_LEN,(UINT8_T *)&ATT_DECL_CFG,PERM(RD,ENABLE)|perm(wr,启用),
&(val_hdl));

//////字符3.
//添加char属性,第三个特征
= attmdb_add_attribute (sample128_env.sample地位128_shdl, ATT_UUID_128_LEN + 3, //Data size = 19 (ATT_UUID_128_LEN + 3)
ATT_UUID_16_LEN,(UINT8_T *)&ATT_DECL_CHAR,PERM(RD,ENABLE),
&(char_hdl));

//add val attribute, Third characteristic
status = attmdb_add_attribute(sample128_env.sample128_shdl,8,// data size = 8字节
ATT_UUID_128_LEN,(UINT8_T *)和SAMPLE128_3_VAL.UUID,PERM(RD,ENABLE)|perm(ntf,启用),
&(val_hdl));

memcpy(sample128_3_char.attr_hdl,&val_hdl,sizeof(uint16_t));

status = attmdb_att_set_value(char_hdl,sizeof(sample128_3_char),(uint8_t *)和sample128_3_char);

//添加CFG属性,第三个特征
status = attmdb_add_attribute(sample128_env.sample128_shdl,sizeof(uint16_t),
ATT_UUID_16_LEN,(UINT8_T *)&ATT_DECL_CFG,PERM(RD,ENABLE)|perm(wr,启用),
&(val_hdl));

//禁用示例128服务
attmdb_svc_set_permission(sample128_env.sample128_shdl, PERM(SVC, DISABLE));

//转到空闲状态

//If we are here, database has been fulfilled with success, go to idle state
ke_state_set(TASK_SAMPLE128, SAMPLE128_IDLE);
}

//Send CFM to application
struct sample128_create_db_cfm * cfm = KE_MSG_ALLOC(SAMPLE128_CREATE_DB_CFM, src_id,
TASK_SAMPLE128, sample128_create_db_cfm);
cfm->status = status;
ke_msg_send(cfm);

return (KE_MSG_CONSUMED);
}

Alex Luo
Offline
Last seen:1年3个月前
专家
Joined:2014-02-28 19:16
请帮忙!

请帮忙!

VesaN
Offline
Last seen:5年7个月前
格鲁鲁 Master
Joined:2014-06-26 08:49
Hello Alex Luo,

Hello Alex Luo,

are you sure that the problem is software related? Are you using your own design?

You can also try to reset the BLE subsystem with allocating and sending GAPM_RESET message.

struct gapm_reset_cmd * cmd = ke_msg_alloc(gapm_reset_cmd,task_gapm,task_app,gapm_reset_cmd);
cmd->操作= gapm_reset;
ke_msg_send(cmd);

gapm_cmp_evt_handler.will set the device configuration again so you don't need to worry about that.

Alex Luo
Offline
Last seen:1年3个月前
专家
Joined:2014-02-28 19:16
嗨Vesa,

嗨Vesa,

Thanks for your advice.,

Yes, it's based on my design and the problem is software related but I can't figure out what is the reason to cause the issue.

After I updated the advertising data, I found the problem ( can't be connected between iPhone and DS14580) for 2-3 time recently. After resetting, it works properly again.

为您的建议,我认为S / W必须在分配和发送CAPM_RESET之前检测BLE是否无法连接。如果S / W可以检测到问题,则很容易修复它。知道BLE连接问题是否存在的任何想法或始终断开连接?

More clues: I used LightBlue to connect DA14580 when I found the connection problem between my iphone and DA14580. LightBlue tool reported "The peripheral disconnected while being interrogated" ... It means that DA14580 disconnected after iPhone try to connect.

谢谢,