Skip to content
This repository has been archived by the owner on Feb 4, 2023. It is now read-only.

Commit

Permalink
v1.6.0
Browse files Browse the repository at this point in the history
#### New in v1.6.0

1. Sync'ed with latest WiFiNINA Library v1.6.0. 
2. New features include ***WiFiStorage*** and update to ***NINA Firmware v1.4.0*** from v1.3.0
3. Enhance debugging tool
  • Loading branch information
khoih-prog authored Jul 21, 2020
1 parent 1db944e commit fe4d77b
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 96 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

1. Sync'ed with latest WiFiNINA Library v1.6.0.
2. New features include ***WiFiStorage*** and update to ***NINA Firmware v1.4.0*** from v1.3.0
3. Enhance debugging tool

#### New in v1.5.3

Expand Down
19 changes: 11 additions & 8 deletions src/WiFiClient_Generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@
1.6.0 K Hoang 19/07/2020 Sync with Aruino WiFiNINA Library v1.6.0 (new Firmware 1.4.0 and WiFiStorage)
*****************************************************************************************************************************/

extern "C" {
#include "utility/wl_definitions.h"
#include "utility/wl_types.h"
#include "string.h"
#include "utility/debug.h"
#define _WIFININA_LOGLEVEL_ 1

extern "C"
{
#include "utility/wl_definitions.h"
#include "utility/wl_types.h"
#include "string.h"
#include "utility/debug.h"
}


Expand Down Expand Up @@ -101,7 +104,7 @@ int WiFiClient::connect(IPAddress ip, uint16_t port)
else
{
// KH
LOGDEBUG("No Socket available");
NN_LOGDEBUG("No Socket available");

return 0;
}
Expand Down Expand Up @@ -136,7 +139,7 @@ int WiFiClient::connectSSL(IPAddress ip, uint16_t port)
else
{
// KH
LOGDEBUG("No Socket available");
NN_LOGDEBUG("No Socket available");

return 0;
}
Expand Down Expand Up @@ -170,7 +173,7 @@ int WiFiClient::connectSSL(const char *host, uint16_t port)
else
{
// KH
LOGDEBUG("No Socket available");
NN_LOGDEBUG("No Socket available");

return 0;
}
Expand Down
31 changes: 30 additions & 1 deletion src/WiFiServer_Generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
#include <string.h>
#include "utility/server_drv.h"

#define _WIFININA_LOGLEVEL_ 1

extern "C"
{
#include "utility/debug.h"
Expand Down Expand Up @@ -88,19 +90,38 @@ WiFiClient WiFiServer::available(byte* status)
{
// check previous received client socket
if (_lastSock != NO_SOCKET_AVAIL)
{
{
WiFiClient client(_lastSock);

// KH, from v1.6.0 debug
NN_LOGDEBUG1("WiFiServer::available: _lastSock =", _lastSock);

if (client.connected())
NN_LOGDEBUG("WiFiServer::available: client.connected");

if (client.available())
NN_LOGDEBUG("WiFiServer::available: client.available");


//////

if (client.connected() && client.available())
{
sock = _lastSock;

// KH, from v1.6.0 debug
NN_LOGDEBUG1("WiFiServer::available: sock/_lastSock =", sock);
}
}

if (sock == NO_SOCKET_AVAIL)
{
// check for new client socket
sock = ServerDrv::availServer(_sock);

// KH, from v1.6.0 debug
//NN_LOGDEBUG1("WiFiServer::available: sock =", sock);
//////
}
}

Expand All @@ -114,10 +135,18 @@ WiFiClient WiFiServer::available(byte* status)
}

_lastSock = sock;

// KH, from v1.6.0 debug
NN_LOGDEBUG1("WiFiServer::available: Client OK, sock =", sock);
//////

return client;
}

// KH, from v1.6.0 debug
NN_LOGDEBUG("WiFiServer::available: Client not OK");
//////

return WiFiClient(255);
}

Expand Down
2 changes: 2 additions & 0 deletions src/WiFiServer_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
extern "C"
{
#include "utility/wl_definitions.h"
// KH, from v1.6.0
#include "utility/debug.h"
}

#include "Server.h"
Expand Down
1 change: 1 addition & 0 deletions src/WiFiUdp_Generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ class WiFiUDP : public UDP
friend class WiFiDrv;
};


#endif //WiFiUDP_Generic_h
12 changes: 6 additions & 6 deletions src/WiFi_Generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int WiFiClass::begin(const char* ssid, const char *passphrase)
if ((status != WL_IDLE_STATUS) && (status != WL_NO_SSID_AVAIL) && (status != WL_SCAN_COMPLETED))
{
//KH
LOGDEBUG1("WiFi-begin: return1 = ", status);
NN_LOGDEBUG1("WiFi-begin: return1 = ", status);
break;
}
}
Expand All @@ -135,7 +135,7 @@ int WiFiClass::begin(const char* ssid, const char *passphrase)
}

//KH
LOGDEBUG1("WiFi-begin: return2 = ", status);
NN_LOGDEBUG1("WiFi-begin: return2 = ", status);

return status;
}
Expand All @@ -159,7 +159,7 @@ uint8_t WiFiClass::beginAP(const char *ssid, uint8_t channel)
if ((status != WL_IDLE_STATUS) && (status != WL_NO_SSID_AVAIL) && (status != WL_SCAN_COMPLETED))
{
//KH
LOGDEBUG1("WiFi-beginAP2: return1 = ", status);
NN_LOGDEBUG1("WiFi-beginAP2: return1 = ", status);

break;
}
Expand All @@ -171,7 +171,7 @@ uint8_t WiFiClass::beginAP(const char *ssid, uint8_t channel)
}

//KH
LOGDEBUG1("WiFi-beginAP2: return2 = ", status);
NN_LOGDEBUG1("WiFi-beginAP2: return2 = ", status);

return status;
}
Expand All @@ -197,7 +197,7 @@ uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase, uint8_t cha
if ((status != WL_IDLE_STATUS) && (status != WL_NO_SSID_AVAIL) && (status != WL_SCAN_COMPLETED))
{
//KH
LOGDEBUG1("WiFi-beginAP3: return1 = ", status);
NN_LOGDEBUG1("WiFi-beginAP3: return1 = ", status);

break;
}
Expand All @@ -209,7 +209,7 @@ uint8_t WiFiClass::beginAP(const char *ssid, const char* passphrase, uint8_t cha
}

//KH
LOGDEBUG1("WiFi-beginAP3: return2 = ", status);
NN_LOGDEBUG1("WiFi-beginAP3: return2 = ", status);

return status;
}
Expand Down
35 changes: 20 additions & 15 deletions src/utility/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@

// KH Add, v1.6.0
#ifdef DEBUG_WIFININA_PORT
#define DBG_PORT DEBUG_WIFININA_PORT
#define DBG_PORT_NN DEBUG_WIFININA_PORT
#else
#define DBG_PORT Serial
#define DBG_PORT_NN Serial
#endif

// Change _WIFININA_LOGLEVEL_ to set tracing and logging verbosity
Expand All @@ -72,25 +72,27 @@
// Error waitResponse message
#define ERROR_RESPONSE ":Error waitResponse"

#define LOGERROR(x) if(_WIFININA_LOGLEVEL_>0) { DBG_PORT.print("[NN] "); DBG_PORT.println(x); }
#define LOGERROR1(x,y) if(_WIFININA_LOGLEVEL_>0) { DBG_PORT.print("[NN] "); DBG_PORT.print(x); DBG_PORT.print(" "); DBG_PORT.println(y); }
#define NN_LOGERROR(x) if(_WIFININA_LOGLEVEL_>0) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.println(x); }
#define NN_LOGERROR1(x,y) if(_WIFININA_LOGLEVEL_>0) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.print(x); DBG_PORT_NN.print(" "); DBG_PORT_NN.println(y); }

#define LOGWARN(x) if(_WIFININA_LOGLEVEL_>1) { DBG_PORT.print("[NN] "); DBG_PORT.println(x); }
#define LOGWARN1(x,y) if(_WIFININA_LOGLEVEL_>1) { DBG_PORT.print("[NN] "); DBG_PORT.print(x); DBG_PORT.print(" "); DBG_PORT.println(y); }
#define NN_LOGWARN(x) if(_WIFININA_LOGLEVEL_>1) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.println(x); }
#define NN_LOGWARN1(x,y) if(_WIFININA_LOGLEVEL_>1) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.print(x); DBG_PORT_NN.print(" "); DBG_PORT_NN.println(y); }

#define LOGINFO(x) if(_WIFININA_LOGLEVEL_>2) { DBG_PORT.print("[NN] "); DBG_PORT.println(x); }
#define LOGINFO1(x,y) if(_WIFININA_LOGLEVEL_>2) { DBG_PORT.print("[NN] "); DBG_PORT.print(x); DBG_PORT.print(" "); DBG_PORT.println(y); }
#define LOGINFO2(x,y,z) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT.print("[NN] "); DBG_PORT.print(x); DBG_PORT.print(" "); DBG_PORT.print(y); DBG_PORT.print(" "); DBG_PORT.println(z); }
#define LOGINFO3(x,y,z,w) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT.print("[NN] "); DBG_PORT.print(x); DBG_PORT.print(" "); DBG_PORT.print(y); DBG_PORT.print(" "); DBG_PORT.println(z); DBG_PORT.print(" "); DBG_PORT.println(w); }
#define NN_LOGINFO(x) if(_WIFININA_LOGLEVEL_>2) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.println(x); }
#define NN_LOGINFO1(x,y) if(_WIFININA_LOGLEVEL_>2) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.print(x); DBG_PORT_NN.print(" "); DBG_PORT_NN.println(y); }
#define NN_LOGINFO2(x,y,z) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.print(x); DBG_PORT_NN.print(" "); DBG_PORT_NN.print(y); DBG_PORT_NN.print(" "); DBG_PORT_NN.println(z); }
#define NN_LOGINFO3(x,y,z,w) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.print(x); DBG_PORT_NN.print(" "); DBG_PORT_NN.print(y); DBG_PORT_NN.print(" "); DBG_PORT_NN.println(z); DBG_PORT_NN.print(" "); DBG_PORT_NN.println(w); }

#define LOGDEBUG(x) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT.print("[NN] "); DBG_PORT.println(x); }
#define LOGDEBUG0(x) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT.print("[NN] "); DBG_PORT.print(x); }
#define LOGDEBUG1(x,y) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT.print("[NN] "); DBG_PORT.print(x); DBG_PORT.print(" "); DBG_PORT.println(y); }
#define LOGDEBUG2(x,y,z) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT.print("[NN] "); DBG_PORT.print(x); DBG_PORT.print(" "); DBG_PORT.print(y); DBG_PORT.print(" "); DBG_PORT.println(z); }
#define LOGDEBUG3(x,y,z,w) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT.print("[NN] "); DBG_PORT.print(x); DBG_PORT.print(" "); DBG_PORT.print(y); DBG_PORT.print(" "); DBG_PORT.println(z); DBG_PORT.print(" "); DBG_PORT.println(w); }
#define NN_LOGDEBUG(x) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.println(x); }
#define NN_LOGDEBUG0(x) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.print(x); }
#define NN_LOGDEBUG1(x,y) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.print(x); DBG_PORT_NN.print(" "); DBG_PORT_NN.println(y); }
#define NN_LOGDEBUG2(x,y,z) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.print(x); DBG_PORT_NN.print(" "); DBG_PORT_NN.print(y); DBG_PORT_NN.print(" "); DBG_PORT_NN.println(z); }
#define NN_LOGDEBUG3(x,y,z,w) if(_WIFININA_LOGLEVEL_>3) { DBG_PORT_NN.print("[NN] "); DBG_PORT_NN.print(x); DBG_PORT_NN.print(" "); DBG_PORT_NN.print(y); DBG_PORT_NN.print(" "); DBG_PORT_NN.println(z); DBG_PORT_NN.print(" "); DBG_PORT_NN.println(w); }

//////

#if 0

#define PRINT_FILE_LINE() do { \
Serial.print("[");Serial.print(__FILE__); \
Serial.print("::");Serial.print(__LINE__);Serial.print("]");\
Expand Down Expand Up @@ -130,6 +132,8 @@
#define WARN(args) do {} while (0);
#endif

#endif // if 0


//KH
#define _DEBUG_SPI_ false
Expand Down Expand Up @@ -158,4 +162,5 @@
#define TOGGLE_TRIGGER()
#endif


#endif // Debug_H
26 changes: 13 additions & 13 deletions src/utility/server_drv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void ServerDrv::startServer(uint16_t port, uint8_t sock, uint8_t protMode)

if (!SpiDrv::waitResponseCmd(START_SERVER_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::startServer1", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::startServer1", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand All @@ -102,7 +102,7 @@ void ServerDrv::startServer(uint32_t ipAddress, uint16_t port, uint8_t sock, uin

if (!SpiDrv::waitResponseCmd(START_SERVER_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::startServer2", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::startServer2", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down Expand Up @@ -130,7 +130,7 @@ void ServerDrv::startClient(uint32_t ipAddress, uint16_t port, uint8_t sock, uin

if (!SpiDrv::waitResponseCmd(START_CLIENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::startClient1", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::startClient1", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down Expand Up @@ -167,7 +167,7 @@ void ServerDrv::startClient(const char* host, uint8_t host_len, uint32_t ipAddre

if (!SpiDrv::waitResponseCmd(START_CLIENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::startClient2", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::startClient2", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down Expand Up @@ -196,7 +196,7 @@ void ServerDrv::stopClient(uint8_t sock)

if (!SpiDrv::waitResponseCmd(STOP_CLIENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::stopClient", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::stopClient", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down Expand Up @@ -225,7 +225,7 @@ uint8_t ServerDrv::getServerState(uint8_t sock)

if (!SpiDrv::waitResponseCmd(GET_STATE_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::getServerState", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::getServerState", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down Expand Up @@ -255,7 +255,7 @@ uint8_t ServerDrv::getClientState(uint8_t sock)

if (!SpiDrv::waitResponseCmd(GET_CLIENT_STATE_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::getClientState", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::getClientState", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down Expand Up @@ -351,7 +351,7 @@ bool ServerDrv::getData(uint8_t sock, uint8_t *data, uint8_t peek)

if (!SpiDrv::waitResponseData8(GET_DATA_TCP_CMD, &_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::getData", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::getData", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down Expand Up @@ -392,7 +392,7 @@ bool ServerDrv::getDataBuf(uint8_t sock, uint8_t *_data, uint16_t *_dataLen)
// Wait for reply
if (!SpiDrv::waitResponseData16(GET_DATABUF_TCP_CMD, _data, _dataLen))
{
LOGDEBUG1("ServerDrv::getDataBuf", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::getDataBuf", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down Expand Up @@ -433,7 +433,7 @@ bool ServerDrv::insertDataBuf(uint8_t sock, const uint8_t *data, uint16_t _len)

if (!SpiDrv::waitResponseData8(INSERT_DATABUF_CMD, &_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::insertDataBuf", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::insertDataBuf", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down Expand Up @@ -468,7 +468,7 @@ bool ServerDrv::sendUdpData(uint8_t sock)

if (!SpiDrv::waitResponseData8(SEND_DATA_UDP_CMD, &_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::sendUdpData", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::sendUdpData", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down Expand Up @@ -509,7 +509,7 @@ uint16_t ServerDrv::sendData(uint8_t sock, const uint8_t *data, uint16_t len)

if (!SpiDrv::waitResponseData8(SEND_DATA_TCP_CMD, (uint8_t*)&_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::sendData", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::sendData", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down Expand Up @@ -544,7 +544,7 @@ uint8_t ServerDrv::checkDataSent(uint8_t sock)
// Wait for reply
if (!SpiDrv::waitResponseCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
LOGDEBUG1("ServerDrv::checkDataSent", ERROR_RESPONSE);
NN_LOGDEBUG1("ServerDrv::checkDataSent", ERROR_RESPONSE);
}

SpiDrv::spiSlaveDeselect();
Expand Down
Loading

0 comments on commit fe4d77b

Please sign in to comment.