Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 4 months ago.
How do i use ble.gattServer().onDataWritten?
I'm using UARTService class of BLE library in my app. I have a problem with ble.gattServer().onDataWritten().
I added this line in my main() function so that it will be notify of onDataWritten event:
ble.gattServer().onDataWritten(&onDataWritten);
my onDataWritten handler is:
void onDataWritten(const GattWriteCallbackParams * params)
{
receivedCommandEvent =true;
}
in the while loop of main function:
while (true) {
....
if(receivedCommandEvent)
{
while(int command = uart->_getc() != EOF)
{
if(command == 1)
{
//turn on something.
}
else if (command == 0)
{
//turn off something.
}
}
receivedCommandEvent = false;
}
ble.waitForEvent();
}
but this seem a wrong way to handle onDataWritten, i got error value for command variable in every run. What is the right way to handle onDataWritten then?