我正在使用ble_examples\ble_app_peripheral项目的SDK
我通过发送GATTM_ADD_SVC_REQ消息来添加一个新服务,如下所示:
step0 struct gattm_add_svc_req * req = KE_MSG_ALLOC(gattm_add_svc_req,TASK_ATTM,TASK_APP,gattm_add_svc_req);请求-> task_id = TASK_APP;Req -> total_size = 36;// 16 + 19 +1 req-> nb_att_uuid_16 = 2;Req -> nb_att_uuid_32 = 0;Req -> nb_att_uuid_128 = 1;申请- > start_hdl = 0;ke_msg_send(要求的);
我在user_catch_rest_hndl(…)函数中得到了GATTM_ADD_SVC_RSP响应
然而,当我在user_catch_rest_hndl(…)中执行以下代码step2时,程序将会死亡:
case GATTM_ADD_SVC_RSP: {struct GATTM_ADD_SVC_RSP const *msg_param = (struct GATTM_ADD_SVC_RSP const *)(param);if(msg_param->status==ATT_ERR_NO_ERROR){arch_printf("GATTM_ADD_SVC_RSP成功%d\n",msg_param->start_hdl);} arch_printf_process ();svc_handle = msg_param - > start_hdl;step1 // Add svc decl attribute struct gattm_add_attribute_req * addreq = KE_MSG_ALLOC(gattm_add_attribute_req,TASK_ATTM,TASK_APP,gattm_add_attribute_req);Addreq ->start_hdl = svc_handle;//从svc的成功rsp以上addreq ->perm = perm (RD, ENABLE);addreq ->uuid_len = ATT_UUID_16_LEN;addreq ->max_data_size = ATT_UUID_128_LEN;uint16_t att_decl_svc = ATT_DECL_PRIMARY_SERVICE; memcpy(addreq ->uuid, &att_decl_svc, sizeof(att_decl_svc)); ke_msg_send(addreq ); step2 //Set svc uuid value struct gattm_att_set_value_req * setreq = KE_MSG_ALLOC(GATTM_ATT_SET_VALUE_REQ,TASK_ATTM,TASK_APP,gattm_att_set_value_req); setreq ->handle =svc_handle; setreq ->length = ATT_UUID_128_LEN; uint8_t svc_uuid[16]={1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6}; memcpy(setreq ->value, svc_uuid, sizeof(svc_uuid)); ke_msg_send(setreq); } break;
仅执行step1的代码不会杀死程序
你认为第2步和第0步的作用是什么?
设备:
嗨TM_Dialog
我正在使用ble_examples\ble_app_peripheral项目的SDK
嗨chenpenglai,
你有没有跟着教程3:构建自定义概要文件从我们的支持网站?你说"不会扼杀程序"是什么意思?你在调试模式下运行它了吗?是否被困在某个地方?
谢谢,PM_Dialog