mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
WiFi libraries: Bugfix on TestReport 12.01.2012
This commit is contained in:
@ -30,6 +30,12 @@
|
||||
|
||||
#ifdef _DEBUG_
|
||||
|
||||
#define INFO(format, args...) do { \
|
||||
char buf[250]; \
|
||||
sprintf(buf, format, args); \
|
||||
Serial.println(buf); \
|
||||
} while(0);
|
||||
|
||||
#define INFO1(x) do { PRINT_FILE_LINE() Serial.print("-I-");\
|
||||
Serial.println(x); \
|
||||
}while (0);
|
||||
@ -39,11 +45,6 @@
|
||||
Serial.print(x,16);Serial.print(",");Serial.println(y,16); \
|
||||
}while (0);
|
||||
|
||||
#define INFO(format, args...) do { \
|
||||
char buf[250]; \
|
||||
sprintf(buf, format, args); \
|
||||
Serial.println(buf); \
|
||||
} while(0);
|
||||
|
||||
#else
|
||||
#define INFO1(x) do {} while(0);
|
||||
|
@ -12,7 +12,7 @@ extern "C" {
|
||||
|
||||
|
||||
// Start server TCP on port specified
|
||||
void ServerDrv::StartServer(uint16_t port, uint8_t sock)
|
||||
void ServerDrv::startServer(uint16_t port, uint8_t sock)
|
||||
{
|
||||
WAIT_FOR_SLAVE_SELECT();
|
||||
// Send Command
|
||||
@ -34,7 +34,7 @@ void ServerDrv::StartServer(uint16_t port, uint8_t sock)
|
||||
}
|
||||
|
||||
// Start server TCP on port specified
|
||||
void ServerDrv::StartClient(uint32_t ipAddress, uint16_t port, uint8_t sock)
|
||||
void ServerDrv::startClient(uint32_t ipAddress, uint16_t port, uint8_t sock)
|
||||
{
|
||||
WAIT_FOR_SLAVE_SELECT();
|
||||
// Send Command
|
||||
@ -56,7 +56,29 @@ void ServerDrv::StartClient(uint32_t ipAddress, uint16_t port, uint8_t sock)
|
||||
SpiDrv::spiSlaveDeselect();
|
||||
}
|
||||
|
||||
uint8_t ServerDrv::getState(uint8_t sock)
|
||||
// Start server TCP on port specified
|
||||
void ServerDrv::stopClient(uint8_t sock)
|
||||
{
|
||||
WAIT_FOR_SLAVE_SELECT();
|
||||
// Send Command
|
||||
SpiDrv::sendCmd(STOP_CLIENT_TCP_CMD, PARAM_NUMS_1);
|
||||
SpiDrv::sendParam(&sock, 1, LAST_PARAM);
|
||||
|
||||
//Wait the reply elaboration
|
||||
SpiDrv::waitForSlaveReady();
|
||||
|
||||
// Wait for reply
|
||||
uint8_t _data = 0;
|
||||
uint8_t _dataLen = 0;
|
||||
if (!SpiDrv::waitResponseCmd(STOP_CLIENT_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||
{
|
||||
WARN("error waitResponse");
|
||||
}
|
||||
SpiDrv::spiSlaveDeselect();
|
||||
}
|
||||
|
||||
|
||||
uint8_t ServerDrv::getServerState(uint8_t sock)
|
||||
{
|
||||
WAIT_FOR_SLAVE_SELECT();
|
||||
// Send Command
|
||||
@ -77,6 +99,26 @@ uint8_t ServerDrv::getState(uint8_t sock)
|
||||
return _data;
|
||||
}
|
||||
|
||||
uint8_t ServerDrv::getClientState(uint8_t sock)
|
||||
{
|
||||
WAIT_FOR_SLAVE_SELECT();
|
||||
// Send Command
|
||||
SpiDrv::sendCmd(GET_CLIENT_STATE_TCP_CMD, PARAM_NUMS_1);
|
||||
SpiDrv::sendParam(&sock, sizeof(sock), LAST_PARAM);
|
||||
|
||||
//Wait the reply elaboration
|
||||
SpiDrv::waitForSlaveReady();
|
||||
|
||||
// Wait for reply
|
||||
uint8_t _data = 0;
|
||||
uint8_t _dataLen = 0;
|
||||
if (!SpiDrv::waitResponseCmd(GET_CLIENT_STATE_TCP_CMD, PARAM_NUMS_1, &_data, &_dataLen))
|
||||
{
|
||||
WARN("error waitResponse");
|
||||
}
|
||||
SpiDrv::spiSlaveDeselect();
|
||||
return _data;
|
||||
}
|
||||
|
||||
uint8_t ServerDrv::availData(uint8_t sock)
|
||||
{
|
||||
|
@ -8,11 +8,15 @@ class ServerDrv
|
||||
{
|
||||
public:
|
||||
// Start server TCP on port specified
|
||||
static void StartServer(uint16_t port, uint8_t sock);
|
||||
static void startServer(uint16_t port, uint8_t sock);
|
||||
|
||||
static void StartClient(uint32_t ipAddress, uint16_t port, uint8_t sock);
|
||||
static void startClient(uint32_t ipAddress, uint16_t port, uint8_t sock);
|
||||
|
||||
static void stopClient(uint8_t sock);
|
||||
|
||||
static uint8_t getState(uint8_t sock);
|
||||
static uint8_t getServerState(uint8_t sock);
|
||||
|
||||
static uint8_t getClientState(uint8_t sock);
|
||||
|
||||
static bool getData(uint8_t sock, uint8_t *data);
|
||||
|
||||
|
@ -39,6 +39,8 @@ enum {
|
||||
AVAIL_DATA_TCP_CMD = 0x2B,
|
||||
GET_DATA_TCP_CMD = 0x2C,
|
||||
START_CLIENT_TCP_CMD= 0x2D,
|
||||
STOP_CLIENT_TCP_CMD = 0x2E,
|
||||
GET_CLIENT_STATE_TCP_CMD= 0x2F,
|
||||
|
||||
DISCONNECT_CMD = 0x30,
|
||||
// All command with DATA_FLAG 0x40 send a 16bit Len
|
||||
|
Reference in New Issue
Block a user