1
votes

I'm playing with an Arduino board and the samples provided. Trying to get a message I received to be displayed on the LCD. I'm struggling to figure out how to work with some of the pre-built code.

I get the error: invalid conversion from 'const unsigned char*' to 'const char*

I tried modify the payload parameter type but it breaks other references to MessageCallback.

Screen.print() definition in the documentation for the arduino board: int print(unsigned int line, const char s, bool wrap)

Code:

static int  MessageCallback(const unsigned char *payload)
{
int result = 200;
const char screenMsg[100]; 
strcpy(screenMsg,"Set Temp: ");
strcat(screenMsg,payload);

Screen.print(1, screenMsg, true);

return result;
}
2
const char screenMsg[100]; not initialized as const and then changed (?) in the next line seems ambiguousTetix

2 Answers

0
votes

Strcat's arguments are (char *, const char *). You can cast "payload" to a char* by doing "strcat(screenMsg, (char*)payload);". Read Strcat two unsigned char in C.

0
votes

If you just change to char screenMsg[100]; it should work.

The print function will not change the string you provide to it, is all that

const char s

means.