cancel
Showing results for 
Search instead for 
Did you mean: 

Client to Server write with notification problem (BLUENRG-1)

nibbly78
Associate III

I'm trying to :-

A> use one characteristic that Server can use to write data to Client with indication

B> use same characteristic so that Client can send data to Server with indication

the characteristic is set up as follows aci_gatt_add_char(....CHAR_PROP_READ|CHAR_PROP_INDICATE|CHAR_PROP_WRITE on both Client and Server

I have achieved A> and works pretty well, however I'm having problems with B>

the problem is even though I can send easily send the data from Client to Server and Server is receiving the data in the aci_gatt_notification_event() 

0690X00000AsXtgQAF.png

How can I achieve notification back? I'm happy to have the Client >> Server write on a separate Characteristic 

11 REPLIES 11
Winfred LU
ST Employee

Please try to call ACI_GATT_SET_EVENT_MASK enabling ACI_GATT_ATTRIBUTE_MODIFIED_EVENT

Whenever an ATT write comes, there shall be an ACI_GATT_ATTRIBUTE_MODIFIED_EVENT reported.

nibbly78
Associate III

thanks, I'll give that a try

nibbly78
Associate III

I've added but now I can't connect?

won't just writing ACI_GATT_ATTRIBUTE_MODIFIED_EVENT wipe out all the other masks?

I see in bluenrg1_gatt_aci.h >>>

 @brief Mask events from the GATT. The default configuration is all the events masked

so ACI_GATT_ATTRIBUTE_MODIFIED_EVENT should already be set? Also, is ACI_GATT_ATTRIBUTE_MODIFIED_EVENT defined somewhere?

nibbly78
Associate III

I did ret = aci_gatt_set_event_mask(0x7FFFF); on server end and added aci_gatt_attribute_modified_event() handler but handler never gets call even though the write is still working.

What was wrong with catching the write responce in aci_gat_notification_event() in my original post- this works (its just I cant send a notification back to say that I have received.

Winfred LU
ST Employee

If the attribute property includes "write", the GATT write request would have the write response already.

In case you need to know whenever the characteristic is updated, please add "notify" in its properties during configuring the database, then subscribe the notification from the client.

nibbly78
Associate III

I added CHAR_PROP_INDICATE so now have

aci_gatt_add_char(....CHAR_PROP_READ|CHAR_PROP_INDICATE|CHAR_PROP_WRITE|CHAR_PROP_INDICATE

but aci_gatt_notification_event() still doesn't get called on client.

Also, when server sends data to client, client receives data push on notification AND on indication which is not what I need.

Winfred LU
ST Employee

If you add indicate property (CHAR_PROP_INDICATE), when an indication comes the aci_gatt_indication_event() will be called.

If you need notify, please add CHAR_PROP_NOTIFY, then the aci_gatt_notify_event() will be called when a notification is received.

Both these event callbacks only work on a GATT client.

aci_gatt_confirm_indication() can only be used by a GATT to confirm (send a confirmation back to the server) for a received indication.

Are you saying it's not possible to achieve what I'm asking for?

If not, then please please share with US how I can get some sort of acknowledgement on the CLIENT from the server that the server received the data.

No. I was saying that please do not misunderstand the notification and indication.

Notification is used when a server is configured to notify a Characteristic Value to a client without expecting any Attribute Protocol layer acknowledgment that the notification was successfully received.

0690X00000AtN4QQAV.png

Indication is used when a server is configured to indicate a Characteristic Value to a client and expects an Attribute Protocol layer acknowledgement that the indication was successfully received.

0690X00000AtN4VQAV.png

Back to the question of using ACI_GATT_UPDATE_CHAR_VALUE,

If notifications (or indications) are enabled on that characteristic, a notification (or indication) will be sent to the client after sending this command to the BlueNRG-1.

On the GATT client the callbacks will be called accordingly, either aci_gatt_notification_event() or aci_gatt_indication_event().

But in the case indication is used, on the client you have to confirm the indication reception using the command aci_gatt_confirm_indication().