diff --git a/docs/html/annotated.html b/docs/html/annotated.html index e74ee63..12a116f 100644 --- a/docs/html/annotated.html +++ b/docs/html/annotated.html @@ -114,6 +114,7 @@  CSystemLogger  CTelemetry_Data  CTest + CWIFIConfig diff --git a/docs/html/annotated_dup.js b/docs/html/annotated_dup.js index 049d569..11d1357 100644 --- a/docs/html/annotated_dup.js +++ b/docs/html/annotated_dup.js @@ -10,5 +10,6 @@ var annotated_dup = [ "State_machine", "class_state__machine.html", null ], [ "SystemLogger", "class_system_logger.html", "class_system_logger" ], [ "Telemetry_Data", "struct_telemetry___data.html", "struct_telemetry___data" ], - [ "Test", "class_test.html", null ] + [ "Test", "class_test.html", null ], + [ "WIFIConfig", "class_w_i_f_i_config.html", null ] ]; \ No newline at end of file diff --git a/docs/html/class_w_i_f_i_config-members.html b/docs/html/class_w_i_f_i_config-members.html new file mode 100644 index 0000000..64949c8 --- /dev/null +++ b/docs/html/class_w_i_f_i_config-members.html @@ -0,0 +1,115 @@ + + + + + + + +N4 Flight Software: Member List + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+
N4 Flight Software N4 +
+
Flight software used for the N4 flight computers
+
+
+ + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+
WIFIConfig Member List
+
+
+ +

This is the complete list of members for WIFIConfig, including all inherited members.

+
+
+ + + + diff --git a/docs/html/class_w_i_f_i_config.html b/docs/html/class_w_i_f_i_config.html new file mode 100644 index 0000000..8827908 --- /dev/null +++ b/docs/html/class_w_i_f_i_config.html @@ -0,0 +1,120 @@ + + + + + + + +N4 Flight Software: WIFIConfig Class Reference + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+
N4 Flight Software N4 +
+
Flight software used for the N4 flight computers
+
+
+ + + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+
+
+
+
+
Loading...
+
Searching...
+
No Matches
+
+
+
+
+ +
+ +
WIFIConfig Class Reference
+
+
+
The documentation for this class was generated from the following files: +
+
+ + + + diff --git a/docs/html/classes.html b/docs/html/classes.html index 0a14bd1..f356300 100644 --- a/docs/html/classes.html +++ b/docs/html/classes.html @@ -101,7 +101,7 @@
Class Index
-
A | D | F | G | M | S | T
+
A | D | F | G | M | S | T | W
A
@@ -124,6 +124,9 @@
T
Telemetry_Data
Test
+
+
W
+
WIFIConfig
diff --git a/docs/html/custom-time_8h.html b/docs/html/custom-time_8h.html index 4300ea0..247c666 100644 --- a/docs/html/custom-time_8h.html +++ b/docs/html/custom-time_8h.html @@ -143,6 +143,7 @@

Returns
tstamp with time in huma readable format
diff --git a/docs/html/custom-time_8h_source.html b/docs/html/custom-time_8h_source.html index d74f655..f72cba7 100644 --- a/docs/html/custom-time_8h_source.html +++ b/docs/html/custom-time_8h_source.html @@ -115,7 +115,7 @@
12void convertTimestamp(unsigned long);
13ma
14#endif
-
void convertTimestamp(unsigned long)
convert time in milliseconds to minutes, seconds and time that are human readable,...
Definition custom_time.cpp:18
+
void convertTimestamp(unsigned long)
convert time in milliseconds to minutes, seconds and time that are human readable,...
Definition custom_time.cpp:20
diff --git a/docs/html/custom__time_8h.html b/docs/html/custom__time_8h.html index 9905ed5..51a81bc 100644 --- a/docs/html/custom__time_8h.html +++ b/docs/html/custom__time_8h.html @@ -149,6 +149,7 @@

Returns
tstamp with time in huma readable format
diff --git a/docs/html/custom__time_8h_source.html b/docs/html/custom__time_8h_source.html index d8661ff..57257ee 100644 --- a/docs/html/custom__time_8h_source.html +++ b/docs/html/custom__time_8h_source.html @@ -115,7 +115,7 @@
12void convertTimestamp(unsigned long);
13
14#endif
-
void convertTimestamp(unsigned long)
convert time in milliseconds to minutes, seconds and time that are human readable,...
Definition custom_time.cpp:18
+
void convertTimestamp(unsigned long)
convert time in milliseconds to minutes, seconds and time that are human readable,...
Definition custom_time.cpp:20
char tstamp[]
Definition custom_time.cpp:10
diff --git a/docs/html/dir_d09072d1c94fe000833aa47d92501a74.html b/docs/html/dir_d09072d1c94fe000833aa47d92501a74.html index 8d0867b..e60fddd 100644 --- a/docs/html/dir_d09072d1c94fe000833aa47d92501a74.html +++ b/docs/html/dir_d09072d1c94fe000833aa47d92501a74.html @@ -127,6 +127,8 @@    system_logger.h   + wifi-config.h diff --git a/docs/html/dir_d09072d1c94fe000833aa47d92501a74.js b/docs/html/dir_d09072d1c94fe000833aa47d92501a74.js index 4d66c03..abe8dbe 100644 --- a/docs/html/dir_d09072d1c94fe000833aa47d92501a74.js +++ b/docs/html/dir_d09072d1c94fe000833aa47d92501a74.js @@ -8,5 +8,6 @@ var dir_d09072d1c94fe000833aa47d92501a74 = [ "mpu.h", "mpu_8h_source.html", null ], [ "states.h", "states_8h.html", null ], [ "system_log_levels.h", "system__log__levels_8h_source.html", null ], - [ "system_logger.h", "system__logger_8h_source.html", null ] + [ "system_logger.h", "system__logger_8h_source.html", null ], + [ "wifi-config.h", "wifi-config_8h_source.html", null ] ]; \ No newline at end of file diff --git a/docs/html/doxygen_crawl.html b/docs/html/doxygen_crawl.html index e0a0069..9063f31 100644 --- a/docs/html/doxygen_crawl.html +++ b/docs/html/doxygen_crawl.html @@ -19,6 +19,7 @@ + @@ -54,6 +55,8 @@ + + @@ -175,6 +178,7 @@ + @@ -352,5 +356,6 @@ + diff --git a/docs/html/files.html b/docs/html/files.html index b5f8dee..04eb390 100644 --- a/docs/html/files.html +++ b/docs/html/files.html @@ -120,10 +120,11 @@  states.h  system_log_levels.h  system_logger.h -  test -  log_time_fmt_test - custom-time.hThis file defeines functions needed for time conversions for data logging - test_class.h + wifi-config.h +  test +  log_time_fmt_test + custom-time.hThis file defeines functions needed for time conversions for data logging + test_class.h diff --git a/docs/html/index.html b/docs/html/index.html index 8541207..ef09f51 100644 --- a/docs/html/index.html +++ b/docs/html/index.html @@ -197,7 +197,17 @@

  • LOG_TO_MEMORY - defs.h
  • -Contributors

    +WIFI network configuration

    +

    The software is written such that it allows the launch crew to connect to any WIFI they are using, without hardcoding the WIFI credentials into the flight software. Follow the procedure below to connect to the WIFI:

      +
    1. When powered on, the flight computer will create an open WIFI network called "flight-computer". This network will be visible on any device within range.
    2. +
    3. On the ground station computer, connect to "flight-computer".
    4. +
    5. Open the browser and go to the following IP address "192.168.4.1". This should open the following window in your browser. [image here]
    6. +
    7. Enter the WIFI SSID and password for the network you want to connect to. In this case it is the WIFI network used for telemetry transmission.
    8. +
    9. Press save
    10. +
    +

    The flight computer will save the network credentials and auto-reconnect itself to the launch WIFI network. You can now stream telemetry over the network.

    +

    +WIFI network configuration

    Our thanks go to the following current and previous avionics team members for their contribution:

    1. Edwin Mwiti
    2. Junn Hope
    3. diff --git a/docs/html/logger_8h_source.html b/docs/html/logger_8h_source.html index ad74e97..f2afd06 100644 --- a/docs/html/logger_8h_source.html +++ b/docs/html/logger_8h_source.html @@ -145,8 +145,8 @@
      void loggerEquals()
      helper function to print = for data formatting
      Definition logger.cpp:262
      bool loggerTest()
      test the flash memory write and read function by reading and writing a variable to it
      Definition logger.cpp:143
      defines the data types, structs and typedefs used to store flight data
      -
      char filename[]
      Definition main.cpp:526
      -
      SerialFlashFile file
      Definition main.cpp:530
      +
      char filename[]
      Definition main.cpp:527
      +
      SerialFlashFile file
      Definition main.cpp:531
      Definition data_types.h:55
      diff --git a/docs/html/navtreedata.js b/docs/html/navtreedata.js index 2bd1fd7..42798a5 100644 --- a/docs/html/navtreedata.js +++ b/docs/html/navtreedata.js @@ -43,7 +43,7 @@ var NAVTREE = [ "Hardware, pin assignment and peripherals", "index.html#step13", null ], [ "Integration and Testing Procedures", "index.html#step14", null ], [ "Pre-flight software checks", "index.html#step15", null ], - [ "Contributors", "index.html#step16", null ], + [ "WIFI network configuration", "index.html#step16", null ], [ "README", "md_n4-flight-software_2_r_e_a_d_m_e.html", null ], [ "Flight computer pin assignment", "md_n4-flight-software_2src_2pin__assignment.html", null ], [ "Classes", "annotated.html", [ diff --git a/docs/html/navtreeindex0.js b/docs/html/navtreeindex0.js index e26876e..2df2733 100644 --- a/docs/html/navtreeindex0.js +++ b/docs/html/navtreeindex0.js @@ -23,6 +23,7 @@ var NAVTREEINDEX0 = "class_system_logger.html#a0755dee42eafc8a8f7a6a6d027b880f2":[9,0,8,1], "class_system_logger.html#ad6feeadde357832516761347ff4cf25c":[9,0,8,0], "class_test.html":[9,0,10], +"class_w_i_f_i_config.html":[9,0,11], "classes.html":[9,1], "custom-time_8h.html":[10,0,0,2,0,0], "custom-time_8h.html#a742a45ab1cba3ca3717085198ec6d2a9":[10,0,0,2,0,0,0], @@ -206,5 +207,6 @@ var NAVTREEINDEX0 = "struct_telemetry___data.html#ab56d1832a9db40699f8944b0ca2db51c":[9,0,9,5], "system__log__levels_8h_source.html":[10,0,0,1,7], "system__logger_8h_source.html":[10,0,0,1,8], -"test__class_8h_source.html":[10,0,0,2,1] +"test__class_8h_source.html":[10,0,0,2,1], +"wifi-config_8h_source.html":[10,0,0,1,9] }; diff --git a/docs/html/search/all_12.js b/docs/html/search/all_12.js index 8dbce4a..31b32d1 100644 --- a/docs/html/search/all_12.js +++ b/docs/html/search/all_12.js @@ -1,4 +1,6 @@ var searchData= [ - ['wifi_20telemetry_20selection_0',['XBEE, MQTT, LORA, WIFI telemetry selection',['../index.html#step8',1,'']]] + ['wifi_20network_20configuration_0',['WIFI network configuration',['../index.html#step16',1,'']]], + ['wifi_20telemetry_20selection_1',['XBEE, MQTT, LORA, WIFI telemetry selection',['../index.html#step8',1,'']]], + ['wificonfig_2',['WIFIConfig',['../class_w_i_f_i_config.html',1,'']]] ]; diff --git a/docs/html/search/all_2.js b/docs/html/search/all_2.js index 80a1742..ca1bd7b 100644 --- a/docs/html/search/all_2.js +++ b/docs/html/search/all_2.js @@ -9,7 +9,7 @@ var searchData= ['code_6',['Building the code',['../index.html#step11',1,'']]], ['compilation_20and_20downloading_7',['Building, Compilation and Downloading.',['../index.html#install_sec',1,'']]], ['computer_20pin_20assignment_8',['Flight computer pin assignment',['../md_n4-flight-software_2src_2pin__assignment.html',1,'']]], - ['contributors_9',['Contributors',['../index.html#step16',1,'']]], + ['configuration_9',['WIFI network configuration',['../index.html#step16',1,'']]], ['converttimestamp_10',['convertTimestamp',['../custom__time_8h.html#a742a45ab1cba3ca3717085198ec6d2a9',1,'convertTimestamp(unsigned long): custom_time.cpp'],['../custom-time_8h.html#a742a45ab1cba3ca3717085198ec6d2a9',1,'convertTimestamp(unsigned long): custom_time.cpp']]], ['current_5flog_5ftime_11',['current_log_time',['../src_2main_8cpp.html#a318b23db9cedde5ea8466af114f0c203',1,'main.cpp']]], ['current_5fstate_12',['current_state',['../src_2main_8cpp.html#ac559654865b2d48ea0b77b1a1f4a097b',1,'main.cpp']]], diff --git a/docs/html/search/all_b.js b/docs/html/search/all_b.js index af55539..c654757 100644 --- a/docs/html/search/all_b.js +++ b/docs/html/search/all_b.js @@ -2,5 +2,6 @@ var searchData= [ ['n4_20flight_20software_0',['N4 Flight Software',['../index.html',1,'']]], ['nak_1',['NAK',['../src_2main_8cpp.html#a7ff3e502ffb5d509612c6c6741de45cc',1,'main.cpp']]], - ['nak_5finterval_2',['NAK_INTERVAL',['../src_2main_8cpp.html#a394162e74bbeb9bf67d3009cc38e0466',1,'main.cpp']]] + ['nak_5finterval_2',['NAK_INTERVAL',['../src_2main_8cpp.html#a394162e74bbeb9bf67d3009cc38e0466',1,'main.cpp']]], + ['network_20configuration_3',['WIFI network configuration',['../index.html#step16',1,'']]] ]; diff --git a/docs/html/search/classes_7.js b/docs/html/search/classes_7.js index 725f293..b976124 100644 --- a/docs/html/search/classes_7.js +++ b/docs/html/search/classes_7.js @@ -1,5 +1,4 @@ var searchData= [ - ['telemetry_5fdata_0',['Telemetry_Data',['../struct_telemetry___data.html',1,'']]], - ['test_1',['Test',['../class_test.html',1,'']]] + ['wificonfig_0',['WIFIConfig',['../class_w_i_f_i_config.html',1,'']]] ]; diff --git a/docs/html/search/searchdata.js b/docs/html/search/searchdata.js index 3a30e2d..9c2f6fa 100644 --- a/docs/html/search/searchdata.js +++ b/docs/html/search/searchdata.js @@ -1,7 +1,7 @@ var indexSectionsWithContent = { 0: "abcdefghilmnoprstvwx", - 1: "adfgmst", + 1: "adfgmstw", 2: "cdlms", 3: "bcdfghilmprs", 4: "acfgiloprstv", diff --git a/docs/html/src_2main_8cpp.html b/docs/html/src_2main_8cpp.html index 1a8260e..07a205d 100644 --- a/docs/html/src_2main_8cpp.html +++ b/docs/html/src_2main_8cpp.html @@ -128,6 +128,7 @@ #include "states.h"
      #include "system_logger.h"
      #include "system_log_levels.h"
      +#include "wifi-config.h"
      @@ -274,7 +275,7 @@ - + @@ -722,7 +723,7 @@

      Parameters

      Macros

       Check and update the current state of flight - refer to states.h.
       
      void flightStateCallback (void *pvParameters)
       performs flight actions based on the current flight state If the flight state neccessisates an operation, we perfom it here For example if the flight state is apogee, we perfom MAIN_CHUTE ejection
       performs flight actions based on the current flight state If the flight state neccessisates an operation, we perform it here For example if the flight state is apogee, we perform MAIN_CHUTE ejection
       
      void debugToTerminalTask (void *pvParameters)
       debug flight/test data to terminal, this task is called if the DEBUG_TO_TERMINAL is set to 1 (see defs.h)
      - +
      pvParameters- A value that is passed as the paramater to the created task. If pvParameters is set to the address of a variable then the variable must still exist when the created task executes - so it is not valid to pass the address of a stack variable.
      pvParameters- A value that is passed as the parameter to the created task. If pvParameters is set to the address of a variable then the variable must still exist when the created task executes - so it is not valid to pass the address of a stack variable.
      @@ -769,7 +770,7 @@

      Parameters
      - +
      pvParameters- A value that is passed as the paramater to the created task. If pvParameters is set to the address of a variable then the variable must still exist when the created task executes - so it is not valid to pass the address of a stack variable.
      pvParameters- A value that is passed as the parameter to the created task. If pvParameters is set to the address of a variable then the variable must still exist when the created task executes - so it is not valid to pass the address of a stack variable.
      @@ -796,7 +797,7 @@

      Parameters
      - +
      pvParameter- A value that is passed as the paramater to the created task. If pvParameter is set to the address of a variable then the variable must still exist when the created task executes - so it is not valid to pass the address of a stack variable.
      pvParameter- A value that is passed as the parameter to the created task. If pvParameter is set to the address of a variable then the variable must still exist when the created task executes - so it is not valid to pass the address of a stack variable.
      @@ -839,11 +840,11 @@

      -

      performs flight actions based on the current flight state If the flight state neccessisates an operation, we perfom it here For example if the flight state is apogee, we perfom MAIN_CHUTE ejection

      +

      performs flight actions based on the current flight state If the flight state neccessisates an operation, we perform it here For example if the flight state is apogee, we perform MAIN_CHUTE ejection


      Parameters
      - +
      pvParameter- A value that is passed as the paramater to the created task. If pvParameter is set to the address of a variable then the variable must still exist when the created task executes - so it is not valid to pass the address of a stack variable.
      pvParameter- A value that is passed as the parameter to the created task. If pvParameter is set to the address of a variable then the variable must still exist when the created task executes - so it is not valid to pass the address of a stack variable.
      @@ -1098,7 +1099,7 @@

      Parameters
      - +
      pvParameters- A value that is passed as the paramater to the created task. If pvParameters is set to the address of a variable then the variable must still exist when the created task executes - so it is not valid to pass the address of a stack variable.
      pvParameters- A value that is passed as the parameter to the created task. If pvParameters is set to the address of a variable then the variable must still exist when the created task executes - so it is not valid to pass the address of a stack variable.
      diff --git a/docs/html/system__logger_8h_source.html b/docs/html/system__logger_8h_source.html index 4465988..86c161d 100644 --- a/docs/html/system__logger_8h_source.html +++ b/docs/html/system__logger_8h_source.html @@ -124,7 +124,7 @@
      void readLogFile(fs::FS &fs, const char *file)
      read log file to console
      Definition system_logger.cpp:65
      const char * getLogLevelString(uint8_t log_level)
      convert the log level to string
      Definition system_logger.cpp:87
      This file defines functions needed for human readable time conversion for data logging.
      -
      SerialFlashFile file
      Definition main.cpp:530
      +
      SerialFlashFile file
      Definition main.cpp:531
      diff --git a/docs/html/wifi-config_8h_source.html b/docs/html/wifi-config_8h_source.html new file mode 100644 index 0000000..26ceafc --- /dev/null +++ b/docs/html/wifi-config_8h_source.html @@ -0,0 +1,129 @@ + + + + + + + +N4 Flight Software: n4-flight-software/src/wifi-config.h Source File + + + + + + + + + + + + + + + +
      +
      + + + + + + + +
      +
      N4 Flight Software N4 +
      +
      Flight software used for the N4 flight computers
      +
      +
      + + + + + + + + +
      +
      + +
      +
      +
      + +
      + +
      +
      + + +
      +
      +
      +
      +
      +
      Loading...
      +
      Searching...
      +
      No Matches
      +
      +
      +
      +
      + +
      +
      wifi-config.h
      +
      +
      +
      1
      +
      2#ifndef WIFI_CONFIG_H
      +
      3#define WIFI_CONFIG_H
      +
      4
      +
      5#include <Arduino.h>
      +
      6#include "WiFiManager.h"
      +
      7
      +
      +
      8class WIFIConfig {
      +
      9 uint8_t WifiConnect();
      +
      10};
      +
      +
      11
      +
      12#endif // WIFI_CONFIG_H
      +
      Definition wifi-config.h:8
      +
      +
      + + + + diff --git a/mainpage.txt b/mainpage.txt index 803c19c..55df9e5 100644 --- a/mainpage.txt +++ b/mainpage.txt @@ -92,8 +92,25 @@ 5. DEBUG_to_terminal check - defs.h 6. LOG_TO_MEMORY - defs.h - - * @section step16 Contributors + * @section step16 WIFI network configuration + * The software is written such that it allows the launch crew to connect to any WIFI they are using, without + hardcoding the WIFI credentials into the flight software. + Follow the procedure below to connect to the WIFI: + 1. When powered on, the flight computer will create an open WIFI network called "flight-computer". This network will + be visible on any device within range. + 2. On the ground station computer, connect to "flight-computer". + 3. Open the browser and go to the following IP address "192.168.4.1". This should open the following window in + your browser. + [image here] + 4. Enter the WIFI SSID and password for the network you want to connect to. In this case it is the WIFI network used for telemetry + transmission. + 5. Press save. The flight computer will save the network credentials and auto-reconnect itself to the launch WIFI network. You can now + stream telemetry over the network. + + * @section step17 MQTT configuration + + + * @section step20 Contributors * Our thanks go to the following current and previous avionics team members for their contribution: 1. Edwin Mwiti 2. Junn Hope diff --git a/n4-flight-software/include/defs.h b/n4-flight-software/include/defs.h index 1e74064..6ea74f9 100644 --- a/n4-flight-software/include/defs.h +++ b/n4-flight-software/include/defs.h @@ -57,6 +57,9 @@ #define MQTT_SERVER "192.168.78.19" /*!< MQTT broker IP address */ #define MQTT_PORT 1882 /*!< MQTT broker port */ +#define BROKER_IP_ADDRESS_LENGTH 20 /*!< length of broker ip address string */ +#define MQTT_TOPIC_LENGTH 10 /*!< length of mqtt topic string */ + /* WIFI credentials */ // const char* SSID = "Galaxy"; /*!< WIFi SSID */ // const char* PASSWORD = "luwa2131"; /*!< WiFi password */ diff --git a/n4-flight-software/include/sensors.cpp b/n4-flight-software/include/sensors.cpp deleted file mode 100644 index 779ed99..0000000 --- a/n4-flight-software/include/sensors.cpp +++ /dev/null @@ -1,4 +0,0 @@ -// -// Created by Edwin Mwiti on 3/6/2023. -// - diff --git a/n4-flight-software/include/sensors.h b/n4-flight-software/include/sensors.h deleted file mode 100644 index bc9004a..0000000 --- a/n4-flight-software/include/sensors.h +++ /dev/null @@ -1,11 +0,0 @@ -// -// Created by Edwin Miwiri on 3/6/2023. -// - -#ifndef SENSORS_H -#define SENSORS_H - -void initialize_gyroscope(); -void initialize_altimeter(); - -#endif diff --git a/n4-flight-software/platformio.ini b/n4-flight-software/platformio.ini index 7846f69..264cb3d 100644 --- a/n4-flight-software/platformio.ini +++ b/n4-flight-software/platformio.ini @@ -19,3 +19,4 @@ lib_deps = Knolleary/PubSubClient@^2.8 sparkfun/Sparkfun BMP180@^1.1.2 paulstoffregen/SerialFlash@0.0.0-alpha+sha.2b86eb1e43 + tzapu/WiFiManager@^2.0.17 diff --git a/n4-flight-software/src/custom_time.cpp b/n4-flight-software/src/custom_time.cpp index c1de0e0..4a4b43d 100644 --- a/n4-flight-software/src/custom_time.cpp +++ b/n4-flight-software/src/custom_time.cpp @@ -13,7 +13,9 @@ int minute=0, sec=0, msec=0; /*!**************************************************************************** * @brief convert time in milliseconds to minutes, seconds and time that are human readable, to be * used for system logging or other data logging tasks + * * @param msec time in milliseconds, got from millis() function + * @return tstamp with time in huma readable format *******************************************************************************/ void convertTimestamp(unsigned long msec) { minute = ((msec / 1000) / 60) % 60; diff --git a/n4-flight-software/src/main.cpp b/n4-flight-software/src/main.cpp index 8a18667..d83aad4 100644 --- a/n4-flight-software/src/main.cpp +++ b/n4-flight-software/src/main.cpp @@ -15,21 +15,22 @@ #include #include #include // TODO: ADD A MQTT SWITCH - TO USE MQTT OR NOT -#include -#include -#include -#include -#include -#include "sensors.h" -#include "defs.h" -#include "mpu.h" -#include "SerialFlash.h" -#include "logger.h" -#include "data_types.h" -#include "custom_time.h" -#include "states.h" -#include "system_logger.h" -#include "system_log_levels.h" +#include // handle GPS +#include // For BMP180 +#include // File system functions +#include // SD card logging function +#include // SPIFFS file system function +#include "defs.h" // misc defines +#include "mpu.h" // for reading MPU6050 +#include "SerialFlash.h" // Handling external SPI flash memory +#include "logger.h" // system logging +#include "data_types.h" // definitions of data types used +#include "custom_time.h" // custom time conversions +#include "states.h" // state machine states +#include "system_logger.h" // system logging functions +#include "system_log_levels.h" // system logging log levels +#include "wifi-config.h" // handle wifi connection +#include "mqtt-config.h" // handle MQTT connection /* function prototypes definition */ void drogueChuteDeploy(); @@ -39,12 +40,6 @@ void mainChuteDeploy(); uint8_t operation_mode = 0; /*!< Tells whether software is in safe or flight mode - FLIGHT_MODE=1, SAFE_MODE=0 */ uint8_t current_state = FLIGHT_STATE::PRE_FLIGHT_GROUND; /*!< The starting state - we start at PRE_FLIGHT_GROUND state */ -/* create Wi-Fi Client */ -WiFiClient wifi_client; - -/* create MQTT publish-subscribe client */ -PubSubClient mqtt_client(wifi_client); - /* GPS object */ TinyGPSPlus gps; @@ -548,7 +543,7 @@ long long previous_time = 0; #define TRANSMIT_XBEE_BIT ((EventBits_t) 0x01 << 3) // for bit 3 #define DEBUG_TO_TERM_BIT ((EventBits_t) 0x01 << 4) // for bit 4 -// event group type for task syncronization +// event group type for task synchronization EventGroupHandle_t tasksDataReceiveEventGroup; /** @@ -897,7 +892,6 @@ void clearTelemetryQueueTask(void* pvParameters) { } //TODO: XBEE, DEBUG TO TERM - } } @@ -911,7 +905,7 @@ void clearTelemetryQueueTask(void* pvParameters) { * *******************************************************************************/ void checkFlightState(void* pvParameters) { - // get the flight state from the telemetry task + // get the flight state from the telemetry tasi telemetry_type_t sensor_data; while (1) { @@ -1086,6 +1080,8 @@ void logToMemory(void* pvParameter) { } + + // void transmitTelemetry(void* pvParameters){ // /* This function sends data to the ground station */ @@ -1187,6 +1183,15 @@ void logToMemory(void* pvParameter) { // } +/*!**************************************************************************** + * @brief Establish connection to MQTT + * + * + *******************************************************************************/ +void MQTTconnect() { + +} + /*!**************************************************************************** * @brief fires the pyro-charge to deploy the drogue chute @@ -1382,7 +1387,6 @@ void setup(){ } else { debugln("[-}Failed to create checkFlightState task"); } - //// /* TASK 6: FLIGHT STATE CALLBACK TASK */ th = xTaskCreatePinnedToCore(flightStateCallback,"flightStateCallback",STACK_SIZE*2,NULL,1, NULL,app_id); @@ -1407,18 +1411,18 @@ void setup(){ /* TASK 8: TRANSMIT TELEMETRY DATA */ - // if(xTaskCreate( - // transmitTelemetry, - // "transmit_telemetry", - // STACK_SIZE*2, - // NULL, - // 2, - // NULL - // ) != pdPASS){ - // debugln("[-]Transmit task failed to create"); - // }else{ - // debugln("[+]Transmit task created OK."); - // } + if(xTaskCreate( + transmitTelemetry, + "transmit_telemetry", + STACK_SIZE*2, + NULL, + 2, + NULL + ) != pdPASS){ + debugln("[-]Transmit task failed to create"); + }else{ + debugln("[+]Transmit task created OK."); + } #if LOG_TO_MEMORY // set LOG_TO_MEMORY to 1 to allow logging to memory /* TASK 9: LOG DATA TO MEMORY */ diff --git a/n4-flight-software/src/mqtt-config.cpp b/n4-flight-software/src/mqtt-config.cpp new file mode 100644 index 0000000..5bd28fd --- /dev/null +++ b/n4-flight-software/src/mqtt-config.cpp @@ -0,0 +1,50 @@ +/*!**************** + * @file mqtt-config.cpp + * This file implements functions that handle connection to MQTT + * + */ + +#include "mqtt-config.h" + +/*! + * + * @brief initialize MQTT connection parameters + * @param broker_IP IP address of the broker being used for telemetry transmission + * @param broker_port Broker port to use for connection + * @param topic Topic name on which to publish flight data + * + */ +MQTTConfig::MQTTConfig(char* broker_IP, int broker_port, char* topic) { + // copy the passed MQTT parameters to the local variables + strcpy(mqtt_broker_ip_addr, broker_IP); + strcpy(mqtt_broker_port, broker_port); + strcpy(mqtt_topic, topic); + + /* create Wi-Fi Client */ + WiFiClient wifi_client; + + /* create a pub-sub client */ + PubSubClient mqtt_client(wifi_client); + + this->MQTT_Setparameters(mqtt_client); + +} + +/*! + * @brief set MQTT connection parameters + * @param w_client + * @param mqtt_client + * @return + */ +uint8_t MQTTConfig::MQTT_Setparameters(PubSubClient mqtt_client) { + mqtt_client.setServer(this->mqtt_broker_ip_addr, this->mqtt_broker_port); +} + +/*! + * @brief auto reconnect MQTT broker and client if connection is lost + * + */ +void MQTTConfig::MQTT_Reconnect() { + // TODO: log to system logger + while(!) +} \ No newline at end of file diff --git a/n4-flight-software/src/mqtt-config.h b/n4-flight-software/src/mqtt-config.h new file mode 100644 index 0000000..5b0ccd0 --- /dev/null +++ b/n4-flight-software/src/mqtt-config.h @@ -0,0 +1,34 @@ +/*!********************** + * @file mqtt-config.h + * Handle connection to MQTT broker and data transmission over MQTT + * * + */ + + +#ifndef MQTT_CONFIG_H +#define MQTT_CONFIG_H + +#include +#include +#include +#include "defs.h" +#include "string.h" + +class MQTTConfig { + /* create Wi-Fi Client */ + WiFiClient wifi_client; + + /* create a pub-sub client */ + PubSubClient mqtt_client(wifi_client); + + public: + char mqtt_broker_ip_addr[BROKER_IP_ADDRESS_LENGTH]; + int16_t mqtt_broker_port; + char mqtt_topic[MQTT_TOPIC_LENGTH]; + + MQTTConfig(char* broker_IP, int16_t port, char* topic); + uint8_t MQTT_Setparameters(PubSubClient); + void MQTT_Reconnect(); +}; + +#endif diff --git a/n4-flight-software/src/wifi-config.cpp b/n4-flight-software/src/wifi-config.cpp new file mode 100644 index 0000000..ec3a4a5 --- /dev/null +++ b/n4-flight-software/src/wifi-config.cpp @@ -0,0 +1,37 @@ + +/*!**************************************************************************** + * @file configureWifi.cpp + * @brief This file creates methods to allow dynamic configuration of the WIFI credentials + * This allows the launch crew to avoid hardcoding the WIFI SSID and password inside the + * flight software + * + * The crew can just create the Wifi with any SSID and/or password, and this interface will allow them + * to connect to that wifi without touching the flight software + * + * This effectively adds an improved layer of abstraction + *******************************************************************************/ + + +#include "wifi-config.h" + +/*!**************************************************************************** + * @brief allow connection to WiFi + * + */ +WIFIConfig::WifiConnect() { + WiFi.mode(WIFI_STA); // start in station mode + WiFiManager wm; + bool connection_result = 0; + + // generate password procteted acess point + connection_result = wm.autoConnect("flight-computer"); + + if(!connection_result) { + return 0; + // TODO: log to system logger + } else { + // Wifi is connected here + // we will check this in main.cpp to see if we have been connected successfully + return 1; + } +} diff --git a/n4-flight-software/src/wifi-config.h b/n4-flight-software/src/wifi-config.h new file mode 100644 index 0000000..23822d6 --- /dev/null +++ b/n4-flight-software/src/wifi-config.h @@ -0,0 +1,12 @@ + +#ifndef WIFI_CONFIG_H +#define WIFI_CONFIG_H + +#include +#include "WiFiManager.h" + +class WIFIConfig { + uint8_t WifiConnect(); +}; + +#endif // WIFI_CONFIG_H \ No newline at end of file