Can't write characteristic value

5 posts / 0 new
Last post
sklin
Offline
Last seen:5 years 10 months ago
Expert
加入:2014-08-12 08:01
Can't write characteristic value

Hi Dialog
I add two charactristics in custom profile service(refer to sample128), and I can read the value by use a android phone.
But I fail to write the characteristic value in the service.What's the problem?
It seems that I can't receivce the msg(GATTC_WRITE_CMD_IND).Is there anything wrong in my code?

static int gattc_write_cmd_ind_handler(ke_msg_id_t const msgid,
struct gattc_write_cmd_ind const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
uint8_t char_code = SAMPLE128_ERR_CHAR;
uint8_t status = PRF_APP_ERROR;

if (KE_IDX_GET(src_id) == simpleKey_env.con_info.conidx)
{
if(param->handle == simpleKey_env.sample128_shdl + SIMPLE_KEY_VAL1)
{
char_code = SIMPLE_KEY_VAL1;
}
else if(param->handle == simpleKey_env.sample128_shdl + SIMPLE_KEY_CFG2)
{
char_code = SIMPLE_KEY_CFG2;
}

switch(char_code)
{
case SIMPLE_KEY_VAL1:
attmdb_att_set_value(param->handle,
sizeof(uint8_t),
(uint8_t *)¶m->value[0]);
if(param->last)
{
sample128_send_val(param->value[0]);
}
status = PRF_ERR_OK;
break;

case SIMPLE_KEY_CFG2:
uint16_t ntf_cfg;
ntf_cfg = co_read16p(¶m->value[0]);
if ((ntf_cfg == PRF_CLI_STOP_NTFIND) || (ntf_cfg == PRF_CLI_START_NTF))
{
attmdb_att_set_value(param->handle, sizeof(uint16_t), (uint8_t *)¶m->value[0]);
if (ntf_cfg == PRF_CLI_START_NTF)
{
simpleKey_env.feature |= PRF_CLI_START_NTF;
}
else
{
simpleKey_env.feature &= ~PRF_CLI_START_NTF;
}
status = PRF_ERR_OK;
}
break;
default:break;
}
}
atts_write_rsp_send(simpleKey_env.con_info.conidx, param->handle, PRF_ERR_OK);
return (KE_MSG_CONSUMED);
}

sklin
Offline
Last seen:5 years 10 months ago
Expert
加入:2014-08-12 08:01
I have solved the problem,it

I have solved the problem,it's cause by careless.
I set the permission of characteristic readable but not writable.

JE_Dialog
Offline
Last seen:1 month 1 week ago
工作人员
加入:2013-12-05 14:02
好的,谢谢Sklin . .

好的,谢谢Sklin . .

拉-m.sharkawy
Offline
Last seen:6 years 1 month ago
加入:2014-10-14 10:37
Hello Sklin and JE_Dialog,

Hello Sklin and JE_Dialog,

Sklin, you said in the post the following "I add two characteristics in custom profile service(refer to sample128),". Would you please clarify where did you add those characteristics ? in what structure, and in what file i mean.

Thanks in advance.

MT_dialog
Offline
Last seen:2 months 2 weeks ago
工作人员
加入:2015-06-08 11:34
Hi krishnacr,

Hi krishnacr,

You can use the Connection manager with the USB Dongle or with any development kit and operate it as central, or you can use any generic application for BLE on android play store like BLE Scanner, B-BLE etc.

Regarding the throughput question, there is no generic tool from dialog that will allow you to measure the throughput of your application or a thirdparty application as far as i know. If you wish to test your application the test should be application specific.

Thanks MT_dialog