code migration UNO to DUE : strcpy(char*, uint8_t*)

Hi.

I try to make a websocket working on UNO to arduino DUE.

ArduinoWebSocketServer

First bug is on a strcpy function. On utility file, it take as argument an char array an a function that return an unsigned int:

void encodeSecKey(char output[], const char *key) {
	char newKey[64] = { '\0' };
	
	strcpy(newKey, key);
	strcat(newKey, _MAGIC_STRING);

	Sha1.init();
	Sha1.print(newKey);

	char result[25] = { '\0' };
	strcpy(result, Sha1.result()); //<---------
	
	char B64Result[32] = { '\0' };
	base64_encode(B64Result, result, 20);
	
	strcpy(output, B64Result);
}

Sha1.result() is define in Sha1Class:

uint8_t* result(void)

the thing is it compile right on UNO but on DUE it get :

error: invalid conversion from 'uint8_t* {aka unsigned char*}' to 'const char*' [-fpermissive]

  strcpy(result, Sha1.result());

I tried itoa() but it is not define in DUE also...

Any suggestion ??

nitrof:
Any suggestion ??

Cast it to a char*

tried:

<char*>(Sha1.result())
//get: error: expected primary-expression before '<' token 


static_cast<char*>(Sha1.result())
//get: error: invalid static_cast from type 'uint8_t* {aka unsigned char*}' to type 'char*'

humm don't know now how much effort I want to put in this library... even with UNO, I cant get a connection to work....

Anyone add usued one before, specialy with DUE and Ethernet shield2 ?

Yeah, you'll need a reinterpret_cast (or just a plain C-style cast) for that. You want to tell the compiler that you are happy with the bits as they are and no conversion manipulation is necessary.

Ok. I will try that. By now I was trying to make it work on UNO but I got a bug using Ethernet shield2 on uno... if I call localIp() it return 255.255.255.255 address instead of ip... but I still can ping the arduino from command prompt.

I got the bug even with example... strange.
When I use the websocket server example, I can't establish a connection.... it got refused...

@arduarn. At least, your solution compile. I had to change one more variable type in a function definition to make it compile on a DUE.

With the DUE, I don't have the bug to print localIp().

Still, I can't establish a connection with the example webpage given, neither telnet...