1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

Merge pull request #438 from Links2004/esp8266

update SDK to esp_iot_sdk_v1.1.2_15_06_16_p1
This commit is contained in:
Ivan Grokhotkov
2015-06-26 20:33:02 +03:00
40 changed files with 582 additions and 138 deletions

View File

@ -40,7 +40,9 @@ extern "C" void esp_schedule();
extern "C" void esp_yield();
ESP8266WiFiClass::ESP8266WiFiClass()
: _useApMode(false)
: _smartConfigStarted(false)
, _smartConfigDone(false)
, _useApMode(false)
, _useClientMode(false)
, _useStaticIp(false)
{
@ -121,7 +123,7 @@ uint8_t ESP8266WiFiClass::waitForConnectResult(){
}
// You will have to set the DNS-Server manually later since this will not enable DHCP
// You will have to set the DNS-Server manually later since this will not enable DHCP2
void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet)
{
struct ip_info info;
@ -358,12 +360,47 @@ void ESP8266WiFiClass::_scanDone(void* result, int status)
}
}
esp_schedule();
ESP8266WiFiClass::_scanStarted = false;
ESP8266WiFiClass::_scanComplete = true;
if(!ESP8266WiFiClass::_scanAsync) {
esp_schedule();
}
}
int8_t ESP8266WiFiClass::scanComplete() {
int8_t ESP8266WiFiClass::scanNetworks()
if(_scanStarted) {
return WIFI_SCAN_RUNNING;
}
if(_scanComplete) {
return ESP8266WiFiClass::_scanCount;
}
return WIFI_SCAN_FAILD;
}
void ESP8266WiFiClass::scanDelete()
{
if (ESP8266WiFiClass::_scanResult)
{
delete[] reinterpret_cast<bss_info*>(ESP8266WiFiClass::_scanResult);
ESP8266WiFiClass::_scanResult = 0;
ESP8266WiFiClass::_scanCount = 0;
}
_scanComplete = false;
}
int8_t ESP8266WiFiClass::scanNetworks(bool async)
{
if(ESP8266WiFiClass::_scanStarted) {
return WIFI_SCAN_RUNNING;
}
ESP8266WiFiClass::_scanAsync = async;
if(_useApMode) {
// turn on AP+STA mode
mode(WIFI_AP_STA);
@ -377,22 +414,29 @@ int8_t ESP8266WiFiClass::scanNetworks()
{
disconnect();
}
if (ESP8266WiFiClass::_scanResult)
{
delete[] reinterpret_cast<bss_info*>(ESP8266WiFiClass::_scanResult);
ESP8266WiFiClass::_scanResult = 0;
ESP8266WiFiClass::_scanCount = 0;
}
scanDelete();
struct scan_config config;
config.ssid = 0;
config.bssid = 0;
config.channel = 0;
config.show_hidden = 0;
wifi_station_scan(&config, reinterpret_cast<scan_done_cb_t>(&ESP8266WiFiClass::_scanDone));
esp_yield();
return ESP8266WiFiClass::_scanCount;
if(wifi_station_scan(&config, reinterpret_cast<scan_done_cb_t>(&ESP8266WiFiClass::_scanDone))) {
ESP8266WiFiClass::_scanComplete = false;
ESP8266WiFiClass::_scanStarted = true;
if(ESP8266WiFiClass::_scanAsync) {
delay(0); // time for the OS to trigger the scan
return WIFI_SCAN_RUNNING;
}
esp_yield();
return ESP8266WiFiClass::_scanCount;
} else {
return WIFI_SCAN_FAILD;
}
}
void * ESP8266WiFiClass::_getScanInfoByIndex(int i)
@ -645,6 +689,10 @@ void ESP8266WiFiClass::printDiag(Print& p)
}
bool ESP8266WiFiClass::_scanAsync = false;
bool ESP8266WiFiClass::_scanStarted = false;
bool ESP8266WiFiClass::_scanComplete = false;
size_t ESP8266WiFiClass::_scanCount = 0;
void* ESP8266WiFiClass::_scanResult = 0;

View File

@ -32,6 +32,9 @@ extern "C" {
#include "WiFiClient.h"
#include "WiFiServer.h"
#define WIFI_SCAN_RUNNING (-1)
#define WIFI_SCAN_FAILD (-2)
enum WiFiMode { WIFI_OFF = 0, WIFI_STA = 1, WIFI_AP = 2, WIFI_AP_STA = 3 };
class ESP8266WiFiClass
@ -189,12 +192,26 @@ public:
int32_t RSSI();
/*
* called to get the scan state in Async mode
*
* return -1 if scan not fin
* return -2 if scan not triggered
*/
int8_t scanComplete();
/*
* delete last scan result from RAM
*/
void scanDelete();
/*
* Start scan WiFi networks available
*
* return: Number of discovered networks
*/
int8_t scanNetworks();
int8_t scanNetworks(bool async = false);
/*
* Return the SSID discovered during the network scan.
@ -314,13 +331,17 @@ protected:
void * _getScanInfoByIndex(int i);
static void _smartConfigCallback(uint32_t status, void* result);
static void _eventCallback(void *event);
bool _smartConfigStarted = false;
bool _smartConfigDone = false;
bool _smartConfigStarted;
bool _smartConfigDone;
bool _useApMode;
bool _useClientMode;
bool _useStaticIp;
static bool _scanAsync;
static bool _scanStarted;
static bool _scanComplete;
static size_t _scanCount;
static void* _scanResult;

View File

@ -40,107 +40,119 @@ bool ESP8266WiFiMulti::addAP(const char* ssid, const char *passphrase) {
wl_status_t ESP8266WiFiMulti::run(void) {
int8_t scanResult;
wl_status_t status = WiFi.status();
if(status == WL_DISCONNECTED || status == WL_NO_SSID_AVAIL || status == WL_IDLE_STATUS || status == WL_CONNECT_FAILED) {
WifiAPlist_t bestNetwork { NULL, NULL };
int bestNetworkDb = INT_MIN;
uint8 bestBSSID[6];
int32_t bestChannel;
scanResult = WiFi.scanComplete();
if(scanResult == WIFI_SCAN_RUNNING) {
// scan is running
return WL_NO_SSID_AVAIL;
} else if(scanResult > 0) {
// scan done analyze
WifiAPlist_t bestNetwork { NULL, NULL };
int bestNetworkDb = INT_MIN;
uint8 bestBSSID[6];
int32_t bestChannel;
DEBUG_WIFI_MULTI("[WIFI] delete old wifi config...\n");
WiFi.disconnect();
DEBUG_WIFI_MULTI("[WIFI] scan done\n");
delay(0);
DEBUG_WIFI_MULTI("[WIFI] start scan\n");
// WiFi.scanNetworks will return the number of networks found
int8_t n = WiFi.scanNetworks();
if(scanResult <= 0) {
DEBUG_WIFI_MULTI("[WIFI] no networks found\n");
} else {
DEBUG_WIFI_MULTI("[WIFI] %d networks found\n", scanResult);
for(int8_t i = 0; i < scanResult; ++i) {
DEBUG_WIFI_MULTI("[WIFI] scan done\n");
delay(0);
String ssid_scan;
int32_t rssi_scan;
uint8_t sec_scan;
uint8_t* BSSID_scan;
int32_t chan_scan;
bool hidden_scan;
if(n <= 0) {
DEBUG_WIFI_MULTI("[WIFI] no networks found\n");
} else {
DEBUG_WIFI_MULTI("[WIFI] %d networks found\n", n);
for(int8_t i = 0; i < n; ++i) {
WiFi.getNetworkInfo(i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan, hidden_scan);
String ssid_scan;
int32_t rssi_scan;
uint8_t sec_scan;
uint8_t* BSSID_scan;
int32_t chan_scan;
bool hidden_scan;
bool known = false;
for(uint32_t x = 0; x < APlist.size(); x++) {
WifiAPlist_t entry = APlist[x];
WiFi.getNetworkInfo(i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan, hidden_scan);
bool known = false;
for(uint32_t x = 0; x < APlist.size(); x++) {
WifiAPlist_t entry = APlist[x];
if(ssid_scan == entry.ssid) { // SSID match
known = true;
if(rssi_scan > bestNetworkDb) { // best network
if(sec_scan == ENC_TYPE_NONE || entry.passphrase) { // check for passphrase if not open wlan
bestNetworkDb = rssi_scan;
bestChannel = chan_scan;
memcpy((void*) &bestNetwork, (void*) &entry, sizeof(bestNetwork));
memcpy((void*) &bestBSSID, (void*) BSSID_scan, sizeof(bestBSSID));
if(ssid_scan == entry.ssid) { // SSID match
known = true;
if(rssi_scan > bestNetworkDb) { // best network
if(sec_scan == ENC_TYPE_NONE || entry.passphrase) { // check for passphrase if not open wlan
bestNetworkDb = rssi_scan;
bestChannel = chan_scan;
memcpy((void*) &bestNetwork, (void*) &entry, sizeof(bestNetwork));
memcpy((void*) &bestBSSID, (void*) BSSID_scan, sizeof(bestBSSID));
}
}
break;
}
break;
}
}
if(known) {
DEBUG_WIFI_MULTI(" ---> ");
} else {
DEBUG_WIFI_MULTI(" ");
}
if(known) {
DEBUG_WIFI_MULTI(" ---> ");
} else {
DEBUG_WIFI_MULTI(" ");
}
DEBUG_WIFI_MULTI(" %d: [%d][%02X:%02X:%02X:%02X:%02X:%02X] %s (%d) %c\n", i, chan_scan, BSSID_scan[0], BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], ssid_scan.c_str(), rssi_scan, (sec_scan == ENC_TYPE_NONE) ? ' ' : '*');
delay(0);
DEBUG_WIFI_MULTI(" %d: [%d][%02X:%02X:%02X:%02X:%02X:%02X] %s (%d) %c\n", i, chan_scan, BSSID_scan[0], BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], ssid_scan.c_str(), rssi_scan, (sec_scan == ENC_TYPE_NONE) ? ' ' : '*');
delay(0);
}
}
}
DEBUG_WIFI_MULTI("\n\n");
delay(0);
// clean up ram
WiFi.scanDelete();
if(bestNetwork.ssid) {
DEBUG_WIFI_MULTI("[WIFI] Connecting BSSID: %02X:%02X:%02X:%02X:%02X:%02X SSID: %s Channal: %d (%d)\n", bestBSSID[0], bestBSSID[1], bestBSSID[2], bestBSSID[3], bestBSSID[4], bestBSSID[5], bestNetwork.ssid, bestChannel, bestNetworkDb);
DEBUG_WIFI_MULTI("\n\n");
delay(0);
WiFi.begin(bestNetwork.ssid, bestNetwork.passphrase, bestChannel, bestBSSID);
status = WiFi.status();
if(bestNetwork.ssid) {
DEBUG_WIFI_MULTI("[WIFI] Connecting BSSID: %02X:%02X:%02X:%02X:%02X:%02X SSID: %s Channal: %d (%d)\n", bestBSSID[0], bestBSSID[1], bestBSSID[2], bestBSSID[3], bestBSSID[4], bestBSSID[5], bestNetwork.ssid, bestChannel, bestNetworkDb);
// wait for connection or fail
while(status != WL_CONNECTED && status != WL_NO_SSID_AVAIL && status != WL_CONNECT_FAILED) {
delay(10);
WiFi.begin(bestNetwork.ssid, bestNetwork.passphrase, bestChannel, bestBSSID);
status = WiFi.status();
}
IPAddress ip;
uint8_t * mac;
switch(status) {
case WL_CONNECTED:
ip = WiFi.localIP();
mac = WiFi.BSSID();
DEBUG_WIFI_MULTI("[WIFI] Connecting done.\n");
DEBUG_WIFI_MULTI("[WIFI] SSID: %s\n", WiFi.SSID());
DEBUG_WIFI_MULTI("[WIFI] IP: %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
DEBUG_WIFI_MULTI("[WIFI] MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
DEBUG_WIFI_MULTI("[WIFI] Channel: %d\n", WiFi.channel());
break;
case WL_NO_SSID_AVAIL:
DEBUG_WIFI_MULTI("[WIFI] Connecting Faild AP not found.\n");
break;
case WL_CONNECT_FAILED:
DEBUG_WIFI_MULTI("[WIFI] Connecting Faild.\n");
break;
default:
DEBUG_WIFI_MULTI("[WIFI] Connecting Faild (%d).\n", status);
break;
// wait for connection or fail
while(status != WL_CONNECTED && status != WL_NO_SSID_AVAIL && status != WL_CONNECT_FAILED) {
delay(10);
status = WiFi.status();
}
IPAddress ip;
uint8_t * mac;
switch(status) {
case WL_CONNECTED:
ip = WiFi.localIP();
mac = WiFi.BSSID();
DEBUG_WIFI_MULTI("[WIFI] Connecting done.\n");
DEBUG_WIFI_MULTI("[WIFI] SSID: %s\n", WiFi.SSID());
DEBUG_WIFI_MULTI("[WIFI] IP: %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]);
DEBUG_WIFI_MULTI("[WIFI] MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
DEBUG_WIFI_MULTI("[WIFI] Channel: %d\n", WiFi.channel());
break;
case WL_NO_SSID_AVAIL:
DEBUG_WIFI_MULTI("[WIFI] Connecting Faild AP not found.\n");
break;
case WL_CONNECT_FAILED:
DEBUG_WIFI_MULTI("[WIFI] Connecting Faild.\n");
break;
default:
DEBUG_WIFI_MULTI("[WIFI] Connecting Faild (%d).\n", status);
break;
}
} else {
DEBUG_WIFI_MULTI("[WIFI] no matching wifi found!\n");
}
} else {
DEBUG_WIFI_MULTI("[WIFI] no matching wifi found!\n");
// start scan
DEBUG_WIFI_MULTI("[WIFI] delete old wifi config...\n");
WiFi.disconnect();
DEBUG_WIFI_MULTI("[WIFI] start scan\n");
// scan wifi async mode
WiFi.scanNetworks(true);
}
}
return status;

View File

@ -90,12 +90,15 @@ class ClientContext {
}
void unref() {
DEBUGV(":ur %d\r\n", _refcnt);
if(--_refcnt == 0) {
flush();
close();
if(_discard_cb) _discard_cb(_discard_cb_arg, this);
delete this;
if(this != 0) {
DEBUGV(":ur %d\r\n", _refcnt);
if(--_refcnt == 0) {
flush();
close();
if(_discard_cb)
_discard_cb(_discard_cb_arg, this);
delete this;
}
}
}

View File

@ -77,10 +77,11 @@ public:
void unref()
{
DEBUGV(":ur %d\r\n", _refcnt);
if (--_refcnt == 0)
{
delete this;
if(this != 0) {
DEBUGV(":ur %d\r\n", _refcnt);
if(--_refcnt == 0) {
delete this;
}
}
}

View File

@ -0,0 +1,8 @@
name=ESP8266httpUpdate
version=1.0
author=Markus Sattler
maintainer=Markus Sattler
sentence=Http Update for ESP8266
paragraph=
url=https://github.com/Links2004/Arduino/tree/esp8266/hardware/esp8266com/esp8266/libraries/ESP8266httpUpdate
architectures=ESP8266

View File

@ -0,0 +1,165 @@
/**
*
* @file ESP8266HTTPUpdate.cpp
* @date 21.06.2015
* @author Markus Sattler
*
* Copyright (c) 2015 Markus Sattler. All rights reserved.
* This file is part of the ESP8266 Http Updater.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include "ESP8266HTTPUpdate.h"
ESP8266HTTPUpdate::ESP8266HTTPUpdate(void) {
}
ESP8266HTTPUpdate::~ESP8266HTTPUpdate(void) {
}
t_httpUpdate_return ESP8266HTTPUpdate::update(const char * host, uint16_t port, const char * url, const char * current_version) {
t_httpUpdate_return ret = HTTP_UPDATE_FAILD;
WiFiClient tcp;
DEBUG_HTTP_UPDATE("[httpUpdate] connected to %s:%u %s .... ", host, port, url);
if(!tcp.connect(host, port)) {
DEBUG_HTTP_UPDATE("faild.\n");
return ret;
}
DEBUG_HTTP_UPDATE("ok.\n");
// set Timeout for readBytesUntil and readStringUntil
tcp.setTimeout(2000);
tcp.setNoDelay(true);
String req = "GET ";
req += url;
req += " HTTP/1.1\r\n"
"Host: ";
req += host;
req += "\r\n"
"Connection: close\r\n"
"User-Agent: ESP8266-http-Update\r\n"
"x-ESP8266-STA-MAC: ";
req += WiFi.macAddress();
req += "\r\n"
"x-ESP8266-AP-MAC: ";
req += WiFi.softAPmacAddress();
req += "\r\n"
"x-ESP8266-free-space: ";
req += ESP.getFreeSketchSpace();
req += "\r\n"
"x-ESP8266-sketch-size: ";
req += ESP.getSketchSize();
req += "\r\n"
"x-ESP8266-chip-size: ";
req += ESP.getFlashChipRealSize();
req += "\r\n"
"x-ESP8266-sdk-version: ";
req += ESP.getSdkVersion();
if(current_version[0] != 0x00) {
req += "\r\n"
"x-ESP8266-version: ";
req += current_version;
}
req += "\r\n"
"\r\n";
tcp.write(req.c_str(), req.length());
uint32_t code = 0;
size_t len = 0;
while(true) {
String headerLine = tcp.readStringUntil('\n');
headerLine.trim(); // remove \r
if(headerLine.length() > 0) {
DEBUG_HTTP_UPDATE("[httpUpdate][Header] RX: %s\n", headerLine.c_str());
if(headerLine.startsWith("HTTP/1.")) {
// 9 = lenght of "HTTP/1.x "
code = headerLine.substring(9, headerLine.indexOf(' ', 9)).toInt();
} else if(headerLine.startsWith("Content-Length: ")) {
// 16 = lenght of "Content-Length: "
len = headerLine.substring(16).toInt();
}
} else {
break;
}
}
DEBUG_HTTP_UPDATE("[httpUpdate] Header read fin.\n");
DEBUG_HTTP_UPDATE("[httpUpdate] Server header:\n");
DEBUG_HTTP_UPDATE("[httpUpdate] - code: %d\n", code);
DEBUG_HTTP_UPDATE("[httpUpdate] - len: %d\n", len);
DEBUG_HTTP_UPDATE("[httpUpdate] ESP8266 info:\n");
DEBUG_HTTP_UPDATE("[httpUpdate] - free Space: %d\n", ESP.getFreeSketchSpace());
DEBUG_HTTP_UPDATE("[httpUpdate] - current Sketch Size: %d\n", ESP.getSketchSize());
if(current_version[0] != 0x00) {
DEBUG_HTTP_UPDATE("[httpUpdate] - current version: %s\n", current_version);
}
switch(code) {
case 200: ///< OK (Start Update)
if(len > 0) {
if(len > ESP.getFreeSketchSpace()) {
ret = HTTP_UPDATE_FAILD;
DEBUG_HTTP_UPDATE("[httpUpdate] FreeSketchSpace to low (%d) needed: %d\n", ESP.getFreeSketchSpace(), len);
} else {
if(ESP.updateSketch(tcp, len)) {
// may never reached!
ret = HTTP_UPDATE_OK;
DEBUG_HTTP_UPDATE("[httpUpdate] Update ok\n");
} else {
ret = HTTP_UPDATE_FAILD;
DEBUG_HTTP_UPDATE("[httpUpdate] Update failed\n");
}
}
} else {
ret = HTTP_UPDATE_FAILD;
DEBUG_HTTP_UPDATE("[httpUpdate]Content-Length is 0?!\n");
}
break;
case 304:
///< Not Modified (No updates)
ret = HTTP_UPDATE_NO_UPDATES;
break;
case 403:
///< Forbidden
// todo handle login
default:
ret = HTTP_UPDATE_FAILD;
DEBUG_HTTP_UPDATE("[httpUpdate] Code is (%d)\n", code);
break;
}
return ret;
}
t_httpUpdate_return ESP8266HTTPUpdate::update(String host, uint16_t port, String url, String current_version) {
return update(host.c_str(), port, url.c_str(), current_version.c_str());
}
ESP8266HTTPUpdate ESPhttpUpdate;

View File

@ -0,0 +1,55 @@
/**
*
* @file ESP8266HTTPUpdate.h
* @date 21.06.2015
* @author Markus Sattler
*
* Copyright (c) 2015 Markus Sattler. All rights reserved.
* This file is part of the ESP8266 Http Updater.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef ESP8266HTTPUPDATE_H_
#define ESP8266HTTPUPDATE_H_
#include <Arduino.h>
#include <ESP8266WiFi.h>
#define DEBUG_HTTP_UPDATE(...) Serial1.printf( __VA_ARGS__ )
#ifndef DEBUG_HTTP_UPDATE
#define DEBUG_HTTP_UPDATE(...)
#endif
typedef enum {
HTTP_UPDATE_FAILD,
HTTP_UPDATE_NO_UPDATES,
HTTP_UPDATE_OK
} t_httpUpdate_return;
class ESP8266HTTPUpdate {
public:
ESP8266HTTPUpdate(void);
~ESP8266HTTPUpdate(void);
t_httpUpdate_return update(const char * host, uint16_t port, const char * url = "/", const char * current_version = "");
t_httpUpdate_return update(String host, uint16_t port, String url = "/", String current_version = "");
};
extern ESP8266HTTPUpdate ESPhttpUpdate;
#endif /* ESP8266HTTPUPDATE_H_ */

View File

@ -117,9 +117,13 @@ sample code bearing this copyright.
#include "OneWire.h"
OneWire::OneWire(uint8_t pin)
OneWire::OneWire(uint8_t pin, bool pullup)
{
pinMode(pin, INPUT_PULLUP);
if(pullup) {
pinMode(pin, INPUT_PULLUP);
} else {
pinMode(pin, INPUT);
}
bitmask = PIN_TO_BITMASK(pin);
baseReg = PIN_TO_BASEREG(pin);
#if ONEWIRE_SEARCH

View File

@ -135,7 +135,7 @@ class OneWire
#endif
public:
OneWire( uint8_t pin);
OneWire(uint8_t pin, bool pullup = true);
// Perform a 1-Wire reset cycle. Returns 1 if a device responds
// with a presence pulse. Returns 0 if there is no device or the

View File

@ -3,7 +3,7 @@
The SD library allows for reading from and writing to SD cards.
For more information about this library please visit us at
http://arduino.cc/en/Reference/SD
http://www.arduino.cc/en/Reference/SD
== License ==

View File

@ -1,9 +1,9 @@
name=SD
version=1.0.4
version=1.0.5
author=Arduino, SparkFun
maintainer=Arduino <info@arduino.cc>
sentence=Enables reading and writing on SD cards. For all Arduino boards.
paragraph=Once an SD memory card is connected to the SPI interfare of the Arduino board you are enabled to create files and read/write on them. You can also move through directories on the SD card.
category=Data Storage
url=http://arduino.cc/en/Reference/SD
url=http://www.arduino.cc/en/Reference/SD
architectures=*

View File

@ -93,18 +93,23 @@ public:
// write, etc). Returns a File object for interacting with the file.
// Note that currently only one file can be open at a time.
File open(const char *filename, uint8_t mode = FILE_READ);
File open(const String &filename, uint8_t mode = FILE_READ) { return open( filename.c_str(), mode ); }
// Methods to determine if the requested file path exists.
boolean exists(char *filepath);
boolean exists(const String &filepath) { return exists(filepath.c_str()); }
// Create the requested directory heirarchy--if intermediate directories
// do not exist they will be created.
boolean mkdir(char *filepath);
boolean mkdir(const String &filepath) { return mkdir(filepath.c_str()); }
// Delete the file.
boolean remove(char *filepath);
boolean remove(const String &filepath) { return remove(filepath.c_str()); }
boolean rmdir(char *filepath);
boolean rmdir(const String &filepath) { return rmdir(filepath.c_str()); }
uint8_t type(){ return card.type(); }
uint8_t fatType(){ return volume.fatType(); }