So I have a java server running that is expecting data from a client in my arduino. The original type of my data is uint8_t, but i want it as a String. This is how I'm doing my conversion:
String stringData = (char*) data;
where 'data' is an array of type uint8_t. I can print the 'stringData' value and it looks exactly how I want it, but when it gets to my java server it shows up as a little question mark inside of a box. Does anyone know why?
P.S. It works just fine when create a normal string (String stringdata = "123456") So I'm assuming it has to do with the conversion.
Here's the code that pertains:
Arduino:
void arduinoClient(String accountID) {
if (client.connect(ip, 9876)) {
client.println(accountID);
Serial.println("Message sent");
} else {
Serial.println("connection failed");
}
}
Java:
BufferedReader buff = new BufferedReader(new InputStreamReader (socket.getInputStream()));
String message = buff.readLine();
I'd also be fine with doing the conversion on the java side if it is more convenient (or possible) to do so