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

Send text by BLE

I'm sending data from my phone to the device using nRF Connect app for android as follows 

uint8_t SoporteBLE::enviaTiempoEspera()
{
uint8_t tiempoEspera;
if(Bluefruit.connected()){
if (TiempoEspera.read8()) {
tiempoEspera = (uint8_t) TiempoEspera.read8();
delay(250);
}else{
tiempoEspera = 0;
}

}
return tiempoEspera;
}

It works fine, but I need to send text. I tried this, but don´t work

char * SoporteBLE::enviaSentido()
{
char * sentido;
if(Bluefruit.connected()){
if (Sentido.read16()) {
sentido = (char *) Sentido.read16();
delay(250);
}else{
sentido = 0;
}
}
return sentido;
}

What can i do for solve this problem?

Parents Reply Children
  • This code works with data of numerical type (values between 0 and 255)

    uint8_t SoporteBLE::enviaTiempoEspera()
    {
        uint8_t tiempoEspera;
        if(Bluefruit.connected()){
            if (TiempoEspera.read8()) {
                tiempoEspera = (uint8_t) TiempoEspera.read8();
                delay(250);
            }else{
                tiempoEspera = 0;
            }
        }
        return tiempoEspera;
    }

    But i need to send data of text type, String or char*, I'm using BLECharacteristic library, I tried with read64 function, but whe I try to send text, the module doesn't receive any data, if during configuratio of charcteristics I modifiy this value to a higher value, the module receives unreadable ASCII characters

    Sentido.setFixedLen(1); 
      

  •  I'm using BLECharacteristic library

    I have no idea what that is. It's not a Nordic thing, is it?

    Have you contacted the author for support?

    As noted above, Nordic's UART Service (NUS) can do what you require.

Related