hi, guys, hope you doing all well, so i m using an arduino Uno as a master and an arduino rp2040 connect as slave through i2c communication, my goal was to send a String to the nano and then he extract the informations needed and goes into AP mode, this work ( meaning when master tries to write on slave it works) but now if i try to read something from the slave ( like for exemple if the configuration is done or not, nothing is hapenning and the code is stock and does nt go further the command : "Wire.request", is it a problem of desychnronisation ? here s the master code :
Serial.println("je suis dans la configuration master");
currentMillis=millis();
//Configuration du point d'acces AP
Wire.beginTransmission(8);
String config=(String(selectedMode)+","+String(currentMillis)+","+String(nom_wifi)+","+String(password_wifi)+","+String(canal_wifi_value));
Wire.write(config.c_str()); // Example configuration message
Wire.endTransmission();
delay(500); // Give some time for the slave to process the configuration
Serial.println("j ai envoyé le message de configurartion");
Serial.println(isConfigDone);
while(!isConfigDone) {
// Request status from the slave
Serial.println("je suis dans la boucle pour check la config");
Wire.requestFrom(8, 1); // Request 1 byte from peripheral device #8
Serial.println("j'entre dans la boucle");
while (Wire.available()) {
char c = Wire.read();
if (c == 'S') {
Serial.println("Configuration successful. Proceeding with data exchange.");
isConfigDone=true;
} else if (c == 'F') {
Serial.println("Configuration not yet done. Waiting...");
}
}
}
isConfigDone=false;
Serial.println("i m at the end of it ");
and here s the slave go :
void receiveEvent(int howMany) {
if(howMany>2) {
isConfigDone=false;
}
if (!isConfigDone) {
// Read the configuration parameters sent by the master
char config[howMany+1];
for (int i = 0; i < howMany; i++) {
config[i] = Wire.read();
}
config[howMany] = '\0'; // Null-terminate the string
Serial.println(config);
char* token = strtok(config, ",");
if (token != NULL) {
strcpy(mode, token); // Copy the first token to mode
token = strtok(NULL, ",");
}
if (token != NULL) {
currentMillis = strtoul(token, NULL, 10); // Convert the second token to an unsigned long
token = strtok(NULL, ",");
}
if (token != NULL) {
strcpy(nom_wifi, token); // Copy the third token to nom_wifi
token = strtok(NULL, ",");
}
if (token != NULL) {
strcpy(password_wifi, token); // Copy the fourth token to password_wifi
}
if (token != NULL) {
strcpy(canal_wifi, token); // Copy the fourth token to password_wifi
}
Serial.println(currentMillis);
if (strcmp(mode, "Mode 6 ") == 0) {
// Ensure BLE module is not in use
if(BLE.connected()) {
BLE.disconnect();
BLE.end();
}
digitalWrite(LEDR, LOW);
digitalWrite(LEDB, HIGH);
digitalWrite(LEDG, LOW);
while (WiFi.status() == WL_NO_MODULE) {
delay(100);
}
while(status!=WL_AP_LISTENING) {
// initialiser le point d'accés
status = WiFi.beginAP(nom_wifi, password_wifi, atoi(canal_wifi));
}
digitalWrite(LEDR, HIGH);
digitalWrite(LEDB, LOW);
digitalWrite(LEDG, LOW);
isConfigDone = true;
Serial.println(millis());
configtime=millis()-currentMillis;
Serial.println(configtime);
Serial.println("Configuration done");
}
}
}
void requestEvent() {
Serial.println("je suis la ");
if (isConfigDone) {
Wire.write("S"); // Respond with 'S' to indicate configuration is successful
} else {
Wire.write("F"); // Respond with 'F' to indicate configuration is not yet done
}
}
i repeat, the slave execute all the on receive function nice and clean and goes into AP mode, but it never execute the on request function, any suggestion ?