mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
add more NULL prt checks in strtok_r
Conflicts: libraries/SD/src/SD.cpp libraries/SD/src/SD.h
This commit is contained in:
@ -75,6 +75,11 @@ void WiFiServer::begin()
|
||||
|
||||
extern "C" uint32_t esp_micros_at_task_start();
|
||||
|
||||
bool WiFiServer::hasClient(){
|
||||
if (_unclaimed) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
WiFiClient WiFiServer::available(byte* status)
|
||||
{
|
||||
static uint32_t lastPollTime = 0;
|
||||
|
@ -44,6 +44,7 @@ private:
|
||||
public:
|
||||
WiFiServer(uint16_t port);
|
||||
WiFiClient available(uint8_t* status = NULL);
|
||||
bool hasClient();
|
||||
void begin();
|
||||
virtual size_t write(uint8_t);
|
||||
virtual size_t write(const uint8_t *buf, size_t size);
|
||||
|
@ -39,7 +39,39 @@ class ClientContext {
|
||||
tcp_sent(pcb, &_s_sent);
|
||||
tcp_err(pcb, &_s_error);
|
||||
}
|
||||
|
||||
|
||||
err_t abort(){
|
||||
if(_pcb) {
|
||||
DEBUGV(":abort\r\n");
|
||||
tcp_arg(_pcb, NULL);
|
||||
tcp_sent(_pcb, NULL);
|
||||
tcp_recv(_pcb, NULL);
|
||||
tcp_err(_pcb, NULL);
|
||||
tcp_abort(_pcb);
|
||||
_pcb = 0;
|
||||
}
|
||||
return ERR_ABRT;
|
||||
}
|
||||
|
||||
err_t close(){
|
||||
err_t err = ERR_OK;
|
||||
if(_pcb) {
|
||||
DEBUGV(":close\r\n");
|
||||
tcp_arg(_pcb, NULL);
|
||||
tcp_sent(_pcb, NULL);
|
||||
tcp_recv(_pcb, NULL);
|
||||
tcp_err(_pcb, NULL);
|
||||
err = tcp_close(_pcb);
|
||||
if(err != ERR_OK) {
|
||||
DEBUGV(":tc err %d\r\n", err);
|
||||
tcp_abort(_pcb);
|
||||
err = ERR_ABRT;
|
||||
}
|
||||
_pcb = 0;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
~ClientContext() {
|
||||
}
|
||||
|
||||
@ -58,22 +90,11 @@ class ClientContext {
|
||||
}
|
||||
|
||||
void unref() {
|
||||
err_t err;
|
||||
DEBUGV(":ur %d\r\n", _refcnt);
|
||||
if(--_refcnt == 0) {
|
||||
flush();
|
||||
if(_pcb) {
|
||||
tcp_arg(_pcb, NULL);
|
||||
tcp_sent(_pcb, NULL);
|
||||
tcp_recv(_pcb, NULL);
|
||||
tcp_err(_pcb, NULL);
|
||||
err = tcp_close(_pcb);
|
||||
if(err != ERR_OK) {
|
||||
DEBUGV(":tc err %d\r\n", err);
|
||||
tcp_abort(_pcb);
|
||||
}
|
||||
_pcb = 0;
|
||||
}
|
||||
close();
|
||||
if(_discard_cb) _discard_cb(_discard_cb_arg, this);
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
@ -179,6 +200,13 @@ class ClientContext {
|
||||
|
||||
private:
|
||||
|
||||
err_t _sent(tcp_pcb* pcb, uint16_t len) {
|
||||
DEBUGV(":sent %d\r\n", len);
|
||||
_size_sent -= len;
|
||||
if(_size_sent == 0 && _send_waiting) esp_schedule();
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void _consume(size_t size) {
|
||||
ptrdiff_t left = _rx_buf->len - _rx_buf_offset - size;
|
||||
if(left > 0) {
|
||||
@ -204,21 +232,8 @@ class ClientContext {
|
||||
|
||||
if(pb == 0) // connection closed
|
||||
{
|
||||
DEBUGV(":rcl\r\n");
|
||||
tcp_arg(pcb, NULL);
|
||||
tcp_sent(pcb, NULL);
|
||||
tcp_recv(pcb, NULL);
|
||||
tcp_err(pcb, NULL);
|
||||
// int error = tcp_close(pcb);
|
||||
// if (error != ERR_OK)
|
||||
{
|
||||
DEBUGV(":rcla\r\n");
|
||||
tcp_abort(pcb);
|
||||
_pcb = 0;
|
||||
return ERR_ABRT;
|
||||
}
|
||||
_pcb = 0;
|
||||
return ERR_OK;
|
||||
DEBUGV(":rcla\r\n");
|
||||
return abort();
|
||||
}
|
||||
|
||||
if(_rx_buf) {
|
||||
@ -231,27 +246,12 @@ class ClientContext {
|
||||
_rx_buf = pb;
|
||||
_rx_buf_offset = 0;
|
||||
}
|
||||
// tcp_recved(pcb, received);
|
||||
// pbuf_free(pb);
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
void _error(err_t err) {
|
||||
DEBUGV(":er %d\r\n", err);
|
||||
|
||||
if(_pcb) {
|
||||
tcp_arg(_pcb, NULL);
|
||||
tcp_sent(_pcb, NULL);
|
||||
tcp_recv(_pcb, NULL);
|
||||
tcp_err(_pcb, NULL);
|
||||
err = tcp_close(_pcb);
|
||||
if(err != ERR_OK) {
|
||||
DEBUGV(":tc err %d\r\n", err);
|
||||
tcp_abort(_pcb);
|
||||
}
|
||||
}
|
||||
_pcb = 0;
|
||||
|
||||
close();
|
||||
if(_size_sent && _send_waiting) {
|
||||
esp_schedule();
|
||||
}
|
||||
@ -261,13 +261,6 @@ class ClientContext {
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
err_t _sent(tcp_pcb* pcb, uint16_t len) {
|
||||
DEBUGV(":sent %d\r\n", len);
|
||||
_size_sent -= len;
|
||||
if(_size_sent == 0 && _send_waiting) esp_schedule();
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
static err_t _s_recv(void *arg, struct tcp_pcb *tpcb, struct pbuf *pb, err_t err) {
|
||||
return reinterpret_cast<ClientContext*>(arg)->_recv(tpcb, pb, err);
|
||||
}
|
||||
|
@ -326,7 +326,13 @@ boolean callback_rmdir(SdFile& parentDir, char *filePathComponent,
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean SDClass::begin(uint8_t csPin, uint32_t sckRateID) {
|
||||
|
||||
|
||||
/* Implementation of class used to create `SDCard` object. */
|
||||
|
||||
|
||||
|
||||
boolean SDClass::begin(uint8_t csPin, uint32_t speed) {
|
||||
/*
|
||||
|
||||
Performs the initialisation required by the sdfatlib library.
|
||||
@ -334,7 +340,7 @@ boolean SDClass::begin(uint8_t csPin, uint32_t sckRateID) {
|
||||
Return true if initialization succeeds, false otherwise.
|
||||
|
||||
*/
|
||||
return card.init(sckRateID, csPin) &&
|
||||
return card.init(speed, csPin) &&
|
||||
volume.init(card) &&
|
||||
root.openRoot(volume);
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ private:
|
||||
public:
|
||||
// This needs to be called to set up the connection to the SD card
|
||||
// before other methods are used.
|
||||
boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN, uint32_t sckRateID = SPI_FULL_SPEED);
|
||||
boolean begin(uint8_t csPin = SD_CHIP_SELECT_PIN, uint32_t speed = SPI_HALF_SPEED);
|
||||
|
||||
// Open the specified file/directory with the supplied mode (e.g. read or
|
||||
// write, etc). Returns a File object for interacting with the file.
|
||||
|
Reference in New Issue
Block a user