I am trying to create an application that acts as the server of a serial port connection. To do this I am creating a custom profile with two characteristics:
Tx: sends 1 byte of data from the server to the client.
Rx: sends 1 byte of data from the client to the server.
I have followed tutorial 4 (creating a custom profile), but it only explains how to create characteristics that can be written to.
Clearly, Tx needs to be read from but I can't seem to find any examples of how to read from a characteristic on the website or in the example projects.
I also can't use sample128 as that is designed for SDK 3 and I am using SDK 5.
Could you point me in the right direction for some examples?
Thanks.
Keywords:
Device:
Hi jamartin,
Normally for the transmit, notifiable characteristics are used, for example the DSPS application in the server side it uses notifications in order to send data to the central, also you can have a look at the app_ble_peripheral project, it also uses notifiable characteristics in order to send data to the central.
Thanks MT_dialog
I have reviewed the ble_app_peripheral example, and it has many read + notify characteristics defined. Unfortunately, however, the handler function for each characteristic is left empty. So I can see what functions need to be written, however I'm not sure how to begin sending data to my client. (temporarily using lightblue on ios). As the code currently is, trying to read from a characteristic returns 'no value'. what do I need to do within the handler functions to send data to the client? Do I have to interact with the kernel? will I be able to send 1 byte at a time, or does the kernel wait until more data is available and send data to the client in packets of multiple bytes?
A detailed explanation or example would be greatly appreciated as I'm new to this.
Hi jamartin,
The ble_app_peripheral has the following functionallity, the user should write from the central side the control point characteristic, as soon as it written the handler user_custs1_ctrl_wr_ind_handler() in your peripheral (indicates to your application that the specified characteristic has been written) will be triggered. That function will trigger a timer, when the time elapses the handler of the timer will be invoked app_adcval1_timer_cb_handler(). The timer handler will allocate a notification message CUSTS1_VAL_NTF_REQ, that message includes the data to be sent to the central and send it to the custs1 profile. The custs1_val_ntf_req_handler() from the custs1_task.c will handle that message and will send the notification command to the stack, thus to the central. The central in order to receive those kind of notification needs to enable them. I hope the above explanation is sufficient to get you started.
Thanks MT_dialog
Thank you, that was very helpful. I will see if I can modify the ble_app_peripheral project to meet my needs.
Hi,
I had a similar question and this thread answered part of it, so thank you. I would also like to know more about the Notify operation.
I know the Central (client) device has to enable notifications to allow the server to push data. Is there a check I (the server) need to perform to know whether Notify has been enabled or not by the client?
Thanks,
Justin
Hi justinturley,
Yes, you can read the characteristic with the notify property with the attmdb_att_get_value() function and check if the value returned is equal to PRF_CLI_START_NTF. If it is that means that the central has enabled the characteristics, also you get an indication to your application when the central writes to your notifiable characteristic, please check the next posthttp://support.dialog-semiconductor.com/bug-report-multi-periodic-appeas....
Thanks MT_dialog