Hi Dialog,
I am working for central role application using DA14580. I am following DSPS SDK 5 host example. I struck into discovering services and attributes of peripheral GATT profile. Code is not very clear. Is there some document or some other simple code example with central role to show proper flow of GATT command and events for central side.
I am using Android smartphone as peripheral.
thanks,
sabasit
Device:
Hi sabasit,
Unfortunatelly there is no documentation regarding the flow of the discovery of the services. But you can have a look at the RW-BLE-GATT-IS pdf where the service discovery commands and messages are documented, you can also use the proximity monitor application in order to check how the interaction between the application and the profile in the 580 occurs, its simpler than the DSPS and the messages .
Thanks MT_dialog
Hi MT_dialog,
Based on DSPS SDK 5, I call function "prf_disc_svc_send_128(&spsc_env->con_info, spsc_env->last_svc_req)" on connection to get service of connected device. After that "gattc_cmp_evt_handler" is called on GATTC complete event. In this function I am not getting correct profile service handler . The service handler "spsc_env->sps.svc.shdl" is 0x00 always.
what could be the reason?
Thanks,
sabasit
Hi sabasit,
Theprf_disc_svc_send_128() function sends a GATTC_DISC_CMD with ranges between the maximum and the minimum available handles 1 up to 65535, the peripheral should respond with the actual handles where the available service is located in the database, when the service is located, you should get a GATTC_DISC_SVC_IND at your device that indicates that specific handles is the range of the peripheral's service, you should store the handles of that service in the spsc_env->sps.evc.shdl (starting handle), so that when the service discovery is complete you can search the appropriate handles for the available characteristics. Please check thegattc_disc_svc_ind_handler in the DSPS host application.
Thanks MT_dialog
Hi MT_dialog,
Thank you. We have got GATTC_DISC_SVC_IND which gives the handler of service and the associated UUID is read correctly. After that we discovered attributes using prf_disc_char_all_send(..) function which triggers GATTC_DISC_CHAR_IND and it gives the handlers of characteristics and the associated UUIDs correctly.
Next when we tried to read value of characteristic which is of two bytes using function rf_read_char_send(&spsc_env->con_info, 0x00, 0xFF, spsc_env->abrs.chars[0].char_hdl); for simple read, this gives us event GATTC_READ_IND with handler function static int gattc_read_ind_handler(ke_msg_id_t const msgid,
struct gattc_read_ind const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
但是,length received is incorrect i.e. 0x13 instead of 2. And the value read is fixed always i.e. 0x022A which is wrong and it supposed to be changed with every read.
Could you guide us what steps we are doing wrong or what we need to check at our end. The peripheral side is an Android app.
Thanks,
I guess we were using wrong handler in function rf_read_char_send(&spsc_env->con_info, 0x00, 0xFF, spsc_env->abrs.chars[0].char_hdl); i.e. abrs.chars[0].char_hdl. A valhdl should be used which solves the problem. Characteristic read write from client is working now.
Thanks.
嗨sabasit !
I'm also working on the GATT client for a central role based device. I have problem understanding the data flow of the GATT client. Could you describe the flow of the GATT client. Preferably, if you could share a small code snippet how to read and write to a simple 128 bit UUID on the remote peripheral?
Thank you!
Hi quangng,
As mentioned above if you are looking for an example you can have a look at the DSPS HOST example and check the discovery procedure that the Host applies and also the documentation mentioned above, that RW_BLE_GATT_IS explains the commands as well as the expected responses, check paragraph 4.4. Also a few details are provided via mail.
Thanks MT_dialog