This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Which event should be triggered by a "write" operation?

Hi all! I have an application where i perform a "write command" with a device on the characteristic value of another device (client). I want on the client that when it receives an array of values by the write operation, to make something else, like sending the received values via uart or making some processing; so, i need something like an event to be put in the ble_evt_dispatch function where i will write all the further instruction to be executed when a write is received. How shall i do this? I tried simply to put a case BLE_GATTC_EVT_WRITE_RSPin on_ble_evt (but i don't know if this case does what i am looking for) but it doesn't work (the case is not executed after a write operation), what is the instructions that i should write to get an event in response of a write on my client? Maybe what i need is something like the event BLE_EVT_TX_COMPLETE but on the receiving side? Or also, the function for a data_handler for my characteristic?

Please note that of course i already checked that the write operation is successfully performed!

EDIT: i also tried with the event BLE_GATTS_EVT_WRITE, but it seems to cause a disconnection between the two devices...

our_service.c

Parents
  • A client doesn't receive write commands, it sends them. A server receives write commands.

    If a client sends a write command to a server you will receive the BLE_GATTS_EVT_WRITE event. Receiving this shouldn't cause a disconnection.

  • Ok sorry, i wrongly called the server client. I think the problem is the values that i am passing to the case BLE_GATTS_EVT_WRITE, because now i managed to make it enter there when the other device performs a write, but it doesn't do what i want! I posted the code of my service; as you can see, in ble_our_service_on_ble_evt i put the case BLE_GATTS_EVT_WRITE, stating that if a particular byte of the considered characteristic value is not zero, it should toggle a led (of course this doesn't happen). The problem is that, in my opinion, i don't pass the value correctly to the if statement. Can you suggest me ho, syntactically speaking, i refer to the characteristic value in that case?

Reply
  • Ok sorry, i wrongly called the server client. I think the problem is the values that i am passing to the case BLE_GATTS_EVT_WRITE, because now i managed to make it enter there when the other device performs a write, but it doesn't do what i want! I posted the code of my service; as you can see, in ble_our_service_on_ble_evt i put the case BLE_GATTS_EVT_WRITE, stating that if a particular byte of the considered characteristic value is not zero, it should toggle a led (of course this doesn't happen). The problem is that, in my opinion, i don't pass the value correctly to the if statement. Can you suggest me ho, syntactically speaking, i refer to the characteristic value in that case?

Children
No Data
Related