While receiving all data from a BLE device until a '\n' character is received, I get the following error:
invalid conversion from 'char' to 'const char*' [-fpermissive]
My Code:
String dataBLE;
if (Serial.available() > 0)
{
dataBLE = Serial1.readString(); //read Serial1 input and move to String dataBLE
if (dataBLE == '\n')
if (dataBLE == -1) //continue reading all of user input
continue;
// DEBUG
Serial.print(dataBLE);
}
I have a custom PCB 3.3V @ 12MHz with a ATMEGA328PB
I am using the MCUdude/MiniCore Boards File
Full Error message:
D:\GP Technology\Firmware-2019\T-Trax-12-FINAL-27092019\T-Trax-12-FINAL-27092019.ino: In function 'void ReadBeaconBLE()':
T-Trax-12-FINAL-27092019:180:24: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
if (dataBLE == '\n')
^
In file included from C:\Users\Robert\Documents\Arduino\hardware\MiniCore-master\avr\cores\MCUdude_corefiles/Arduino.h:287:0,
from C:\Users\Robert\AppData\Local\Temp\arduino_build_922042\sketch\T-Trax-12-FINAL-27092019.ino.cpp:1:
C:\Users\Robert\Documents\Arduino\hardware\MiniCore-master\avr\cores\MCUdude_corefiles/WString.h:143:17: note: initializing argument 1 of 'unsigned char String::operator==(const char*) const'
unsigned char operator == (const char *cstr) const {return equals(cstr);}
^
T-Trax-12-FINAL-27092019:182:27: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
if (dataBLE == -1) //continue reading all of user input
^
In file included from C:\Users\Robert\Documents\Arduino\hardware\MiniCore-master\avr\cores\MCUdude_corefiles/Arduino.h:287:0,
from C:\Users\Robert\AppData\Local\Temp\arduino_build_922042\sketch\T-Trax-12-FINAL-27092019.ino.cpp:1:
C:\Users\Robert\Documents\Arduino\hardware\MiniCore-master\avr\cores\MCUdude_corefiles/WString.h:143:17: note: initializing argument 1 of 'unsigned char String::operator==(const char*) const'
unsigned char operator == (const char *cstr) const {return equals(cstr);}
^
Using library Wire at version 1.0 in folder: C:\Users\Robert\Documents\Arduino\hardware\MiniCore-master\avr\libraries\Wire
Using library AltSoftSerial-master at version 1.4 in folder: C:\Users\Robert\Documents\Arduino\libraries\AltSoftSerial-master
Using library Adafruit_GPS_Library at version 1.1.1 in folder: C:\Users\Robert\Documents\Arduino\libraries\Adafruit_GPS_Library
Using library SoftwareSerial at version 1.1 in folder: C:\Users\Robert\Documents\Arduino\hardware\MiniCore-master\avr\libraries\SoftwareSerial
Using library Arduino_Vcc-master in folder: C:\Users\Robert\Documents\Arduino\libraries\Arduino_Vcc-master (legacy)
exit status 1
invalid conversion from 'char' to 'const char*' [-fpermissive]
Single quotes (') are used for character literals, double quotes (") are used for string literals.
You cannot compare a string to a single character, try this:
if (dataBLE == "\n")
Your code doesn't make much sense to me. How can dataBLE equal both "\n" and -1 at the same time?
Single quotes (') are used for character literals, double quotes (") are used for string literals.
You cannot compare a string to a single character, try this:
if (dataBLE == "\n")
Your code doesn't make much sense to me. How can dataBLE equal both "\n" and -1 at the same time?
Pieter
Sorry, this code was written by a third party.
I'm not a prolific programmer - how should it be done?
Hard to say. Most people on here won't download txt or ino files. Post your full code between code tags (button on the post form looks like </>) and you'll most likely get a lot more help.