mirror of
https://github.com/supleed2/ELEC50003-P1-CW.git
synced 2024-11-10 01:35:50 +00:00
Add missing RSSI / Signal Strength tracking
This commit is contained in:
parent
8353103e1f
commit
6ca4be5e11
|
@ -27,7 +27,7 @@
|
||||||
#define RX1pin 17 // Pin 6 on expansion board, UART1
|
#define RX1pin 17 // Pin 6 on expansion board, UART1
|
||||||
#define TX1pin 16 // Pin 7 on expansion board, UART1
|
#define TX1pin 16 // Pin 7 on expansion board, UART1
|
||||||
#define RX2pin 18 // Pin 8 on expansion board, UART2
|
#define RX2pin 18 // Pin 8 on expansion board, UART2
|
||||||
#define TX2pin 5 // Pin 9 on expansion board, UART2
|
#define TX2pin 5 // Pin 9 on expansion board, UART2
|
||||||
#define RX3pin 14 // Pin 10 on expansion board, UART3
|
#define RX3pin 14 // Pin 10 on expansion board, UART3
|
||||||
#define TX3pin 4 // Pin 11 on expansion board, UART3
|
#define TX3pin 4 // Pin 11 on expansion board, UART3
|
||||||
#define RX4pin 15 // Pin 12 on expansion board, UART4
|
#define RX4pin 15 // Pin 12 on expansion board, UART4
|
||||||
|
@ -46,6 +46,7 @@ void recvFromEnergy();
|
||||||
void sendToVision();
|
void sendToVision();
|
||||||
void recvFromVision();
|
void recvFromVision();
|
||||||
void recvFromCompass();
|
void recvFromCompass();
|
||||||
|
void updateRSSI();
|
||||||
void emergencyStop();
|
void emergencyStop();
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
@ -81,10 +82,10 @@ void setup()
|
||||||
esp_log_level_set("wifi", ESP_LOG_WARN); // enable WARN logs from WiFi stack
|
esp_log_level_set("wifi", ESP_LOG_WARN); // enable WARN logs from WiFi stack
|
||||||
esp_log_level_set("dhcpc", ESP_LOG_INFO); // enable INFO logs from DHCP client
|
esp_log_level_set("dhcpc", ESP_LOG_INFO); // enable INFO logs from DHCP client
|
||||||
|
|
||||||
Serial.begin(115200); // Set up hardware UART0 (Connected to USB port)
|
Serial.begin(115200); // Set up hardware UART0 (Connected to USB port)
|
||||||
Serial1.begin(9600, SERIAL_8N1, RX1pin, TX1pin); // Set up hardware UART1 (Connected to Drive)
|
Serial1.begin(9600, SERIAL_8N1, RX1pin, TX1pin); // Set up hardware UART1 (Connected to Drive)
|
||||||
Serial2.begin(9600, SERIAL_8N1, RX2pin, TX2pin); // Set up hardware UART2 (Connected to Energy)
|
Serial2.begin(9600, SERIAL_8N1, RX2pin, TX2pin); // Set up hardware UART2 (Connected to Energy)
|
||||||
Serial3.begin(9600, SWSERIAL_8N1, RX3pin, TX3pin); // Set up software UART3 (Connected to Vision)
|
Serial3.begin(9600, SWSERIAL_8N1, RX3pin, TX3pin); // Set up software UART3 (Connected to Vision)
|
||||||
Serial4.begin(9600, SWSERIAL_8N1, RX4pin, TX4pin); // Set up software UART4 (Connected to Compass)
|
Serial4.begin(9600, SWSERIAL_8N1, RX4pin, TX4pin); // Set up software UART4 (Connected to Compass)
|
||||||
|
|
||||||
// Set global variable startup values
|
// Set global variable startup values
|
||||||
|
@ -144,6 +145,7 @@ void loop()
|
||||||
recvFromEnergy(); // Update stats from Energy
|
recvFromEnergy(); // Update stats from Energy
|
||||||
// recvFromVision(); // Update stats from Vision
|
// recvFromVision(); // Update stats from Vision
|
||||||
recvFromCompass(); // Update stats from Compass
|
recvFromCompass(); // Update stats from Compass
|
||||||
|
updateRSSI();
|
||||||
switch (Status)
|
switch (Status)
|
||||||
{
|
{
|
||||||
case CS_ERROR:
|
case CS_ERROR:
|
||||||
|
@ -195,8 +197,8 @@ void loop()
|
||||||
break;
|
break;
|
||||||
case INSTR_WAIT: // Normal wait
|
case INSTR_WAIT: // Normal wait
|
||||||
{
|
{
|
||||||
Status = CS_WAITING; // Set waiting state
|
Status = CS_WAITING; // Set waiting state
|
||||||
waitGoal = millis() + 1000*(instr->time); // Set wait time
|
waitGoal = millis() + 1000 * (instr->time); // Set wait time
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INSTR_COLOUR:
|
case INSTR_COLOUR:
|
||||||
|
@ -486,6 +488,11 @@ void recvFromCompass()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateRSSI()
|
||||||
|
{
|
||||||
|
signalStrength = WiFi.RSSI();
|
||||||
|
}
|
||||||
|
|
||||||
void emergencyStop()
|
void emergencyStop()
|
||||||
{
|
{
|
||||||
DynamicJsonDocument tdoc(1024);
|
DynamicJsonDocument tdoc(1024);
|
||||||
|
|
Loading…
Reference in a new issue