Skip to content

Commit f8a53a0

Browse files
committed
initial integration of update firmware from SD card - compiles, menu works - not tested ...
1 parent c428b44 commit f8a53a0

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ flux_sdk_add_module(
3333
flux_network
3434
flux_sdcard
3535
flux_file
36+
flux_firmware
3637
device_bme280
3738
device_bme68x
3839
device_bmp384

sfeIoTNodeLoRaWAN/sfeIoTNodeLoRaWAN.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ const uint8_t kLoRaWANMsgLEDFlash = 0x05;
4949

5050
// Set the brightness for the on-board LED
5151
const uint8_t kLoRaWANMsgLEDBrightness = 0x06;
52+
53+
// For finding the firmware files on SD card
54+
#define kLoRaWANFirmwareFilePrefix "sfeIoTNodeLoRaWAN_"
5255
//---------------------------------------------------------------------------
5356

5457
// The default Soil Sensor pins
@@ -339,6 +342,17 @@ bool sfeIoTNodeLoRaWAN::onSetup()
339342
flxLog_W(F("Unable to initialize the SD Card. Is an SD card installed on the board?"));
340343
}
341344

345+
// Filesystem to read firmware from
346+
_sysUpdate.setFileSystem(&_theSDCard);
347+
348+
// Serial UX - used to list files to select off the filesystem
349+
_sysUpdate.setSerialSettings(_serialSettings);
350+
351+
_sysUpdate.setFirmwareFilePrefix(kLoRaWANFirmwareFilePrefix);
352+
353+
flxRegisterEventCB(flxEvent::kOnFirmwareLoad, this, &sfeIoTNodeLoRaWAN::onFirmwareLoad);
354+
flux_add(&_sysUpdate);
355+
342356
// check our on-board flash file system
343357
_hasOnBoardFlashFS = checkOnBoardFS();
344358

@@ -771,6 +785,15 @@ void sfeIoTNodeLoRaWAN::onSystemResetEvent(void)
771785
// The system is being reset - reset our settings
772786
flxSettings.reset();
773787
}
788+
//---------------------------------------------------------------------------
789+
void sfeIoTNodeLoRaWAN::onFirmwareLoad(bool bLoading)
790+
{
791+
if (bLoading)
792+
sfeLED.on(sfeLED.Yellow);
793+
else
794+
sfeLED.off();
795+
}
796+
774797
//---------------------------------------------------------------------------
775798
// Callback for LoRaWAN receive events
776799
void sfeIoTNodeLoRaWAN::onLoRaWANReceiveEvent(uint32_t data)

sfeIoTNodeLoRaWAN/sfeIoTNodeLoRaWAN.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
#include <Flux/flxLogger.h>
1818
#include <Flux/flxTimer.h>
1919

20+
#include "flxLoRaWANDigi.h"
21+
#include "flxLoRaWANLogger.h"
22+
#include "sfeNLButton.h"
2023
#include <Flux/flxDevMAX17048.h>
2124
#include <Flux/flxDevSoilMoisture.h>
2225
#include <Flux/flxFSSDCard.h>
@@ -26,12 +29,9 @@
2629
#include <Flux/flxSettingsSerial.h>
2730
#include <Flux/flxStorageJSONPref.h>
2831
#include <Flux/flxStorageKVPPref.h>
32+
#include <Flux/flxSysFirmware.h>
2933
#include <Flux/flxSystem.h>
3034

31-
#include "flxLoRaWANDigi.h"
32-
#include "flxLoRaWANLogger.h"
33-
#include "sfeNLButton.h"
34-
3535
// Buffer size of our JSON document output
3636
const uint16_t kAppJSONDocSize = 1600;
3737
// Default log interval in milli secs
@@ -134,6 +134,7 @@ class sfeIoTNodeLoRaWAN : public flxApplication
134134
void onErrorMessage(uint8_t);
135135
void onLogEvent(void);
136136
void onQwiicButtonEvent(bool);
137+
void onFirmwareLoad(bool bLoading);
137138
void onLoRaWANSendEvent(bool);
138139
void onLoRaWANReceiveEvent(uint32_t);
139140

@@ -258,6 +259,9 @@ class sfeIoTNodeLoRaWAN : public flxApplication
258259
// The soil moisture device object -- if a user connects it to the GPIO of the device.
259260
flxDevSoilMoisture _soilSensor;
260261

262+
// The system firmware object
263+
flxSysFirmware _sysUpdate;
264+
261265
// for our button events of the board
262266
sfeNLButton _boardButton;
263267

0 commit comments

Comments
 (0)