Skip to content

Commit

Permalink
updates MQTT topic
Browse files Browse the repository at this point in the history
  • Loading branch information
bytecod3 committed Sep 28, 2024
1 parent 54677f9 commit c5367df
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 32 deletions.
50 changes: 18 additions & 32 deletions n4-flight-software/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,8 @@ void receiveTestDataSerialEvent() {
void MQTTInit(const char* broker_IP, uint16_t broker_port);
#endif

/* WIFI configuration class object */
WIFIConfig wifi_config;

uint8_t drogue_pyro = 25;
uint8_t main_pyro = 12;
Expand Down Expand Up @@ -656,11 +658,6 @@ QueueHandle_t gps_data_qHandle;
// digitalWrite(LED_BUILTIN, LOW);
// }

// void initializeMQTTParameters(){
// /* this functions creates an MQTT client for transmitting telemetry data */;
// mqtt_client.setServer(MQTT_SERVER, MQTT_PORT);
// }


//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////// ACCELERATION AND ROCKET ATTITUDE DETERMINATION /////////////////
Expand Down Expand Up @@ -1107,9 +1104,15 @@ void logToMemory(void* pvParameter) {
*
*******************************************************************************/
void MQTT_TransmitTelemetry(void* pvParameters) {

while(1) {
debugln("Transmitting telemetry");
if(mqtt_client.publish(MQTT_TOPIC, "Hello from FC1")) {
debugln("[+]Data sent");
} else {
debugln("[-]Data not sent");
}
}

}

/*!
Expand Down Expand Up @@ -1196,39 +1199,14 @@ void MQTT_Reconnect() {
// file.close();
// id+=1;

// if(mqtt_client.publish("n3/telemetry", telemetry_data)){
// if(mqtt_client.publish("n3/telemetry", telemetry_data)) {
// debugln("[+]Data sent");
// } else{
// debugln("[-]Data not sent");
// }
// }
// }

// void reconnect(){

// while(!mqtt_client.connected()){
// debug("[..]Attempting MQTT connection...");
// String client_id = "[+]FC Client - ";
// client_id += String(random(0XFFFF), HEX);

// if(mqtt_client.connect(client_id.c_str())){
// debugln("[+]MQTT connected");
// }
// }
// }

// void testMQTT(void *pvParameters){
// while(true){
// debugln("Publishing data");
// if(mqtt_client.publish("n3/telemetry", "Hello from flight!")){
// debugln("Data sent");
// }else{
// debugln("Unable to send data");
// }
// }
// }


/*!****************************************************************************
* @brief Initialize MQTT
*
Expand Down Expand Up @@ -1272,6 +1250,14 @@ void setup(){
Serial.begin(BAUDRATE);
delay(100);

// create dynamic WIFI
uint8_t wifi_connection_result = wifi_config.WifiConnect();
if(wifi_connection_result) {
debugln("Wifi config OK!");
} else {
debugln("Wifi config failed");
}

/* initialize the system logger */
InitSPIFFS();

Expand Down
1 change: 1 addition & 0 deletions n4-flight-software/src/wifi-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "WiFiManager.h"

class WIFIConfig {
public:
uint8_t WifiConnect();
};

Expand Down

0 comments on commit c5367df

Please sign in to comment.