Open TAMHAN opened 3 months ago
And I think I fixed it:
event_t process_event()
{
String response; //TODO TAMHAN TOUCH
int val = 0;
event_t event_number = EVENT_NONE;
val = digitalRead(EVENT_PIN);
if(val)
{
response = execute_command("AT+EVENT?", 3000);
if (response.equals("OK"))
{
return EVENT_NONE;
}
else {
char ok_string[3];
int topic_index;
int total_read;
char someResponse[300];
strcpy(someResponse, response.c_str());
total_read = sscanf(someResponse, "%s %d %d %*s" , ok_string, &event_number, &topic_index);
Serial.print("OAIRON : ");
Serial.println(event_number);
return event_number;
}
}
}
Please DO NOT ask me what is happening. However, this line clearly caused the problem - it seems to fuxate the inner state of the C++ string somehow: total_read = sscanf(response.c_str(), "%s %d %d %*s" , ok_string, &event_number, &topic_index);
And yes, avoid C++ if you can.
Hello Folks, sorry to report back a very weird problem - I spent quite a bit of time getting this to run on the Arduno Uno R4 WiFi. Now I have it working, but am a lot perplexed.
Particularly, the normal code failed after receiving the EVT Code 2. The exact error, as decoded by addr2line, was this:
Apparently, the receiving of the code failed. I instrumented it like this:
The change I did to the location of the declaration of response "fixed" the problem, but of course caused a memory leak. My question, thus, now is what to do.