mirror of https://github.com/noisymime/Arduino.git
Added function to get firmware version
This commit is contained in:
parent
6ab79f0536
commit
6f27863ae5
|
@ -34,6 +34,11 @@ uint8_t WiFiClass::getSocket()
|
|||
return NO_SOCKET_AVAIL;
|
||||
}
|
||||
|
||||
char* WiFiClass::firmwareVersion()
|
||||
{
|
||||
return WiFiDrv::getFwVersion();
|
||||
}
|
||||
|
||||
int WiFiClass::begin(char* ssid)
|
||||
{
|
||||
uint8_t status = WL_IDLE_STATUS;
|
||||
|
|
|
@ -28,6 +28,12 @@ public:
|
|||
*/
|
||||
static uint8_t getSocket();
|
||||
|
||||
/*
|
||||
* Get firmware version
|
||||
*/
|
||||
static char* firmwareVersion();
|
||||
|
||||
|
||||
/* Start Wifi connection for OPEN networks
|
||||
*
|
||||
* param ssid: Pointer to the SSID string.
|
||||
|
|
|
@ -7,11 +7,12 @@ extern "C" {
|
|||
#include "debug.h"
|
||||
}
|
||||
|
||||
#define DATAOUT 11//MOSI
|
||||
#define DATAIN 12//MISO
|
||||
#define SPICLOCK 13//sck
|
||||
#define SLAVESELECT 10//ss
|
||||
#define SLAVEREADY 3
|
||||
#define DATAOUT 11 // MOSI
|
||||
#define DATAIN 12 // MISO
|
||||
#define SPICLOCK 13 // sck
|
||||
#define SLAVESELECT 10 // ss
|
||||
#define SLAVEREADY 3 // handshake pin
|
||||
#define WIFILED 9 // led on wifi shield
|
||||
|
||||
#define DELAY_100NS do { asm volatile("nop"); }while(0);
|
||||
#define DELAY_SPI(X) { int ii=0; do { asm volatile("nop"); }while(++ii<X);}
|
||||
|
@ -30,11 +31,13 @@ void SpiDrv::begin()
|
|||
pinMode(SS, OUTPUT);
|
||||
pinMode(SLAVESELECT, OUTPUT);
|
||||
pinMode(SLAVEREADY, INPUT);
|
||||
pinMode(WIFILED, OUTPUT);
|
||||
|
||||
digitalWrite(SCK, LOW);
|
||||
digitalWrite(MOSI, LOW);
|
||||
digitalWrite(SS, HIGH);
|
||||
digitalWrite(SLAVESELECT, HIGH);
|
||||
digitalWrite(WIFILED, LOW);
|
||||
|
||||
#ifdef _DEBUG_
|
||||
INIT_TRIGGER()
|
||||
|
|
|
@ -26,6 +26,8 @@ uint8_t WiFiDrv::_mac[] = {0};
|
|||
uint8_t WiFiDrv::_localIp[] = {0};
|
||||
uint8_t WiFiDrv::_subnetMask[] = {0};
|
||||
uint8_t WiFiDrv::_gatewayIp[] = {0};
|
||||
// Firmware version
|
||||
char WiFiDrv::fwVersion[] = {0};
|
||||
|
||||
|
||||
// Private Methods
|
||||
|
@ -467,4 +469,23 @@ int WiFiDrv::getHostByName(const char* aHostname, IPAddress& aResult)
|
|||
return (retry>0);
|
||||
}
|
||||
|
||||
char* WiFiDrv::getFwVersion()
|
||||
{
|
||||
WAIT_FOR_SLAVE_SELECT();
|
||||
// Send Command
|
||||
SpiDrv::sendCmd(GET_FW_VERSION_CMD, PARAM_NUMS_0);
|
||||
|
||||
//Wait the reply elaboration
|
||||
SpiDrv::waitForSlaveReady();
|
||||
|
||||
// Wait for reply
|
||||
uint8_t _dataLen = 0;
|
||||
if (!SpiDrv::waitResponseCmd(GET_FW_VERSION_CMD, PARAM_NUMS_1, (uint8_t*)fwVersion, &_dataLen))
|
||||
{
|
||||
WARN("error waitResponse");
|
||||
}
|
||||
SpiDrv::spiSlaveDeselect();
|
||||
return fwVersion;
|
||||
}
|
||||
|
||||
WiFiDrv wiFiDrv;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#define KEY_IDX_LEN 1
|
||||
// 5 secs of delay to have the connection established
|
||||
#define WL_DELAY_START_CONNECTION 5000
|
||||
// firmware version string length
|
||||
#define WL_FW_VER_LENGTH 6
|
||||
|
||||
class WiFiDrv
|
||||
{
|
||||
|
@ -18,6 +20,9 @@ private:
|
|||
static int32_t _networkRssi[WL_NETWORKS_LIST_MAXNUM];
|
||||
static uint8_t _networkEncr[WL_NETWORKS_LIST_MAXNUM];
|
||||
|
||||
// firmware version string in the format a.b.c
|
||||
static char fwVersion[WL_FW_VER_LENGTH];
|
||||
|
||||
// settings of current selected network
|
||||
static char _ssid[WL_SSID_MAX_LENGTH];
|
||||
static uint8_t _bssid[WL_MAC_ADDR_LENGTH];
|
||||
|
@ -201,6 +206,12 @@ public:
|
|||
*/
|
||||
static int getHostByName(const char* aHostname, IPAddress& aResult);
|
||||
|
||||
/*
|
||||
* Get the firmware version
|
||||
* result: version as string with this format a.b.c
|
||||
*/
|
||||
static char* getFwVersion();
|
||||
|
||||
};
|
||||
|
||||
extern WiFiDrv wiFiDrv;
|
||||
|
|
|
@ -48,6 +48,7 @@ enum {
|
|||
REQ_HOST_BY_NAME_CMD= 0x34,
|
||||
GET_HOST_BY_NAME_CMD= 0x35,
|
||||
START_SCAN_NETWORKS = 0x36,
|
||||
GET_FW_VERSION_CMD = 0x37,
|
||||
|
||||
// All command with DATA_FLAG 0x40 send a 16bit Len
|
||||
|
||||
|
|
Loading…
Reference in New Issue