编写设备名称(0 x2a00)不变性ic to change the device name

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
11 posts / 0 new
Last post
stanley_yeh
Offline
Last seen:1 year 11 months ago
加入:2016-12-23 06:52
编写设备名称(0 x2a00)不变性ic to change the device name

Hi Dialog,

My customer want to use Device Name(0x2A00) characteristic of Generic Access(0x1800) to modify the device name.

I modified the user_gapm_conf in user_config.h as below...

.att_cfg = GAPM_MASK_ATT_SVC_CHG_EN | GAPM_MASK_ATT_NAME_PERM,

I also add some debug log in "default_app_on_set_dev_info" function but it seems not working.

Is there any wrong?

My device info. DA14585, SDK:6.0.4

Thanks.

Device:
MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi stanley_yeh,

Hi stanley_yeh,

Well there seems to be a problem in the callback function gapc_set_dev_info_req_ind_handler() the task that the confirmation is send should be TASK_GAPC and not TASK_GAPM, also the callback doesn't actually change the devices name, so as soon as you get the callback you should change the devices name in the application callback. I am checking with the SDK team on this, i will let you know as soon as i have some feedback.

Thanks MT_dialog

stanley_yeh
Offline
Last seen:1 year 11 months ago
加入:2016-12-23 06:52
Thank you so much!

Thank you so much!

stanley_yeh
Offline
Last seen:1 year 11 months ago
加入:2016-12-23 06:52
Hi MT_dialog,

Hi MT_dialog,
I tried to print some messages in app_entry_point_handler and gapc_set_dev_info_req_ind_handler functions.
However, It seems that DA14585 did not receive any event.
Can I fix this issue by myself? Does this issue have to update the system_library.lib that I can't fix it?
Thanks.

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi stanley_yeh,

Hi stanley_yeh,

The current implementation allows you to have a callback notifying you when someone writes at that specific characteristic, but there is no actual implementation in changing the name in the database, and this is what the SDK team is investigating. So if you are interested in just getting the callback when someone writes at that specific characteristic all you have to do is make the below changes:

  1. In the gapc_set_dev_info_req_ind_handler() change the destination task of the gapc_set_dev_info_cfm() from TASK_GAPM to TASK_GAPC.
  2. Then in the user_config.h file change the .att_cfg member of user_gapm_conf structure to GAPM_MASK_ATT_SVC_CHG_EN|0x01 in order to enable the write with no security to the specific characteristic.

After the above changes you should see the default_app_on_set_dev_info() callback to occur, but again this is only an indication that the central has written on that characteristic, this wont change the name in database.

Thanks MT_dialog

stanley_yeh
Offline
Last seen:1 year 11 months ago
加入:2016-12-23 06:52
Hi MT_Dialog,

Hi MT_Dialog,
Thank you very much. I can receive the event now.
I am sorry that I can't understand what's the meaning of following sentences:

1. "this wont change the name in database."
Could you tell me the risk and what will happen if the name in the database can not be changed?
Do you mean that the device name is a definition in SDK (#define USER_DEVICE_NAME "DA14585"), so there is no actual implementation to change it?
Actually, I have implemented a function that can store the device name into external flash. So the sentence you said has no effect to my case, right?

2. "to enable the write with no security to the specific characteristic."
My customer said the write characteristic must be with security. I can't understand why the GAPM_MASK_ATT_NAME_PERM doesn't work?

Thanks a lot.

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi stanley_yeh,

Hi stanley_yeh,

1) About what will happen, as the SDK is, at the moment whatever you write at the device the SDK will not store the name that you provided it will just send the value to the device, you will be able to get it, but the name of the device once you read it agan wont change and the device will report the same name as before. So, yes in the SDK there is no actual implementation to change it. I am not aware exactly what you mean by saying that you ve implemented a function that store's the device's name in an external flash. But in order to be able to change the name of the device via that characteristic you will have to apply changes to the SDK itself, apparently you will have to assign a pointer to the USER_DEVICE_NAME instead of a fixed name, the pointer will show to an array that will be used to store the actual device's name and whenever changing the name via writting to that characteristic you will have to copy the data from the writing to that array.

2) Each characteristic has some security features, if enabled. That means that if you have assigned the value of 0x03 (GAPM_MASK_ATT_NAME_PERM) to the device's name characteristic, that means that in order to be able to write at that characteristic the device demands the link to be secured with authentication. So if the link has no authentication, that means that the device wont allow you to write at that specific characteristic since you dont comply to the requirements that device has set. On the other hand if you apply the value of 0x01, that means that you enable the writting of the characteristic but with no additional security, meaning that whoever connects to the device is able to write the characteristic.

Thanks MT_dialog

stanley_yeh
Offline
Last seen:1 year 11 months ago
加入:2016-12-23 06:52
Hi MT_dialog,

Hi MT_dialog,
I am really grateful for your detail information.
For the first question, I can save the device name by myself. That's no problem.
For the second question, I still need the security features, please let me know if there is any new SDK version.
Many thanks.

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi stanley_yeh,

Hi stanley_yeh,

The most recent version of the SDK is the 6.0.6, and there is a project that implements security allready (ble_app_security), i dont quite get what is the problem exactly. If you apply the value GAPM_MASK_ATT_SVC_CHG_EN|0x03 then in order to write to the characteristic would require security, if pairing is not initiated then you wont be able to write to the characteristic. If you dont want protection for that characteristic then GAPM_MASK_ATT_SVC_CHG_EN|0x01 for the .att_cfg will allow you to write to the characteristic without security.

Thanks MT_dialog

stanley_yeh
Offline
Last seen:1 year 11 months ago
加入:2016-12-23 06:52
Hi MT_Dialog,

Hi MT_Dialog,
I am using SDK 6.0.6 now and I also set ".att_cfg = (GAPM_MASK_ATT_SVC_CHG_EN | 0x03)" for security.
First time I write a string to the characteristic, the app shows they're bonding.
After bonding, I still cannot set the device name. The app shows "Error 0x5: GATT INSUF AUTHENTICATION"
Should I modify the parameter from TASK_GAPM to TASK_GAPC in the "gapc_set_dev_info_req_ind_handler" function as below?
struct gapc_set_dev_info_cfm* cfm = KE_MSG_ALLOC(GAPC_SET_DEV_INFO_CFM,
TASK_GAPC,/*TASK_GAPM,*/
TASK_APP,
gapc_set_dev_info_cfm);
Could you give me some advice?
thanks a lot.

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi stanley_yeh,

Hi stanley_yeh,

As stated in my previous post the SDK as is doesn't implement changing the device's name but it will trigger you an indication in application level, so i suppose that you have applied a custom modification, also you will have to change from TASK_GAPM to TASK_GAPC in order to send back a verification to the peer device that you have accepted or not the change. Regarding the GATT_INSUF_AUTHENTICATION this is what you should get the first time you try to set the name and the central initiates bonding (in the case of the ble_app_security), after bonding is done the callback (default_app_on_set_dev_info) will occur and you will have to handle the reception of the name in the application and decide either to accept or reject the new name and send back the GAPC_SET_DEV_INFO_CFM with the appropriate status, in order to properly send back the confirmation you will have to change from TASK_GAPM to TASK_GAPC.

Thanks MT_dialog