您好团队对话框,
I have written a program based on the ble_central project, which finds BLE devices with a special name or MAC address.
If a device is found, I connect to it and then I write into a characteristic.
我的问题是:
Every time I try to write to the peripheral, the status is 3 (ATT_ERROR_WRITE_NOT_PERMITTED) at the Write-Completed-Event.
When I try to do it with my mobile phone via nRF Connect App, I can read and write without any problems.
Tried out as a peripheral a Raspberry Pi, my mobile phone and also a Dialog 14680.
Every time the status is 3.
printf("start write\r\n"); uint16_t * mtu = 0; ble_gattc_get_mtu(evt->conn_idx, mtu); printf("MTU Rate: %u\r\n", *mtu); uint8_t test = 0x00; printf("uuid: %s\r\n",format_uuid(&charact[0].uuid)); printf("write\r\n"); ble_gattc_write(evt->conn_idx, charact[0].handle ,false , sizeof(test) ,&test);
charact[0] contains the handler from the Characteristic.
Many thanks for the effort in advance.
最好的祝福
HDR.
Keywords:
设备:
Hi hdr,
Thanks for your question on our public BLE forums. Could you please indicate what is the peripheral? Is another DA14682?
Thanks, PM_Dialog
I used a Raspberry Pi with PyBluez as peripheral, my mobile phone with the above mentioned app and a Dialog 14680. I'm now trying a DA 14682 as I can't access the 14680 because the device is potted.
HI hdr
i have same request
can you tell me what is Write-Completed-Event and how to use??
thanks
如果我理解这一点correctly, the Write_Completed_Event is called when I call a ble_gattc_write and it has been executed. In the event I get back the conn_idx, the handler and a status code. In my case the status code is 3, which stands for ATT_ERROR_WRITE_NOT_PERMITTED.
To describe how to use the event, I would refer to the ble_central example project.
HI hdr
i also use ble_gattc_write and i add Write_Completed_Event to app_task.c as below , Is this right when ble_gattc_write Completed??
static const struct ke_msg_handler app_gap_process_handlers [] =
{
{GAPM_DEVICE_READY_IND, (ke_msg_func_t)gapm_device_ready_ind_handler},
{GAPM_CMP_EVT, (ke_msg_func_t)gapm_cmp_evt_handler},
{GAPC_CMP_EVT, (ke_msg_func_t)gapc_cmp_evt_handler},
{GAPC_CONNECTION_REQ_IND, (ke_msg_func_t)gapc_connection_req_ind_handler},
{GAPC_DISCONNECT_IND, (ke_msg_func_t)gapc_disconnect_ind_handler},
{GAPC_GET_DEV_INFO_REQ_IND, (ke_msg_func_t)gapc_get_dev_info_req_ind_handler},
{GAPC_SET_DEV_INFO_REQ_IND, (ke_msg_func_t)gapc_set_dev_info_req_ind_handler},
{GAPM_PROFILE_ADDED_IND, (ke_msg_func_t)gapm_profile_added_ind_handler},
{gapm_adv_report_ind,(ke_msg_func_t)gapm_adv_report_ind_handler},
{gapc_param_update_req_ind,(ke_msg_func_t)gapc_param_update_req_ind_handler},
{GAPC_LE_PKT_SIZE_IND, (ke_msg_func_t)gapc_le_pkt_size_ind_handler},
{gapc_con_rssi_ind,(ke_msg_func_t)gapc_get_con_rssi_ind_handler},// alex添加20191030
{GATTC_READ_IND, (ke_msg_func_t)app_read_ind_handler}, //alex test 2020 0710
{GATTC_SDP_SVC_IND, (ke_msg_func_t)app_disc_all_svc }, //alex test 2020 0710
{gattc_cmp_evt,(ke_msg_func_t)alex_gattc_cmp_evt_handler},// Alex Test 2020 0716
//{GAPC_PEER_ATT_INFO_IND, (ke_msg_func_t)app_read_dev_ver_ind_handler}, //alex test 2020 0710
#if (BLE_APP_SEC)
{GAPC_SECURITY_IND, (ke_msg_func_t)gapc_security_ind_handler},
#endif
};
我认为你使用另一个SDK和对话芯片。
Hi hdr,
感谢您的详细回复。根据Bluetooth LE规格:
“如果由于权限而无法写入属性值,则应使用错误代码«不允许写入错误响应»。“
Could you please check if the characteristic ( in the Peripheral side ) has write permission? If yes, then I would suggest to double check if the Central (DA14682) writes to the correct handler (charact[0].handle).
此外,这将是非常有用的BLE sniffer log, so that we can understand what is happening over the air.
Thanks, PM_Dialog
Hello,
外围设备中的特性具有许可写入,并且处理程序应该是正确的。
Here is my Code from the Dialog 14682 Peripheral(same result status is 3):
With my mobile phone I can write in the characteristic.
嗨,亚历克斯,
谢谢你的评论,但请培养另一个论坛线程。具体论坛主题与DA14682和SDK1.0.14有关。据我所知,您在设计中使用DA14585和SDK6,因此请使用您的问题创建另一张票。
Thanks, PM_Dialog
Hi hdr,
Thansk fro gettign back. Could you please provide a BLE sniffer capture/
Thanks, PM_Dialog
Hello,
不幸的是,我们没有嗅探的可能性。
We will continue to search for the error and contact you if we find any new information.
Hi hdr,
Yes please, any further input would be very helpful.
Thanks, PM_Dialog
Hello,
Thanks very much for the help. I found my mistake.
我的手柄确实错了。我应该为句柄_VattC_Discover_char方法中的句柄分配EVT-> Value_Handle。
Thank you very much
HDR.
Hi hdr,
Glad that you figured this out and thanks for your indication.
Thanks, PM_Dialog