miao zhicheng
/
DragonflyMQTT
Using MQTT on Dragonfly
Revision 8:f8a346582627, committed 2017-09-14
- Comitter:
- miaotwilio
- Date:
- Thu Sep 14 08:14:18 2017 +0000
- Parent:
- 7:e741097b1c5d
- Commit message:
- more LEDs
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r e741097b1c5d -r f8a346582627 main.cpp --- a/main.cpp Fri Sep 08 07:40:00 2017 +0000 +++ b/main.cpp Thu Sep 14 08:14:18 2017 +0000 @@ -2,7 +2,7 @@ #include "TripDataReader.hpp" #include "TlsMQTTClient.hpp" #include "Certificates.h" -#include "config.hpp" +#include "config.example.hpp" #include <mbed.h> #include <mtsas.h> #include <ssl.h> @@ -12,18 +12,21 @@ // BC_NCE = 1 disables the battery charger DigitalOut bc_nce(PB_2); -DigitalOut ledGPS(D8); +DigitalOut ledNotEntered(D7); +DigitalOut ledCellular(D4); +DigitalOut ledGPS(D5); +DigitalOut ledOBD(D8); +DigitalOut ledSendingVehicleData(D6); +DigitalOut ledSendingVehicleDataFailed(D3); static bool enableODB = false; static Ticker vehicleDataSamplingTicker; static const int VEHICLE_DATA_SAMPLING_PERIOD_MS = 50; static const int VEHICLE_DATA_REPORTING_PERIOD_MS = 3000; MTSSerial obd(D1, D0); -DigitalOut ledOBD(D6); static TripDataReader* pTripDataReader = NULL; static void vehicleDataSamplingCallback(); -DigitalOut vehicleDataLED(D5); static void sendVehicleData(const MTSCellularManager::GPSStatus& gpsStatus, const TripDataReader::TripData& tripData); @@ -33,8 +36,12 @@ // Disable the battery charger unless a battery is attached. bc_nce = 1; - vehicleDataLED = 1; + ledNotEntered = 1; + ledCellular = 1; ledGPS = 1; + ledOBD = 1; + ledSendingVehicleData = 1; + ledSendingVehicleDataFailed = 1; // Change the baud rate of the debug port from the default 9600 to 115200. Serial debug(USBTX, USBRX); @@ -60,6 +67,7 @@ wait(1); } } + ledCellular = 0; { logInfo("Initializing GPS"); @@ -120,7 +128,8 @@ static void sendVehicleData(const MTSCellularManager::GPSStatus& gpsStatus, const TripDataReader::TripData& tripData) { - vehicleDataLED = 0; + ledSendingVehicleDataFailed = 1; + ledSendingVehicleData = 0; logInfo("Connecting MQTT Client"); TlsMQTTClient client = TlsMQTTClient(); @@ -179,9 +188,10 @@ logInfo("MQTT disconnecting"); client.disconnect(); } else { + ledSendingVehicleDataFailed = 0; logError("MQTT connection failed %d", result); } - vehicleDataLED = 1; + ledSendingVehicleData = 1; } /*