Skip to content

Commit 1c889de

Browse files
pennamandreagilardoni
authored andcommitted
Add command to get firmware version as uint32
1 parent 0788453 commit 1c889de

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed

src/WiFi.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ const char* WiFiClass::firmwareVersion()
4141
return WiFiDrv::getFwVersion();
4242
}
4343

44+
uint32_t WiFiClass::firmwareVersionU32()
45+
{
46+
return WiFiDrv::getFwVersionU32();
47+
}
48+
4449
int WiFiClass::begin(const char* ssid)
4550
{
4651
uint8_t status = WL_IDLE_STATUS;

src/WiFi.h

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class WiFiClass
5353
* Get firmware version
5454
*/
5555
static const char* firmwareVersion();
56+
uint32_t firmwareVersionU32();
5657

5758

5859
/* Start WiFi connection for OPEN networks

src/utility/wifi_drv.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,28 @@ const char* WiFiDrv::getFwVersion()
840840
return fwVersion;
841841
}
842842

843+
uint32_t WiFiDrv::getFwVersionU32()
844+
{
845+
WAIT_FOR_SLAVE_SELECT();
846+
// Send Command
847+
SpiDrv::sendCmd(GET_FW_VERSION_U32_CMD, PARAM_NUMS_0);
848+
849+
SpiDrv::spiSlaveDeselect();
850+
//Wait the reply elaboration
851+
SpiDrv::waitForSlaveReady();
852+
SpiDrv::spiSlaveSelect();
853+
854+
// Wait for reply
855+
uint8_t _data[4] = {0,0,0,0};
856+
uint8_t _dataLen = 0;
857+
if (!SpiDrv::waitResponseCmd(GET_FW_VERSION_U32_CMD, PARAM_NUMS_1, _data, &_dataLen))
858+
{
859+
WARN("error waitResponse");
860+
}
861+
SpiDrv::spiSlaveDeselect();
862+
return _data[0] << 16| _data[1] << 8 | _data[2];
863+
}
864+
843865
uint32_t WiFiDrv::getTime()
844866
{
845867
WAIT_FOR_SLAVE_SELECT();

src/utility/wifi_drv.h

+1
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ class WiFiDrv
278278
* result: version as string with this format a.b.c
279279
*/
280280
static const char* getFwVersion();
281+
static uint32_t getFwVersionU32();
281282

282283
static uint32_t getTime();
283284
static int setTime(uint32_t epochTime);

src/utility/wifi_spi.h

+1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ enum {
118118
PREFERENCES_GETTYPE = 0x5D,
119119

120120
// regular format commands
121+
GET_FW_VERSION_U32_CMD = 0x5E,
121122
SET_TIME_CMD = 0x5F,
122123

123124
// regular format commands

0 commit comments

Comments
 (0)