Read and Write data using Custom service

I want to read and write text data using a custom service. I have added the service and characteristics. But I could not read and I am not able to decode the data which I have written. Is there any sample programs for custom service? Please look into this and suggest your opinion.


You can use peripheral_server_uart and central_client_uart examples .

To verify the Bluetooth Low Energy functionality, use RSL10 or another third-party central device application to establish a connection. In addition to establishing a connection, this application can be used to read/write characteristics and receive notifications.

ble_custom.c - Support functions and message handlers pertaining to the Custom Service Server

GATT : Server ,

Write random values for instance 1 , 2, etc.

GATT : Client

On the receive site random values data entered via phone application will be visible in UART terminal.
Binary tab values : 0b0001 , 0b0010 etc.


GATT: Server

Type your data in UART terminal . In this case Hexadecimal format 0x6F to be sent to the connected Client RSL10.


GATT: Client

Data 0x6F can be read in the mobile phone application.

Hi martin.bela,

Thanks for your reply.

Hello, I have quesiton for write confirmation response.
Mobile writes me an ID from Rx channel which is in custom service. I want to send confirmation message for that. However I could not find how can I find it? I’m usign ble_peripheral_server_cgm example.

Can you explain which function and how can I use it ?



Hello Omur,

Could you please explain "
Mobile app write something for rsl10, I can take this but when it writes me, I want to send confirmation message " .

Do you want for the GATT server , peripheral unit sent notification for the GATT client ?

Hello Martin, my question is that Mobile app sends me unique ID from custom service receive uuıd. I can read this id however when I take this unique id, I want to send response immediately.

According to my search, I saw that there is gattc with response command on other ble , but ı cant see it at your document. At your document, there is gattc_send_confirmation, is it same thing to send response? İf so, how can I use it?

If this is custom service question, we have ble_custom.c.
You could find that we use gattc confirmation to response.

How to use it?

Please reference:
Our ble_custom.c —> GATTC_WriteReqInd
Our ble_custom.c —> GATTC_ReadReqInd\


Thank you for using our community forum !

Hello Martin,
I found these in code however it does not send any response to mobile. If mobile sends me something, GATTC_WRITE_REQ_IND event is called however I want that when this GATTC_WRITE_REQ_IND event is called , I want to send response to mobile at instant moment. For example, mobile sends me something from custom service Rx channel, I will send a message back to it and say that “your message reached”.

It is like a handshake mechanism between rsl10 and mobile app. Mobile app sends something to rsl10 and get back message from it to check message reached or not ?

Best Regards

Let’s look at the GATTC_WriteReqInd().
It does provide the confirmation with status response.
The confirmation structure uses this:
/// Confirm modification of database from upper layer when requested by peer device.

struct gattc_write_cfm
/// Handle of the attribute written
uint16_t handle;
/// Status of write command execution by upper layers
uint8_t status;

In the GATTC_WriteReqInd(), if everything is OK, RSL10 will provide the response with


and then use this to send message back.

cfm->handle = param->handle;
cfm->status = status;
/* Send the message */

I use ble_peripheral_server_cgm, the GATTC_WriteReqInd() inside is at below.

void GATTC_WriteReqInd(ke_msg_id_t const msg_id,
struct gattc_write_req_ind const param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
Retrieve peer device index */
signed int conidx = KE_IDX_GET(src_id);
struct gattc_write_cfm *cfm =
TASK_APP, gattc_write_cfm);
uint8_t status = GAP_ERR_NO_ERROR;
uint16_t attnum;

/* Verify the correctness of the write request. Set the attribute index if
 * the request is valid */
attnum = (param->handle - gatt_env.start_hdl);
if (param->offset)
else if (param->handle <= gatt_env.start_hdl)
else if ((attnum >= gatt_env.att_db_len) ||
         !(gatt_env.att_db[attnum].att.perm & (PERM(WRITE_REQ, ENABLE) | PERM(WRITE_COMMAND, ENABLE))))

/* If there is no error, copy the requested attribute value, using the
 * callback function */
if (status == GAP_ERR_NO_ERROR)
    if (gatt_env.att_db[attnum].callback != NULL)
        status = gatt_env.att_db[attnum].callback(conidx, attnum, param->handle, gatt_env.att_db[attnum].data, param->value,
                                                  MIN(param->length, gatt_env.att_db[attnum].length), GATTC_WRITE_REQ_IND);
    else /* No callback function has been set for this attribute, just do a memcpy */
        memcpy(gatt_env.att_db[attnum].data, param->value, MIN(param->length, gatt_env.att_db[attnum].length));
cfm->handle = param->handle;
cfm->status = status;

/* Send the message */


However in this situation , when we try to read something from mobile app , data values are meaningless. Should I remove some part of this code ?


Please correct me if we have misunderstood your questions.

At the beginning you asked the RSL10 to provide an response to Mobile Phone.
" I found these in code however it does not send any response to mobile. "
and he pointed to GATTC_WriteReqInd() for response.
From this, I think the Mobile phone is writing something into RSL10 and RSL10 has GATTC_WriteReqInd() and confirm an response to Mobile Phone.

Now you are saying “we try to read something from mobile app”.

This is NOT RSL10 confirmation (response) question.
This is RSL10 would like to send command to read something from Mobile Phone.

The reference for gattc is in the document RW-BLE-GATT-IS.pdf in the ceva folder.

Hello Martin,
" I think the Mobile phone is writing something into RSL10 and RSL10 has GATTC_WriteReqInd() and confirm an response to Mobile Phone." This is correct idea. I wrote it wrongly at second part.

According this , can you explain me how I do that ?

You can see we have a topic for “KB: Test the Read/Write function of “ble_peripheral_server” Architecture”.
It also shows the mobile write /read example.

You can use Nordic nRF connection phone application to practice this.

What kind of event is triggered on RSL10 side when customer was doing “write” action on the phone side?

For example:
a. Client send write message to server and ask response from peer device.
b. Client send indication to request attribution inform.

on the RSL10 side, it will have …

Moreover , for the GATTC_WRITE_CMD, there are two confirmations based on which kinds of writing from client.

a. one is for “write characteristic Value” – It needs response
b. one is for “write long characteristic Value” – It needs response

Thank you for using our community forum!