-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Closed
Labels
Status: StaleIssue is stale stage (outdated/stuck)Issue is stale stage (outdated/stuck)
Description
Board: ESP32-EVB
OS: Linux Mint 19.1
I would like to know if I am sending a packet through UDP correctly.
if(digitalRead(TRIGGER_PIN) == LOW) {
logOutput("Trigger sent");
delay(1000);
uint8_t buffer[19] = "statechange,201,1\r";
// send packet to server
if (Server_IP.length()!=0) {
udp.beginPacket(Server_IP.c_str(), Server_Port.toInt());
udp.write(buffer, sizeof(buffer)-1);
delay(30);
Serial.println(udp.endPacket());
memset(buffer, 0, 19);
} else {
logOutput("ERROR ! No IP for the Server was found. Please enter Server's IP !");
}
}
This outputs:
Trigger sent
1
Trying to print buffer
using
void foo(uint8_t *buff, int length) {
for(int i=0; i<length;i++) {
Serial.print(buff[i]);
Serial.print(" ");
}
Serial.println();
}
returns each character's correct ASCII code.
Trying to print buffer
using
void foo(uint8_t *buff, int length) {
for(int i=0; i<length;i++) {
printf("%c ", buff[i]);
}
Serial.println();
}
returns ␀ ␀ ␀ ␀ ␀ ␀ ␀ ␀ ␀ ␀ ␀ ␀ ␀ ␀ ␀ ␀ ␀ ␀ s t a t e c h a n g
So this begs the question: what do I send through UDP ? Do I send the string as it is ? Or what ?
Metadata
Metadata
Assignees
Labels
Status: StaleIssue is stale stage (outdated/stuck)Issue is stale stage (outdated/stuck)