diff --git a/.gitignore b/.gitignore
index 2753f7e..c68747a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-Secret.h
\ No newline at end of file
+.DS_Store
+Secret.h
diff --git a/rover-gnss/Config.cpp b/rover-gnss/Config.cpp
index 963a848..36d459b 100644
--- a/rover-gnss/Config.cpp
+++ b/rover-gnss/Config.cpp
@@ -27,11 +27,10 @@ char user[32] = "rover-gnss-tester";
char passwd[32] = "";
// Network configuration
-IPAddress server(192, 168, 1, 100);
+IPAddress tcp_server(192, 168, 1, 100);
int port = 80;
const char* udpAddress = "192.168.1.255";
const int udpPort = 9999;
-int trans = 3;
// Timing intervals
const unsigned long wifiReconnectInterval = 10000; // 10 seconds
@@ -40,7 +39,7 @@ const unsigned long ntripReconnectInterval = 10000; // 10 seconds
// Global variables
WiFiClient espClient;
-PubSubClient client(espClient);
+PubSubClient mqtt_client(espClient);
TinyGPSPlus gps;
NTRIPClient ntrip_c;
WiFiUDP udp;
@@ -72,51 +71,51 @@ float distance = 0 ;
void loadPreferences() {
preferences.begin("config", true); // read-only
String temp;
-
+
temp = preferences.getString("ssid", ssid);
temp.toCharArray(ssid, sizeof(ssid));
-
+
temp = preferences.getString("password", password);
temp.toCharArray(password, sizeof(password));
-
+
temp = preferences.getString("mqtt_server", mqtt_server);
temp.toCharArray(mqtt_server, sizeof(mqtt_server));
-
+
mqtt_port = preferences.getInt("mqtt_port", mqtt_port);
-
+
temp = preferences.getString("mqtt_output", mqtt_output);
temp.toCharArray(mqtt_output, sizeof(mqtt_output));
-
+
temp = preferences.getString("mqtt_input", mqtt_input);
temp.toCharArray(mqtt_input, sizeof(mqtt_input));
-
+
temp = preferences.getString("mqtt_log", mqtt_log);
temp.toCharArray(mqtt_log, sizeof(mqtt_log));
-
+
temp = preferences.getString("mqtt_user", mqtt_user);
temp.toCharArray(mqtt_user, sizeof(mqtt_user));
-
+
temp = preferences.getString("mqtt_password", mqtt_password);
temp.toCharArray(mqtt_password, sizeof(mqtt_password));
-
+
publish_freq = preferences.getInt("publish_freq", publish_freq);
-
+
temp = preferences.getString("host", host);
temp.toCharArray(host, sizeof(host));
-
+
httpPort = preferences.getInt("httpPort", httpPort);
-
+
temp = preferences.getString("mntpnt", mntpnt);
temp.toCharArray(mntpnt, sizeof(mntpnt));
-
+
temp = preferences.getString("user", user);
temp.toCharArray(user, sizeof(user));
-
+
temp = preferences.getString("passwd", passwd);
temp.toCharArray(passwd, sizeof(passwd));
mqtt_enabled = preferences.getBool("mqtt_enabled", true);
-
+
preferences.end();
}
diff --git a/rover-gnss/Config.h b/rover-gnss/Config.h
index 8c636e7..23f3a7e 100644
--- a/rover-gnss/Config.h
+++ b/rover-gnss/Config.h
@@ -21,6 +21,17 @@
#define LOG_LEVEL LOG_LEVEL_DEBUG
+// Connection to use to transmit data
+// RS2323_SERIAL : and connect tx f9p directly to rs232 module
+// UDP_SERVER
+// TCP_MQTT
+// RS2323_MYSERIAL
+#define LOG 0
+#define UDP_SERVER 1
+#define TCP_SERVER 2
+#define MYSERIAL 3
+#define TRANSMITION_MODE MYSERIAL
+
// Pinouts
#define PIN_TX 18 //esp32
#define PIN_RX 19 //esp32
@@ -52,11 +63,10 @@ extern char user[32];
extern char passwd[32];
// Network configuration
-extern IPAddress server;
+extern IPAddress tcp_server;
extern int port;
extern const char* udpAddress;
extern const int udpPort;
-extern int trans;
// Timing intervals
extern const unsigned long wifiReconnectInterval;
@@ -65,7 +75,7 @@ extern const unsigned long ntripReconnectInterval;
// Global variables
extern WiFiClient espClient;
-extern PubSubClient client;
+extern PubSubClient mqtt_client;
extern TinyGPSPlus gps;
extern NTRIPClient ntrip_c;
extern WiFiUDP udp;
diff --git a/rover-gnss/Connectivity.cpp b/rover-gnss/Connectivity.cpp
index 7f9dc59..9a1a34d 100644
--- a/rover-gnss/Connectivity.cpp
+++ b/rover-gnss/Connectivity.cpp
@@ -103,9 +103,9 @@ void connectToWiFi() {
isAPMode = false; // Reset AP mode flag
// Reinitialize MQTT and NTRIP connections after WiFi reconnects
- if (!isAPMode) {
- if (client.connected()) {
- client.disconnect();
+ if (!isAPMode) {
+ if (mqtt_client.connected()) {
+ mqtt_client.disconnect();
}
reconnectMQTT();
@@ -124,20 +124,20 @@ void connectToWiFi() {
void reconnectMQTT() {
if (!mqtt_enabled || isAPMode) return;
unsigned long startAttemptTime = millis();
- while (!client.connected() && millis() - startAttemptTime < mqttReconnectInterval) {
+ while (!mqtt_client.connected() && millis() - startAttemptTime < mqttReconnectInterval) {
logMessage(LOG_LEVEL_INFO, "Attempting MQTT connection...");
- if (client.connect(mqtt_UUID, mqtt_user, mqtt_password)) {
+ if (mqtt_client.connect(mqtt_UUID, mqtt_user, mqtt_password)) {
logMessage(LOG_LEVEL_INFO, "connected");
- client.subscribe(mqtt_input);
+ mqtt_client.subscribe(mqtt_input);
break;
} else {
- logMessage(LOG_LEVEL_ERROR, "failed, rc=", client.state());
+ logMessage(LOG_LEVEL_ERROR, "failed, rc=", mqtt_client.state());
logMessage(LOG_LEVEL_INFO, " try again in 5 seconds");
vTaskDelay(500 / portTICK_PERIOD_MS); // Utiliser vTaskDelay au lieu de delay()
}
}
- if (!client.connected()) {
+ if (!mqtt_client.connected()) {
logMessage(LOG_LEVEL_ERROR, "MQTT connection failed");
}
}
@@ -244,7 +244,7 @@ void handleRoot() {
-
+