Debug on Server TCP

This commit is contained in:
mlafauci 2011-04-21 07:47:54 +02:00
parent 41bce76a03
commit 49912f241f
12 changed files with 153 additions and 110 deletions

View File

@ -35,10 +35,7 @@ Client Server::available(byte* status)
*status == ESTABLISHED)
{
return client; //TODO
}else{
delayMicroseconds(100);
}
}
}

View File

@ -49,17 +49,18 @@ int WiFiClass::begin()
int WiFiClass::begin(char* ssid)
{
uint8_t status = WL_IDLE_STATUS;
init();
uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION;
begin();
if (WiFiDrv::wifiSetNetwork(ssid, strlen(ssid)) != WL_FAILURE)
{
do
{
delay(WL_DELAY_START_CONNECTION);
status = WiFiDrv::getConnectionStatus();
}
while (( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED));
while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
}else
{
status = WL_CONNECT_FAILED;
@ -70,7 +71,9 @@ int WiFiClass::begin(char* ssid)
int WiFiClass::begin(char* ssid, uint8_t key_idx, const char *key)
{
uint8_t status = WL_IDLE_STATUS;
init();
uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION;
begin();
// set encryption key
if (WiFiDrv::wifiSetKey(ssid, strlen(ssid), key_idx, key, strlen(key)) != WL_FAILURE)
{
@ -79,7 +82,7 @@ int WiFiClass::begin(char* ssid, uint8_t key_idx, const char *key)
delay(WL_DELAY_START_CONNECTION);
status = WiFiDrv::getConnectionStatus();
}
while (( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED));
while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
}else{
status = WL_CONNECT_FAILED;
}
@ -89,7 +92,9 @@ int WiFiClass::begin(char* ssid, uint8_t key_idx, const char *key)
int WiFiClass::begin(char* ssid, const char *passphrase)
{
uint8_t status = WL_IDLE_STATUS;
init();
uint8_t attempts = WL_MAX_ATTEMPT_CONNECTION;
begin();
// set passphrase
if (WiFiDrv::wifiSetPassphrase(ssid, strlen(ssid), passphrase, strlen(passphrase))!= WL_FAILURE)
{
@ -98,7 +103,7 @@ int WiFiClass::begin(char* ssid, const char *passphrase)
delay(WL_DELAY_START_CONNECTION);
status = WiFiDrv::getConnectionStatus();
}
while (( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED));
while ((( status == WL_IDLE_STATUS)||(status == WL_SCAN_COMPLETED))&&(--attempts>0));
}else{
status = WL_CONNECT_FAILED;
}

View File

@ -149,8 +149,9 @@ void loop()
byte _status = 0;
Client client = server.available(&_status);
if (client) {
//Serial.print("Status: ");
//Serial.println(status, 16);
Serial.print("Status: ");
Serial.println(status, 16);
/*
byte idx = 0;
while (client.available())
{
@ -164,6 +165,7 @@ void loop()
server.write((char*)&dataBuf[0]);
}
return;
*/
}
}
}

View File

@ -23,12 +23,13 @@ char ssidList[MAX_NUM_SSID][32] = { {0} };
Server server(23);
boolean gotAMessage = false; // whether or not you got a message from the client yet
void printIpData()
{
ip = WiFi.localIp();
Serial.print("IP: ");
Serial.print("\nIP: ");
Serial.print(ip[3],10);Serial.print(".");
Serial.print(ip[2],10);Serial.print(".");
Serial.print(ip[1],10);Serial.print(".");
@ -85,7 +86,7 @@ void printCurrNet()
void scanNetworks()
{
Serial.println("** Scan Networks **");
Serial.println("\n** Scan Networks **");
byte numSsid = WiFi.scanNetworks();
if (numSsid > MAX_NUM_SSID) numSsid = MAX_NUM_SSID;
Serial.print("SSID List:");
@ -100,7 +101,8 @@ void scanNetworks()
int startWiFiWpa()
{
Serial.println("Setup WiFi Wpa...");
Serial.println("\nSetup WiFi Wpa...");
//strcpy(ssid, "AndroidAP9647");
strcpy(ssid, "Cariddi");
Serial.print("SSID: ");
Serial.println(ssid);
@ -127,44 +129,71 @@ void setup()
if ( _status == WL_CONNECTED)
{
Serial.println("Wifi Connected!");
Serial.println("\nWifi Connected!");
printIpData();
printCurrNet();
scanNetworks();
Serial.println("Starting server...");
Serial.println("\nStarting server...");
server.begin();
delay(1000);
}
}
void execCmd(char* buf)
{
Serial.print("Executing command: ");
Serial.println(buf);
server.write(buf);
}
void loop()
{
if (status == WL_CONNECTED)
{
byte _status = 0;
Client client = server.available(&_status);
//delay(2000);
if (client) {
//Serial.print("Status: ");
//Serial.println(status, 16);
byte idx = 0;
if (!gotAMessage) {
Serial.println("We have a new client");
client.println("Hello, client!");
gotAMessage = true;
}
/*
// read the bytes incoming from the client:
char thisChar = client.read();
// echo the bytes back to the client:
server.write(thisChar);
// echo the bytes to the server as well:
Serial.print(thisChar);
*/
/*
Serial.print("Status: ");
Serial.println(_status, 16);
delay(2000);
*/
static byte idx = 0;
while (client.available())
{
dataBuf[idx++] = client.read();
}
if (idx>0)
delay(10);
dataBuf[idx] = client.read();
Serial.print(dataBuf[idx]);
if (dataBuf[idx] = 0xa)
{
dataBuf[idx]=0;
Serial.println((char*)&dataBuf[0]);
server.write((char*)&dataBuf[0]);
dataBuf[idx+1]=0;
//Serial.println((char*)dataBuf);
//execCmd((char*)dataBuf);
idx=0;
}else{
++idx;
}
}
return;
}
}
}

View File

@ -119,9 +119,11 @@ void setup()
{
Serial.begin(9600);
Serial.println("*** Start WiFi example ***");
delay(3000);
WiFi.begin();
scanNetworks();
startWiFiWep();
if ( status == WL_CONNECTED)
@ -131,41 +133,11 @@ void setup()
printIpData();
printCurrNet();
scanNetworks();
Serial.println("Starting server...");
server.begin();
delay(1000);
}
}
void loop()
{
if (status == WL_CONNECTED)
{
byte _status = 0;
Client client = server.available(&_status);
if (client) {
//Serial.print("Status: ");
//Serial.println(status, 16);
byte idx = 0;
while (client.available())
{
dataBuf[idx++] = client.read();
}
if (idx>0)
{
dataBuf[idx]=0;
Serial.println((char*)&dataBuf[0]);
server.write((char*)&dataBuf[0]);
}
return;
}
}
}

View File

@ -44,6 +44,7 @@
#else
#define INFO1(x) do {} while(0);
#define INFO2(x,y) do {} while(0);
#define INFO(format, args...) do {} while(0);
#endif

View File

@ -3,6 +3,8 @@
#include "WProgram.h"
#include "spi_drv.h"
#define _DEBUG_
extern "C" {
#include "wl_types.h"
#include "debug.h"
@ -15,7 +17,7 @@ void ServerDrv::StartServer(uint16_t port, uint8_t sock)
WAIT_FOR_SLAVE_SELECT();
// Send Command
SpiDrv::sendCmd(START_SERVER_TCP_CMD, PARAM_NUMS_2);
SpiDrv::sendParam(port);SpiDrv::spiSlaveSelect();
SpiDrv::sendParam(port);
SpiDrv::sendParam(&sock, 1, LAST_PARAM);
//Wait the reply elaboration
@ -24,7 +26,7 @@ void ServerDrv::StartServer(uint16_t port, uint8_t sock)
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
if (!SpiDrv::waitResponse(START_SERVER_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
if (!SpiDrv::waitResponseCmd(START_SERVER_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
WARN("error waitResponse");
}
@ -45,12 +47,11 @@ uint8_t ServerDrv::getState(uint8_t sock)
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
if (!SpiDrv::waitResponse(GET_STATE_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
if (!SpiDrv::waitResponseCmd(GET_STATE_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
WARN("error waitResponse");
}
SpiDrv::spiSlaveDeselect();
return _data;
}
@ -68,7 +69,7 @@ uint8_t ServerDrv::availData(uint8_t sock)
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
if (!SpiDrv::waitResponse(AVAIL_DATA_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
if (!SpiDrv::waitResponseCmd(AVAIL_DATA_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
WARN("error waitResponse");
}
@ -94,7 +95,7 @@ bool ServerDrv::getData(uint8_t sock, uint8_t *data)
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
if (!SpiDrv::waitResponse(GET_DATA_TCP_CMD, &_data, &_dataLen))
if (!SpiDrv::waitResponseData8(GET_DATA_TCP_CMD, &_data, &_dataLen))
{
WARN("error waitResponse");
}
@ -112,13 +113,13 @@ bool ServerDrv::getDataBuf(uint8_t sock, uint8_t *_data, uint16_t *_dataLen)
WAIT_FOR_SLAVE_SELECT();
// Send Command
SpiDrv::sendCmd(GET_DATABUF_TCP_CMD, PARAM_NUMS_1);
SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
SpiDrv::sendBuffer(&sock, sizeof(sock), LAST_PARAM);
//Wait the reply elaboration
SpiDrv::waitForSlaveReady();
// Wait for reply
if (!SpiDrv::waitResponse(GET_DATABUF_TCP_CMD, _data, _dataLen))
if (!SpiDrv::waitResponseData16(GET_DATABUF_TCP_CMD, _data, _dataLen))
{
WARN("error waitResponse");
}
@ -136,7 +137,7 @@ bool ServerDrv::sendData(uint8_t sock, const uint8_t *data, uint16_t len)
WAIT_FOR_SLAVE_SELECT();
// Send Command
SpiDrv::sendCmd(SEND_DATA_TCP_CMD, PARAM_NUMS_2);
SpiDrv::sendParam(&sock, sizeof(sock));
SpiDrv::sendBuffer(&sock, sizeof(sock));
SpiDrv::sendBuffer((uint8_t *)data, len, LAST_PARAM);
//Wait the reply elaboration
@ -145,7 +146,7 @@ bool ServerDrv::sendData(uint8_t sock, const uint8_t *data, uint16_t len)
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
if (!SpiDrv::waitResponse(SEND_DATA_TCP_CMD, &_data, &_dataLen))
if (!SpiDrv::waitResponseData8(SEND_DATA_TCP_CMD, &_data, &_dataLen))
{
WARN("error waitResponse");
}
@ -171,7 +172,7 @@ uint8_t ServerDrv::isDataSent(uint8_t sock)
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
if (!SpiDrv::waitResponse(DATA_SENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
if (!SpiDrv::waitResponseCmd(DATA_SENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
WARN("error waitResponse isDataSent");
}

View File

@ -33,6 +33,10 @@ void SpiDrv::begin()
digitalWrite(SS, HIGH);
digitalWrite(SLAVESELECT, HIGH);
#ifdef _DEBUG_
INIT_TRIGGER()
#endif
// Warning: if the SS pin ever becomes a LOW INPUT then SPI
// automatically switches to Slave, so the data direction of
// the SS pin MUST be kept as OUTPUT.
@ -75,6 +79,9 @@ int SpiDrv::waitSpiChar(unsigned char waitChar)
if (_readChar == WAIT_CMD)
{
delayMicroseconds(WAIT_CHAR_DELAY);
}else if (_readChar == ERR_CMD)
{
return -1;
}else
{
delayMicroseconds(TIMEOUT_CHAR_DELAY);
@ -164,7 +171,7 @@ void SpiDrv::waitForSlaveReady()
#endif
}
int SpiDrv::waitResponse(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len)
int SpiDrv::waitResponseCmd(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len)
{
char _data = 0;
int i =0, ii = 0;
@ -188,7 +195,7 @@ int SpiDrv::waitResponse(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t*
return 1;
}
/*
int SpiDrv::waitResponse(uint8_t cmd, uint8_t numParam, uint8_t* param, uint16_t* param_len)
{
char _data = 0;
@ -213,9 +220,9 @@ int SpiDrv::waitResponse(uint8_t cmd, uint8_t numParam, uint8_t* param, uint16_t
return 1;
}
*/
int SpiDrv::waitResponse(uint8_t cmd, uint8_t* param, uint16_t* param_len)
int SpiDrv::waitResponseData16(uint8_t cmd, uint8_t* param, uint16_t* param_len)
{
char _data = 0;
int i =0, ii = 0;
@ -241,7 +248,7 @@ int SpiDrv::waitResponse(uint8_t cmd, uint8_t* param, uint16_t* param_len)
return 1;
}
int SpiDrv::waitResponse(uint8_t cmd, uint8_t* param, uint8_t* param_len)
int SpiDrv::waitResponseData8(uint8_t cmd, uint8_t* param, uint8_t* param_len)
{
char _data = 0;
int i =0, ii = 0;
@ -267,7 +274,7 @@ int SpiDrv::waitResponse(uint8_t cmd, uint8_t* param, uint8_t* param_len)
return 1;
}
int SpiDrv::waitResponse(uint8_t cmd, uint8_t numParam, tParam* params)
int SpiDrv::waitResponseParams(uint8_t cmd, uint8_t numParam, tParam* params)
{
char _data = 0;
int i =0, ii = 0;
@ -308,6 +315,7 @@ int SpiDrv::waitResponse(uint8_t cmd, uint8_t numParam, tParam* params)
return 1;
}
/*
int SpiDrv::waitResponse(uint8_t cmd, tParam* params, uint8_t* numParamRead, uint8_t maxNumParams)
{
char _data = 0;
@ -346,6 +354,7 @@ int SpiDrv::waitResponse(uint8_t cmd, tParam* params, uint8_t* numParamRead, uin
}
return 1;
}
*/
int SpiDrv::waitResponse(uint8_t cmd, uint8_t* numParamRead, uint8_t** params, uint8_t maxNumParams)
{
@ -492,6 +501,9 @@ void SpiDrv::sendCmd(uint8_t cmd, uint8_t numParam)
// Send Spi START CMD
spiTransfer(START_CMD);
//wait the interrupt trigger on slave
delayMicroseconds(SPI_START_CMD_DELAY);
// Send Spi C + cmd
spiTransfer(cmd & ~(REPLY_FLAG));

View File

@ -7,7 +7,9 @@
#define WAIT_CHAR_DELAY 100
#define TIMEOUT_CHAR_DELAY 10
#define TIMEOUT_READY_SLAVE 1000
#define SPI_TX_DELAY 2
#define SPI_TX_DELAY 5
#define SPI_START_CMD_DELAY 10
#define NO_LAST_PARAM 0
#define LAST_PARAM 1
@ -16,7 +18,10 @@
#define WAIT_FOR_SLAVE_SELECT() \
SpiDrv::waitForSlaveReady(); \
SpiDrv::spiSlaveSelect();
SpiDrv::spiSlaveSelect(); \
delayMicroseconds(SPI_TX_DELAY);
class SpiDrv
{
@ -46,18 +51,18 @@ public:
static char readChar();
static int waitResponseParams(uint8_t cmd, uint8_t numParam, tParam* params);
static int waitResponseCmd(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len);
static int waitResponseData8(uint8_t cmd, uint8_t* param, uint8_t* param_len);
static int waitResponseData16(uint8_t cmd, uint8_t* param, uint16_t* param_len);
/*
static int waitResponse(uint8_t cmd, tParam* params, uint8_t* numParamRead, uint8_t maxNumParams);
static int waitResponse(uint8_t cmd, uint8_t numParam, tParam* params);
static int waitResponse(uint8_t cmd, uint8_t numParam, uint8_t* param, uint8_t* param_len);
static int waitResponse(uint8_t cmd, uint8_t numParam, uint8_t* param, uint16_t* param_len);
static int waitResponse(uint8_t cmd, uint8_t* param, uint8_t* param_len);
static int waitResponse(uint8_t cmd, uint8_t* param, uint16_t* param_len);
*/
static int waitResponse(uint8_t cmd, uint8_t* numParamRead, uint8_t** params, uint8_t maxNumParams);
static void sendParam(uint8_t* param, uint8_t param_len, uint8_t lastParam = NO_LAST_PARAM);

View File

@ -43,7 +43,7 @@ void WiFiDrv::getNetworkData(uint8_t *ip, uint8_t *mask, uint8_t *gwip)
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
SpiDrv::waitResponse(GET_IPADDR_CMD, PARAM_NUMS_3, params);
SpiDrv::waitResponseParams(GET_IPADDR_CMD, PARAM_NUMS_3, params);
SpiDrv::spiSlaveDeselect();
}
@ -70,7 +70,7 @@ uint8_t WiFiDrv::wifiSetNetwork(char* ssid, uint8_t ssid_len)
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
if (!SpiDrv::waitResponse(SET_NET_CMD, PARAM_NUMS_1, &_data, &_dataLen))
if (!SpiDrv::waitResponseCmd(SET_NET_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
WARN("error waitResponse");
}
@ -93,7 +93,7 @@ uint8_t WiFiDrv::wifiSetPassphrase(char* ssid, uint8_t ssid_len, const char *pas
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
if (!SpiDrv::waitResponse(SET_PASSPHRASE_CMD, PARAM_NUMS_1, &_data, &_dataLen))
if (!SpiDrv::waitResponseCmd(SET_PASSPHRASE_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
WARN("error waitResponse");
}
@ -117,7 +117,7 @@ uint8_t WiFiDrv::wifiSetKey(char* ssid, uint8_t ssid_len, uint8_t key_idx, const
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
if (!SpiDrv::waitResponse(SET_KEY_CMD, PARAM_NUMS_1, &_data, &_dataLen))
if (!SpiDrv::waitResponseCmd(SET_KEY_CMD, PARAM_NUMS_1, &_data, &_dataLen))
{
WARN("error waitResponse");
}
@ -140,7 +140,7 @@ uint8_t WiFiDrv::disconnect()
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
uint8_t result = SpiDrv::waitResponse(DISCONNECT_CMD, PARAM_NUMS_1, &_data, &_dataLen);
uint8_t result = SpiDrv::waitResponseCmd(DISCONNECT_CMD, PARAM_NUMS_1, &_data, &_dataLen);
SpiDrv::spiSlaveDeselect();
@ -160,7 +160,7 @@ uint8_t WiFiDrv::getConnectionStatus()
// Wait for reply
uint8_t _data = 0;
uint8_t _dataLen = 0;
SpiDrv::waitResponse(GET_CONN_STATUS_CMD, PARAM_NUMS_1, &_data, &_dataLen);
SpiDrv::waitResponseCmd(GET_CONN_STATUS_CMD, PARAM_NUMS_1, &_data, &_dataLen);
SpiDrv::spiSlaveDeselect();
@ -182,7 +182,7 @@ uint8_t* WiFiDrv::getMacAddress()
// Wait for reply
uint8_t _dataLen = 0;
uint8_t result = SpiDrv::waitResponse(GET_MACADDR_CMD, PARAM_NUMS_1, _mac, &_dataLen);
uint8_t result = SpiDrv::waitResponseCmd(GET_MACADDR_CMD, PARAM_NUMS_1, _mac, &_dataLen);
SpiDrv::spiSlaveDeselect();
@ -222,7 +222,7 @@ char* WiFiDrv::getCurrentSSID()
// Wait for reply
uint8_t _dataLen = 0;
uint8_t result = SpiDrv::waitResponse(GET_CURR_SSID_CMD, PARAM_NUMS_1, (uint8_t*)_ssid, &_dataLen);
uint8_t result = SpiDrv::waitResponseCmd(GET_CURR_SSID_CMD, PARAM_NUMS_1, (uint8_t*)_ssid, &_dataLen);
SpiDrv::spiSlaveDeselect();
@ -244,7 +244,7 @@ uint8_t* WiFiDrv::getCurrentBSSID()
// Wait for reply
uint8_t _dataLen = 0;
uint8_t result = SpiDrv::waitResponse(GET_CURR_BSSID_CMD, PARAM_NUMS_1, _bssid, &_dataLen);
uint8_t result = SpiDrv::waitResponseCmd(GET_CURR_BSSID_CMD, PARAM_NUMS_1, _bssid, &_dataLen);
SpiDrv::spiSlaveDeselect();
@ -267,7 +267,7 @@ int32_t WiFiDrv::getCurrentRSSI()
// Wait for reply
uint8_t _dataLen = 0;
int32_t rssi = 0;
uint8_t result = SpiDrv::waitResponse(GET_CURR_RSSI_CMD, PARAM_NUMS_1, (uint8_t*)&rssi, &_dataLen);
uint8_t result = SpiDrv::waitResponseCmd(GET_CURR_RSSI_CMD, PARAM_NUMS_1, (uint8_t*)&rssi, &_dataLen);
SpiDrv::spiSlaveDeselect();
@ -290,7 +290,7 @@ uint8_t WiFiDrv::getCurrentEncryptionType()
// Wait for reply
uint8_t dataLen = 0;
uint8_t encType = 0;
uint8_t result = SpiDrv::waitResponse(GET_CURR_ENCT_CMD, PARAM_NUMS_1, (uint8_t*)encType, &dataLen);
uint8_t result = SpiDrv::waitResponseCmd(GET_CURR_ENCT_CMD, PARAM_NUMS_1, (uint8_t*)encType, &dataLen);
SpiDrv::spiSlaveDeselect();

View File

@ -5,6 +5,7 @@
#define CMD_FLAG 0
#define REPLY_FLAG 1<<7
#define DATA_FLAG 0x40
#define WIFI_SPI_ACK 1
#define WIFI_SPI_ERR 0xFF
@ -17,6 +18,7 @@
#define START_CMD 0xE0
#define WAIT_CMD 0xE1
#define END_CMD 0xEE
#define ERR_CMD 0xEF
enum {
SET_NET_CMD = 0x10,
@ -31,17 +33,17 @@ enum {
GET_CURR_RSSI_CMD = 0x25,
GET_CURR_ENCT_CMD = 0x26,
SCAN_NETWORKS = 0x27,
START_SERVER_TCP_CMD= 0x28,
GET_STATE_TCP_CMD = 0x29,
DATA_SENT_TCP_CMD = 0x2A,
AVAIL_DATA_TCP_CMD = 0x2B,
GET_DATA_TCP_CMD = 0x2C,
DISCONNECT_CMD = 0x30,
// All command with DATA_FLAG 0x40 send a 16bit Len
START_SERVER_TCP_CMD = 0x40,
GET_STATE_TCP_CMD = 0x41,
GET_DATA_TCP_CMD = 0x42,
AVAIL_DATA_TCP_CMD = 0x43,
SEND_DATA_TCP_CMD = 0x44,
DATA_SENT_TCP_CMD = 0x45,
GET_DATABUF_TCP_CMD = 0x46,
GET_DATABUF_TCP_CMD = 0x45,
};
@ -79,6 +81,13 @@ typedef struct __attribute__((__packed__))
char* param;
}tParam;
typedef struct __attribute__((__packed__))
{
uint16_t dataLen;
char* data;
}tDataParam;
typedef struct __attribute__((__packed__))
{
unsigned char cmd;
@ -87,6 +96,14 @@ typedef struct __attribute__((__packed__))
tParam params[MAX_PARAMS];
}tSpiMsg;
typedef struct __attribute__((__packed__))
{
unsigned char cmd;
unsigned char tcmd;
unsigned char nParam;
tDataParam params[MAX_PARAMS];
}tSpiMsgData;
typedef struct __attribute__((__packed__))
{

View File

@ -22,6 +22,8 @@
#define WL_NETWORKS_LIST_MAXNUM 10
// Maxmium number of socket
#define MAX_SOCK_NUM 4
//Maximum number of attempts to establish wifi connection
#define WL_MAX_ATTEMPT_CONNECTION 5
typedef enum {
WL_IDLE_STATUS,