mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-17 22:23:10 +03:00
46
README.md
46
README.md
@ -8,7 +8,7 @@ This project brings support for ESP8266 chip to the Arduino environment. ESP8266
|
|||||||
| OS | Build status | Latest release | Alpha Version |
|
| OS | Build status | Latest release | Alpha Version |
|
||||||
| --- | ------------ | -------------- | --------------- |
|
| --- | ------------ | -------------- | --------------- |
|
||||||
| Linux | [](https://travis-ci.org/igrr/Arduino) | [arduino-1.6.1-linux64.tar.xz](../../releases/download/1.6.1-esp8266-1/arduino-1.6.1-linux64.tar.xz) | |
|
| Linux | [](https://travis-ci.org/igrr/Arduino) | [arduino-1.6.1-linux64.tar.xz](../../releases/download/1.6.1-esp8266-1/arduino-1.6.1-linux64.tar.xz) | |
|
||||||
| Windows | [](https://ci.appveyor.com/project/igrr/Arduino) | [arduino-1.6.1-p1-windows.zip](https://github.com/igrr/Arduino/releases/download/1.6.1-esp8266-1/arduino-1.6.1-p1-windows.zip) | [appveyor Build](https://ci.appveyor.com/project/igrr/Arduino/build/artifacts) |
|
| Windows | [](https://ci.appveyor.com/project/igrr/Arduino) | [arduino-1.6.1-p1-windows.zip](https://github.com/igrr/Arduino/releases/download/1.6.1-esp8266-1/arduino-1.6.1-p1-windows.zip) | [appveyor 64Bit Build](https://ci.appveyor.com/project/igrr/Arduino/build/artifacts) |
|
||||||
| OS X | | [arduino-1.6.1-macosx-java-latest-signed.zip](../../releases/download/1.6.1-esp8266-1/arduino-1.6.1-macosx-java-latest-signed.zip) | |
|
| OS X | | [arduino-1.6.1-macosx-java-latest-signed.zip](../../releases/download/1.6.1-esp8266-1/arduino-1.6.1-macosx-java-latest-signed.zip) | |
|
||||||
|
|
||||||
|
|
||||||
@ -181,8 +181,48 @@ Libraries that don't rely on low-level access to AVR registers should work well.
|
|||||||
|
|
||||||
#### Upload via serial port ####
|
#### Upload via serial port ####
|
||||||
Pick the correct serial port.
|
Pick the correct serial port.
|
||||||
You need to put ESP8266 into bootloader mode before uploading code (pull GPIO0 low and
|
You need to put ESP8266 into bootloader mode before uploading code.
|
||||||
toggle power).
|
|
||||||
|
#### Minimal hardware Setup for Bootloading and usage ####
|
||||||
|
|
||||||
|
ESPxx Hardware
|
||||||
|
|
||||||
|
| PIN | Resistor | Serial Adapter |
|
||||||
|
| ------------- | -------- | -------------- |
|
||||||
|
| VCC | | VCC (3.3V) |
|
||||||
|
| GND | | GND |
|
||||||
|
| TX or GPIO2* | | RX |
|
||||||
|
| RX | | TX |
|
||||||
|
| GPIO0 | PullUp | DTR |
|
||||||
|
| Reset* | | RTS |
|
||||||
|
| GPIO15* | PullDown | |
|
||||||
|
| CH_PD | PullUp | |
|
||||||
|
|
||||||
|
* Note
|
||||||
|
- GPIO15 is also named MTDO
|
||||||
|
- Reset is also named RSBT or REST (adding PullUp improves the stability of the Module)
|
||||||
|
- GPIO2 is alternative TX for the boot loader mode
|
||||||
|
|
||||||
|
ESP01 example:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
#### Minimal hardware Setup for Bootloading only ####
|
||||||
|
ESPxx Hardware
|
||||||
|
|
||||||
|
| PIN | Resistor | Serial Adapter |
|
||||||
|
| ------------- | -------- | -------------- |
|
||||||
|
| VCC | | VCC (3.3V) |
|
||||||
|
| GND | | GND |
|
||||||
|
| TX or GPIO2 | | RX |
|
||||||
|
| RX | | TX |
|
||||||
|
| GPIO0 | | GND |
|
||||||
|
| Reset | | RTS* |
|
||||||
|
| GPIO15 | PullDown | |
|
||||||
|
| CH_PD | PullUp | |
|
||||||
|
|
||||||
|
* Note
|
||||||
|
- if no RTS is used a manual power toggle is needed
|
||||||
|
|
||||||
### Issues and support ###
|
### Issues and support ###
|
||||||
|
|
||||||
|
1157
docs/rgisters_dump.txt
Normal file
1157
docs/rgisters_dump.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
|||||||
menu.UploadSpeed=Upload Speed
|
menu.UploadSpeed=Upload Speed
|
||||||
menu.CpuFrequency=CPU Frequency
|
menu.CpuFrequency=CPU Frequency
|
||||||
menu.FlashSize=Flash size
|
menu.FlashSize=Flash size
|
||||||
|
|
||||||
##############################################################
|
##############################################################
|
||||||
generic.name=Generic ESP8266 Module
|
generic.name=Generic ESP8266 Module
|
||||||
|
|
||||||
@ -56,6 +57,52 @@ generic.menu.FlashSize.2M.build.flash_size=2M
|
|||||||
generic.menu.FlashSize.4M=4M
|
generic.menu.FlashSize.4M=4M
|
||||||
generic.menu.FlashSize.4M.build.flash_size=4M
|
generic.menu.FlashSize.4M.build.flash_size=4M
|
||||||
|
|
||||||
|
##############################################################
|
||||||
|
modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV)
|
||||||
|
|
||||||
|
modwifi.upload.tool=esptool
|
||||||
|
modwifi.upload.speed=115200
|
||||||
|
modwifi.upload.resetmethod=ck
|
||||||
|
modwifi.upload.maximum_size=2097152
|
||||||
|
modwifi.upload.wait_for_upload_port=true
|
||||||
|
modwifi.serial.disableDTR=true
|
||||||
|
modwifi.serial.disableRTS=true
|
||||||
|
|
||||||
|
modwifi.build.mcu=esp8266
|
||||||
|
modwifi.build.f_cpu=80000000L
|
||||||
|
modwifi.build.board=MOD_WIFI_ESP8266
|
||||||
|
modwifi.build.core=esp8266
|
||||||
|
modwifi.build.variant=generic
|
||||||
|
# Winbond W25Q16 flash
|
||||||
|
modwifi.build.flash_mode=qio
|
||||||
|
modwifi.build.flash_size=2M
|
||||||
|
modwifi.build.flash_freq=40
|
||||||
|
|
||||||
|
modwifi.menu.CpuFrequency.80=80 MHz
|
||||||
|
modwifi.menu.CpuFrequency.80.build.f_cpu=80000000L
|
||||||
|
modwifi.menu.CpuFrequency.160=160 MHz
|
||||||
|
modwifi.menu.CpuFrequency.160.build.f_cpu=160000000L
|
||||||
|
|
||||||
|
modwifi.menu.UploadSpeed.115200=115200
|
||||||
|
modwifi.menu.UploadSpeed.115200.upload.speed=115200
|
||||||
|
modwifi.menu.UploadSpeed.9600=9600
|
||||||
|
modwifi.menu.UploadSpeed.9600.upload.speed=9600
|
||||||
|
modwifi.menu.UploadSpeed.57600=57600
|
||||||
|
modwifi.menu.UploadSpeed.57600.upload.speed=57600
|
||||||
|
modwifi.menu.UploadSpeed.256000.windows=256000
|
||||||
|
modwifi.menu.UploadSpeed.256000.upload.speed=256000
|
||||||
|
modwifi.menu.UploadSpeed.230400.linux=230400
|
||||||
|
modwifi.menu.UploadSpeed.230400.macosx=230400
|
||||||
|
modwifi.menu.UploadSpeed.230400.macosx=230400
|
||||||
|
modwifi.menu.UploadSpeed.230400.upload.speed=230400
|
||||||
|
modwifi.menu.UploadSpeed.460800.linux=460800
|
||||||
|
modwifi.menu.UploadSpeed.460800.macosx=460800
|
||||||
|
modwifi.menu.UploadSpeed.460800.upload.speed=460800
|
||||||
|
modwifi.menu.UploadSpeed.512000.windows=512000
|
||||||
|
modwifi.menu.UploadSpeed.512000.upload.speed=512000
|
||||||
|
modwifi.menu.UploadSpeed.921600=921600
|
||||||
|
modwifi.menu.UploadSpeed.921600.upload.speed=921600
|
||||||
|
|
||||||
##############################################################
|
##############################################################
|
||||||
nodemcu.name=NodeMCU (ESP8266 ESP-12 Module)
|
nodemcu.name=NodeMCU (ESP8266 ESP-12 Module)
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ static uint8_t esp8266_gpioToFn[16] = {0x34, 0x18, 0x38, 0x14, 0x3C, 0x40, 0x1C,
|
|||||||
#define T1I ESP8266_REG(0x60C) //Interrupt Status Register (1bit) write to clear
|
#define T1I ESP8266_REG(0x60C) //Interrupt Status Register (1bit) write to clear
|
||||||
//edge interrupt enable register
|
//edge interrupt enable register
|
||||||
#define TEIE ESP8266_DREG(0x04)
|
#define TEIE ESP8266_DREG(0x04)
|
||||||
#define TEIE1 0x02 //it for timer 1
|
#define TEIE1 0x02 //bit for timer 1
|
||||||
|
|
||||||
//Timer 2 Registers (32bit CountUp Timer)
|
//Timer 2 Registers (32bit CountUp Timer)
|
||||||
#define T2L ESP8266_REG(0x620) //Load Value (Starting Value of Counter)
|
#define T2L ESP8266_REG(0x620) //Load Value (Starting Value of Counter)
|
||||||
|
@ -0,0 +1,161 @@
|
|||||||
|
/*
|
||||||
|
SDWebServer - Example WebServer with SD Card backend for esp8266
|
||||||
|
|
||||||
|
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
|
||||||
|
This file is part of the ESP8266WebServer library for Arduino environment.
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
Have a FAT Formatted SD Card connected to the SPI port of the ESP8266
|
||||||
|
The web root is the SD Card root folder
|
||||||
|
File extensions with more than 3 charecters are not supported by the SD Library
|
||||||
|
File Names longer than 8 charecters will be truncated by the SD library, so keep filenames shorter
|
||||||
|
index.htm is the default index (works on subfolders as well)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <WiFiClient.h>
|
||||||
|
#include <ESP8266WebServer.h>
|
||||||
|
#include <ESP8266mDNS.h>
|
||||||
|
#include <SPI.h>
|
||||||
|
#include <SD.h>
|
||||||
|
|
||||||
|
//do not go larger than 1460 bytes as that is the maximum that could fit in a packet
|
||||||
|
#define WWW_BUF_SIZE 1460
|
||||||
|
|
||||||
|
const char* ssid = "**********";
|
||||||
|
const char* password = "**********";
|
||||||
|
const char* hostname = "esp8266sd";
|
||||||
|
|
||||||
|
MDNSResponder mdns;
|
||||||
|
ESP8266WebServer server(80);
|
||||||
|
|
||||||
|
static bool hasSD = false;
|
||||||
|
|
||||||
|
bool loadFromSdCard(String path){
|
||||||
|
String dataType = "text/plain";
|
||||||
|
//handle default index
|
||||||
|
if(path.endsWith("/")) path += "index.htm";
|
||||||
|
|
||||||
|
//set proper Content-Type for the most common extensions
|
||||||
|
if(path.endsWith(".src")) path = path.substring(0, path.lastIndexOf("."));
|
||||||
|
else if(path.endsWith(".htm")) dataType = "text/html";
|
||||||
|
else if(path.endsWith(".css")) dataType = "text/css";
|
||||||
|
else if(path.endsWith(".js")) dataType = "application/javascript";
|
||||||
|
else if(path.endsWith(".png")) dataType = "image/png";
|
||||||
|
else if(path.endsWith(".gif")) dataType = "image/gif";
|
||||||
|
else if(path.endsWith(".jpg")) dataType = "image/jpeg";
|
||||||
|
else if(path.endsWith(".ico")) dataType = "image/x-icon";
|
||||||
|
else if(path.endsWith(".xml")) dataType = "text/xml";
|
||||||
|
else if(path.endsWith(".pdf")) dataType = "application/pdf";
|
||||||
|
else if(path.endsWith(".zip")) dataType = "application/zip";
|
||||||
|
|
||||||
|
//Try to open the file
|
||||||
|
File dataFile = SD.open(path.c_str());
|
||||||
|
|
||||||
|
//if it's a folder, try to open the default index
|
||||||
|
if(dataFile && dataFile.isDirectory()){
|
||||||
|
path += "/index.htm";
|
||||||
|
dataType = "text/html";
|
||||||
|
dataFile = SD.open(path.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
//and finally if the file exists, stream the content to the client
|
||||||
|
if (dataFile) {
|
||||||
|
WiFiClient client = server.client();
|
||||||
|
//send the file headers
|
||||||
|
String head = "HTTP/1.1 200 OK\r\nContent-Type: ";
|
||||||
|
head += dataType;
|
||||||
|
head += "\r\nContent-Length: ";
|
||||||
|
head += dataFile.size();
|
||||||
|
head += "\r\n\r\n";
|
||||||
|
client.print(head);
|
||||||
|
|
||||||
|
//partition the data packets to fit in a TCP packet (1460 bytes MAX)
|
||||||
|
uint8_t obuf[WWW_BUF_SIZE];
|
||||||
|
while (dataFile.available() > WWW_BUF_SIZE){
|
||||||
|
dataFile.read(obuf, WWW_BUF_SIZE);
|
||||||
|
client.write(obuf, WWW_BUF_SIZE);
|
||||||
|
}
|
||||||
|
//stream the last data left (size is at most WWW_BUF_SIZE bytes)
|
||||||
|
uint16_t leftLen = dataFile.available();
|
||||||
|
dataFile.read(obuf, leftLen);
|
||||||
|
client.write(obuf, leftLen);
|
||||||
|
|
||||||
|
dataFile.close();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tryLoadFromSdCard(){
|
||||||
|
String message = "FileNotFound\n\n";
|
||||||
|
if(hasSD){
|
||||||
|
//try to load the URL from SD Card
|
||||||
|
if(loadFromSdCard(server.uri())) return;
|
||||||
|
} else {
|
||||||
|
message = "SDCARD Not Detected\n\n";
|
||||||
|
}
|
||||||
|
server.send(404, "text/plain", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup(void){
|
||||||
|
uint8_t i = 0;
|
||||||
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
//setup WiFi
|
||||||
|
WiFi.begin(ssid, password);
|
||||||
|
Serial.print("\nConnecting to ");
|
||||||
|
Serial.println(ssid);
|
||||||
|
|
||||||
|
//wait for WiFi to connect
|
||||||
|
while (WiFi.status() != WL_CONNECTED && i++ < 20) delay(500);
|
||||||
|
|
||||||
|
//check if we have connected?
|
||||||
|
if(i == 20){
|
||||||
|
Serial.print("Could not connect to");
|
||||||
|
Serial.println(ssid);
|
||||||
|
//stop execution and wait forever
|
||||||
|
while(1) delay(500);
|
||||||
|
}
|
||||||
|
Serial.print("Connected! IP address: ");
|
||||||
|
Serial.println(WiFi.localIP());
|
||||||
|
|
||||||
|
//start mDNS Server
|
||||||
|
if (mdns.begin(hostname, WiFi.localIP())) {
|
||||||
|
Serial.println("MDNS responder started");
|
||||||
|
Serial.print("You can now connect to http://");
|
||||||
|
Serial.print(hostname);
|
||||||
|
Serial.println(".local");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Attach handler
|
||||||
|
server.onNotFound(tryLoadFromSdCard);
|
||||||
|
|
||||||
|
//start server
|
||||||
|
server.begin();
|
||||||
|
Serial.println("HTTP server started");
|
||||||
|
|
||||||
|
//init SD Card
|
||||||
|
if (SD.begin(SS)){
|
||||||
|
Serial.println("SD Card initialized.");
|
||||||
|
hasSD = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(void){
|
||||||
|
mdns.update();
|
||||||
|
server.handleClient();
|
||||||
|
}
|
@ -169,6 +169,7 @@ class ClientContext {
|
|||||||
|
|
||||||
_size_sent = will_send;
|
_size_sent = will_send;
|
||||||
DEBUGV(":wr\r\n");
|
DEBUGV(":wr\r\n");
|
||||||
|
tcp_output( _pcb );
|
||||||
_send_waiting = true;
|
_send_waiting = true;
|
||||||
delay(5000); // max send timeout
|
delay(5000); // max send timeout
|
||||||
_send_waiting = false;
|
_send_waiting = false;
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
esp_iot_sdk_v1.0.1_15_05_04_p1
|
||||||
|
-------------------------------------------
|
||||||
|
Here is a patch for station+softAP issue that users may have, based on SDK_v1.0.1,
|
||||||
|
solved problem that connect to ESP8266 softAP may fail in station+softAP mode.
|
||||||
|
|
||||||
|
Sorry for the inconvenience.
|
||||||
|
|
||||||
esp_iot_sdk_v1.0.1_15_04_24 Release Note
|
esp_iot_sdk_v1.0.1_15_04_24 Release Note
|
||||||
-------------------------------------------
|
-------------------------------------------
|
||||||
|
|
||||||
|
@ -128,6 +128,7 @@ struct mdns_info {
|
|||||||
unsigned long ipAddr;
|
unsigned long ipAddr;
|
||||||
char *txt_data;
|
char *txt_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FunctionName : espconn_connect
|
* FunctionName : espconn_connect
|
||||||
* Description : The function given as the connect
|
* Description : The function given as the connect
|
||||||
@ -173,6 +174,19 @@ sint8 espconn_accept(struct espconn *espconn);
|
|||||||
|
|
||||||
sint8 espconn_create(struct espconn *espconn);
|
sint8 espconn_create(struct espconn *espconn);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : espconn_sent
|
||||||
|
* Description : sent data for client or server
|
||||||
|
* Parameters : espconn -- espconn to set for client or server
|
||||||
|
* psent -- data to send
|
||||||
|
* length -- length of data to send
|
||||||
|
* Returns : none
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
sint8 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length);
|
||||||
|
|
||||||
|
/***** Connetion Settings *******/
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FunctionName : espconn_tcp_get_max_con
|
* FunctionName : espconn_tcp_get_max_con
|
||||||
* Description : get the number of simulatenously active TCP connections
|
* Description : get the number of simulatenously active TCP connections
|
||||||
@ -204,7 +218,7 @@ sint8 espconn_tcp_get_max_con_allow(struct espconn *espconn);
|
|||||||
* FunctionName : espconn_tcp_set_max_con_allow
|
* FunctionName : espconn_tcp_set_max_con_allow
|
||||||
* Description : set the count of simulatenously active connections on the server
|
* Description : set the count of simulatenously active connections on the server
|
||||||
* Parameters : espconn -- espconn to set the count
|
* Parameters : espconn -- espconn to set the count
|
||||||
* num -- support the connection number
|
* num -- support the connection number
|
||||||
* Returns : result
|
* Returns : result
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
@ -214,7 +228,7 @@ sint8 espconn_tcp_set_max_con_allow(struct espconn *espconn, uint8 num);
|
|||||||
* FunctionName : espconn_regist_time
|
* FunctionName : espconn_regist_time
|
||||||
* Description : used to specify the time that should be called when don't recv data
|
* Description : used to specify the time that should be called when don't recv data
|
||||||
* Parameters : espconn -- the espconn used to the connection
|
* Parameters : espconn -- the espconn used to the connection
|
||||||
* interval -- the timer when don't recv data
|
* interval -- the timer when don't recv data
|
||||||
* Returns : none
|
* Returns : none
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
@ -234,12 +248,69 @@ sint8 espconn_get_connection_info(struct espconn *pespconn, remot_info **pcon_in
|
|||||||
* FunctionName : espconn_get_packet_info
|
* FunctionName : espconn_get_packet_info
|
||||||
* Description : get the packet info with host
|
* Description : get the packet info with host
|
||||||
* Parameters : espconn -- the espconn used to disconnect the connection
|
* Parameters : espconn -- the espconn used to disconnect the connection
|
||||||
* infoarg -- the packet info
|
* infoarg -- the packet info
|
||||||
* Returns : the errur code
|
* Returns : the errur code
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
sint8 espconn_get_packet_info(struct espconn *espconn, struct espconn_packet* infoarg);
|
sint8 espconn_get_packet_info(struct espconn *espconn, struct espconn_packet* infoarg);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : espconn_port
|
||||||
|
* Description : access port value for client so that we don't end up bouncing
|
||||||
|
* all connections at the same time .
|
||||||
|
* Parameters : none
|
||||||
|
* Returns : access port value
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
uint32 espconn_port(void);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : espconn_set_opt
|
||||||
|
* Description : access port value for client so that we don't end up bouncing
|
||||||
|
* all connections at the same time .
|
||||||
|
* Parameters : espconn -- the espconn used to set the connection
|
||||||
|
* opt -- the option to set
|
||||||
|
* Returns : access port value
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
sint8 espconn_set_opt(struct espconn *espconn, uint8 opt);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : espconn_clear_opt
|
||||||
|
* Description : clear the option for connections so that we don't end up bouncing
|
||||||
|
* all connections at the same time .
|
||||||
|
* Parameters : espconn -- the espconn used to set the connection
|
||||||
|
* opt -- the option for clear
|
||||||
|
* Returns : the result
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
sint8 espconn_clear_opt(struct espconn *espconn, uint8 opt);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : espconn_set_keepalive
|
||||||
|
* Description : access level value for connection so that we set the value for
|
||||||
|
* keep alive
|
||||||
|
* Parameters : espconn -- the espconn used to set the connection
|
||||||
|
* level -- the connection's level
|
||||||
|
* value -- the value of time(s)
|
||||||
|
* Returns : access port value
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
sint8 espconn_set_keepalive(struct espconn *espconn, uint8 level, void* optarg);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : espconn_get_keepalive
|
||||||
|
* Description : access level value for connection so that we get the value for
|
||||||
|
* keep alive
|
||||||
|
* Parameters : espconn -- the espconn used to get the connection
|
||||||
|
* level -- the connection's level
|
||||||
|
* Returns : access keep alive value
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
sint8 espconn_get_keepalive(struct espconn *espconn, uint8 level, void *optarg);
|
||||||
|
|
||||||
|
/***** CALLBACKS *******/
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FunctionName : espconn_regist_sentcb
|
* FunctionName : espconn_regist_sentcb
|
||||||
* Description : Used to specify the function that should be called when data
|
* Description : Used to specify the function that should be called when data
|
||||||
@ -253,9 +324,9 @@ sint8 espconn_get_packet_info(struct espconn *espconn, struct espconn_packet* in
|
|||||||
sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb);
|
sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_cb);
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FunctionName : espconn_regist_sentcb
|
* FunctionName : espconn_regist_write_finish
|
||||||
* Description : Used to specify the function that should be called when data
|
* Description : Used to specify the function that should be called when data
|
||||||
* has been successfully delivered to the remote host.
|
* has been successfully written to the send buffer
|
||||||
* Parameters : espconn -- espconn to set the sent callback
|
* Parameters : espconn -- espconn to set the sent callback
|
||||||
* sent_cb -- sent callback function to call for this espconn
|
* sent_cb -- sent callback function to call for this espconn
|
||||||
* when data is successfully sent
|
* when data is successfully sent
|
||||||
@ -264,17 +335,6 @@ sint8 espconn_regist_sentcb(struct espconn *espconn, espconn_sent_callback sent_
|
|||||||
|
|
||||||
sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn);
|
sint8 espconn_regist_write_finish(struct espconn *espconn, espconn_connect_callback write_finish_fn);
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* FunctionName : espconn_sent
|
|
||||||
* Description : sent data for client or server
|
|
||||||
* Parameters : espconn -- espconn to set for client or server
|
|
||||||
* psent -- data to send
|
|
||||||
* length -- length of data to send
|
|
||||||
* Returns : none
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
sint8 espconn_sent(struct espconn *espconn, uint8 *psent, uint16 length);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FunctionName : espconn_regist_connectcb
|
* FunctionName : espconn_regist_connectcb
|
||||||
* Description : used to specify the function that should be called when
|
* Description : used to specify the function that should be called when
|
||||||
@ -318,59 +378,7 @@ sint8 espconn_regist_reconcb(struct espconn *espconn, espconn_reconnect_callback
|
|||||||
|
|
||||||
sint8 espconn_regist_disconcb(struct espconn *espconn, espconn_connect_callback discon_cb);
|
sint8 espconn_regist_disconcb(struct espconn *espconn, espconn_connect_callback discon_cb);
|
||||||
|
|
||||||
/******************************************************************************
|
/***** DNS *******/
|
||||||
* FunctionName : espconn_port
|
|
||||||
* Description : access port value for client so that we don't end up bouncing
|
|
||||||
* all connections at the same time .
|
|
||||||
* Parameters : none
|
|
||||||
* Returns : access port value
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
uint32 espconn_port(void);
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* FunctionName : espconn_set_opt
|
|
||||||
* Description : access port value for client so that we don't end up bouncing
|
|
||||||
* all connections at the same time .
|
|
||||||
* Parameters : none
|
|
||||||
* Returns : access port value
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
sint8 espconn_set_opt(struct espconn *espconn, uint8 opt);
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* FunctionName : espconn_clear_opt
|
|
||||||
* Description : clear the option for connections so that we don't end up bouncing
|
|
||||||
* all connections at the same time .
|
|
||||||
* Parameters : espconn -- the espconn used to set the connection
|
|
||||||
* opt -- the option for clear
|
|
||||||
* Returns : the result
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
sint8 espconn_clear_opt(struct espconn *espconn, uint8 opt);
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* FunctionName : espconn_set_keepalive
|
|
||||||
* Description : access level value for connection so that we set the value for
|
|
||||||
* keep alive
|
|
||||||
* Parameters : espconn -- the espconn used to set the connection
|
|
||||||
* level -- the connection's level
|
|
||||||
* value -- the value of time(s)
|
|
||||||
* Returns : access port value
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
sint8 espconn_set_keepalive(struct espconn *espconn, uint8 level, void* optarg);
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* FunctionName : espconn_get_keepalive
|
|
||||||
* Description : access level value for connection so that we get the value for
|
|
||||||
* keep alive
|
|
||||||
* Parameters : espconn -- the espconn used to get the connection
|
|
||||||
* level -- the connection's level
|
|
||||||
* Returns : access keep alive value
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
sint8 espconn_get_keepalive(struct espconn *espconn, uint8 level, void *optarg);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* TypedefName : dns_found_callback
|
* TypedefName : dns_found_callback
|
||||||
@ -405,6 +413,8 @@ typedef void (*dns_found_callback)(const char *name, ip_addr_t *ipaddr, void *ca
|
|||||||
|
|
||||||
err_t espconn_gethostbyname(struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found);
|
err_t espconn_gethostbyname(struct espconn *pespconn, const char *hostname, ip_addr_t *addr, dns_found_callback found);
|
||||||
|
|
||||||
|
/***** SSL *******/
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FunctionName : espconn_encry_connect
|
* FunctionName : espconn_encry_connect
|
||||||
* Description : The function given as connection
|
* Description : The function given as connection
|
||||||
@ -427,7 +437,7 @@ sint8 espconn_secure_disconnect(struct espconn *espconn);
|
|||||||
* FunctionName : espconn_encry_sent
|
* FunctionName : espconn_encry_sent
|
||||||
* Description : sent data for client or server
|
* Description : sent data for client or server
|
||||||
* Parameters : espconn -- espconn to set for client or server
|
* Parameters : espconn -- espconn to set for client or server
|
||||||
* psent -- data to send
|
* psent -- data to send
|
||||||
* length -- length of data to send
|
* length -- length of data to send
|
||||||
* Returns : none
|
* Returns : none
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -438,8 +448,8 @@ sint8 espconn_secure_sent(struct espconn *espconn, uint8 *psent, uint16 length);
|
|||||||
* FunctionName : espconn_secure_set_size
|
* FunctionName : espconn_secure_set_size
|
||||||
* Description : set the buffer size for client or server
|
* Description : set the buffer size for client or server
|
||||||
* Parameters : level -- set for client or server
|
* Parameters : level -- set for client or server
|
||||||
* 1: client,2:server,3:client and server
|
* 1: client,2:server,3:client and server
|
||||||
* size -- buffer size
|
* size -- buffer size
|
||||||
* Returns : true or false
|
* Returns : true or false
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
@ -449,7 +459,7 @@ bool espconn_secure_set_size(uint8 level, uint16 size);
|
|||||||
* FunctionName : espconn_secure_get_size
|
* FunctionName : espconn_secure_get_size
|
||||||
* Description : get buffer size for client or server
|
* Description : get buffer size for client or server
|
||||||
* Parameters : level -- set for client or server
|
* Parameters : level -- set for client or server
|
||||||
* 1: client,2:server,3:client and server
|
* 1: client,2:server,3:client and server
|
||||||
* Returns : buffer size for client or server
|
* Returns : buffer size for client or server
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
@ -464,23 +474,7 @@ sint16 espconn_secure_get_size(uint8 level);
|
|||||||
|
|
||||||
sint8 espconn_secure_accept(struct espconn *espconn);
|
sint8 espconn_secure_accept(struct espconn *espconn);
|
||||||
|
|
||||||
/******************************************************************************
|
/***** TCP RX HOLD *******/
|
||||||
* FunctionName : espconn_igmp_join
|
|
||||||
* Description : join a multicast group
|
|
||||||
* Parameters : host_ip -- the ip address of udp server
|
|
||||||
* multicast_ip -- multicast ip given by user
|
|
||||||
* Returns : none
|
|
||||||
*******************************************************************************/
|
|
||||||
sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* FunctionName : espconn_igmp_leave
|
|
||||||
* Description : leave a multicast group
|
|
||||||
* Parameters : host_ip -- the ip address of udp server
|
|
||||||
* multicast_ip -- multicast ip given by user
|
|
||||||
* Returns : none
|
|
||||||
*******************************************************************************/
|
|
||||||
sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FunctionName : espconn_recv_hold
|
* FunctionName : espconn_recv_hold
|
||||||
@ -498,11 +492,33 @@ sint8 espconn_recv_hold(struct espconn *pespconn);
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
sint8 espconn_recv_unhold(struct espconn *pespconn);
|
sint8 espconn_recv_unhold(struct espconn *pespconn);
|
||||||
|
|
||||||
|
/***** IGMP *******/
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : espconn_igmp_join
|
||||||
|
* Description : join a multicast group
|
||||||
|
* Parameters : host_ip -- the ip address of udp server
|
||||||
|
* multicast_ip -- multicast ip given by user
|
||||||
|
* Returns : none
|
||||||
|
*******************************************************************************/
|
||||||
|
sint8 espconn_igmp_join(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* FunctionName : espconn_igmp_leave
|
||||||
|
* Description : leave a multicast group
|
||||||
|
* Parameters : host_ip -- the ip address of udp server
|
||||||
|
* multicast_ip -- multicast ip given by user
|
||||||
|
* Returns : none
|
||||||
|
*******************************************************************************/
|
||||||
|
sint8 espconn_igmp_leave(ip_addr_t *host_ip, ip_addr_t *multicast_ip);
|
||||||
|
|
||||||
|
/***** mDNS *******/
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* FunctionName : espconn_mdns_init
|
* FunctionName : espconn_mdns_init
|
||||||
* Description : register a device with mdns
|
* Description : register a device with mdns
|
||||||
* Parameters : ipAddr -- the ip address of device
|
* Parameters : ipAddr -- the ip address of device
|
||||||
* hostname -- the hostname of device
|
* hostname -- the hostname of device
|
||||||
* Returns : none
|
* Returns : none
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
70
hardware/tools/esp8266/sdk/include/json/json.h
Executable file
70
hardware/tools/esp8266/sdk/include/json/json.h
Executable file
@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2011-2012, Swedish Institute of Computer Science.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* This file is part of the Contiki operating system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* A few JSON defines used for parsing and generating JSON.
|
||||||
|
* \author
|
||||||
|
* Niclas Finne <nfi@sics.se>
|
||||||
|
* Joakim Eriksson <joakime@sics.se>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __JSON_H__
|
||||||
|
#define __JSON_H__
|
||||||
|
|
||||||
|
#define JSON_TYPE_ARRAY '['
|
||||||
|
#define JSON_TYPE_OBJECT '{'
|
||||||
|
#define JSON_TYPE_PAIR ':'
|
||||||
|
#define JSON_TYPE_PAIR_NAME 'N' /* for N:V pairs */
|
||||||
|
#define JSON_TYPE_STRING '"'
|
||||||
|
#define JSON_TYPE_INT 'I'
|
||||||
|
#define JSON_TYPE_NUMBER '0'
|
||||||
|
#define JSON_TYPE_ERROR 0
|
||||||
|
|
||||||
|
/* how should we handle null vs false - both can be 0? */
|
||||||
|
#define JSON_TYPE_NULL 'n'
|
||||||
|
#define JSON_TYPE_TRUE 't'
|
||||||
|
#define JSON_TYPE_FALSE 'f'
|
||||||
|
|
||||||
|
#define JSON_TYPE_CALLBACK 'C'
|
||||||
|
|
||||||
|
enum {
|
||||||
|
JSON_ERROR_OK,
|
||||||
|
JSON_ERROR_SYNTAX,
|
||||||
|
JSON_ERROR_UNEXPECTED_ARRAY,
|
||||||
|
JSON_ERROR_UNEXPECTED_END_OF_ARRAY,
|
||||||
|
JSON_ERROR_UNEXPECTED_OBJECT,
|
||||||
|
JSON_ERROR_UNEXPECTED_STRING
|
||||||
|
};
|
||||||
|
|
||||||
|
#define JSON_CONTENT_TYPE "application/json"
|
||||||
|
|
||||||
|
#endif /* __JSON_H__ */
|
94
hardware/tools/esp8266/sdk/include/json/jsonparse.h
Executable file
94
hardware/tools/esp8266/sdk/include/json/jsonparse.h
Executable file
@ -0,0 +1,94 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2011-2012, Swedish Institute of Computer Science.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* This file is part of the Contiki operating system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __JSONPARSE_H__
|
||||||
|
#define __JSONPARSE_H__
|
||||||
|
|
||||||
|
#include "c_types.h"
|
||||||
|
#include "json/json.h"
|
||||||
|
|
||||||
|
#ifdef JSONPARSE_CONF_MAX_DEPTH
|
||||||
|
#define JSONPARSE_MAX_DEPTH JSONPARSE_CONF_MAX_DEPTH
|
||||||
|
#else
|
||||||
|
#define JSONPARSE_MAX_DEPTH 10
|
||||||
|
#endif
|
||||||
|
|
||||||
|
struct jsonparse_state {
|
||||||
|
const char *json;
|
||||||
|
int pos;
|
||||||
|
int len;
|
||||||
|
int depth;
|
||||||
|
/* for handling atomic values */
|
||||||
|
int vstart;
|
||||||
|
int vlen;
|
||||||
|
char vtype;
|
||||||
|
char error;
|
||||||
|
char stack[JSONPARSE_MAX_DEPTH];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Initialize a JSON parser state.
|
||||||
|
* \param state A pointer to a JSON parser state
|
||||||
|
* \param json The string to parse as JSON
|
||||||
|
* \param len The length of the string to parse
|
||||||
|
*
|
||||||
|
* This function initializes a JSON parser state for
|
||||||
|
* parsing a string as JSON.
|
||||||
|
*/
|
||||||
|
void jsonparse_setup(struct jsonparse_state *state, const char *json,
|
||||||
|
int len);
|
||||||
|
|
||||||
|
/* move to next JSON element */
|
||||||
|
int jsonparse_next(struct jsonparse_state *state);
|
||||||
|
|
||||||
|
/* copy the current JSON value into the specified buffer */
|
||||||
|
int jsonparse_copy_value(struct jsonparse_state *state, char *buf,
|
||||||
|
int buf_size);
|
||||||
|
|
||||||
|
/* get the current JSON value parsed as an int */
|
||||||
|
int jsonparse_get_value_as_int(struct jsonparse_state *state);
|
||||||
|
|
||||||
|
/* get the current JSON value parsed as a long */
|
||||||
|
long jsonparse_get_value_as_long(struct jsonparse_state *state);
|
||||||
|
|
||||||
|
/* get the current JSON value parsed as a unsigned long */
|
||||||
|
unsigned long jsonparse_get_value_as_ulong(struct jsonparse_state *state);
|
||||||
|
|
||||||
|
/* get the length of the current JSON value */
|
||||||
|
int jsonparse_get_len(struct jsonparse_state *state);
|
||||||
|
|
||||||
|
/* get the type of the current JSON value */
|
||||||
|
int jsonparse_get_type(struct jsonparse_state *state);
|
||||||
|
|
||||||
|
/* compare the JSON value with the specified string */
|
||||||
|
int jsonparse_strcmp_value(struct jsonparse_state *state, const char *str);
|
||||||
|
|
||||||
|
#endif /* __JSONPARSE_H__ */
|
145
hardware/tools/esp8266/sdk/include/json/jsontree.h
Executable file
145
hardware/tools/esp8266/sdk/include/json/jsontree.h
Executable file
@ -0,0 +1,145 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2011-2012, Swedish Institute of Computer Science.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. Neither the name of the Institute nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this software
|
||||||
|
* without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||||
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||||
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||||
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||||
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||||
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
* SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* This file is part of the Contiki operating system.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file
|
||||||
|
* JSON output generation
|
||||||
|
* \author
|
||||||
|
* Niclas Finne <nfi@sics.se>
|
||||||
|
* Joakim Eriksson <joakime@sics.se>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __JSONTREE_H__
|
||||||
|
#define __JSONTREE_H__
|
||||||
|
|
||||||
|
#include "c_types.h"
|
||||||
|
#include "json/json.h"
|
||||||
|
|
||||||
|
#ifdef JSONTREE_CONF_MAX_DEPTH
|
||||||
|
#define JSONTREE_MAX_DEPTH JSONTREE_CONF_MAX_DEPTH
|
||||||
|
#else
|
||||||
|
#define JSONTREE_MAX_DEPTH 10
|
||||||
|
#endif /* JSONTREE_CONF_MAX_DEPTH */
|
||||||
|
|
||||||
|
struct jsontree_context {
|
||||||
|
struct jsontree_value *values[JSONTREE_MAX_DEPTH];
|
||||||
|
uint16_t index[JSONTREE_MAX_DEPTH];
|
||||||
|
int (* putchar)(int);
|
||||||
|
uint8_t depth;
|
||||||
|
uint8_t path;
|
||||||
|
int callback_state;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct jsontree_value {
|
||||||
|
uint8_t type;
|
||||||
|
/* followed by a value */
|
||||||
|
};
|
||||||
|
|
||||||
|
struct jsontree_string {
|
||||||
|
uint8_t type;
|
||||||
|
const char *value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct jsontree_int {
|
||||||
|
uint8_t type;
|
||||||
|
int value;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* NOTE: the jsontree_callback set will receive a jsonparse state */
|
||||||
|
struct jsonparse_state;
|
||||||
|
struct jsontree_callback {
|
||||||
|
uint8_t type;
|
||||||
|
int (* output)(struct jsontree_context *js_ctx);
|
||||||
|
int (* set)(struct jsontree_context *js_ctx, struct jsonparse_state *parser);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct jsontree_pair {
|
||||||
|
const char *name;
|
||||||
|
struct jsontree_value *value;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct jsontree_object {
|
||||||
|
uint8_t type;
|
||||||
|
uint8_t count;
|
||||||
|
struct jsontree_pair *pairs;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct jsontree_array {
|
||||||
|
uint8_t type;
|
||||||
|
uint8_t count;
|
||||||
|
struct jsontree_value **values;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define JSONTREE_STRING(text) {JSON_TYPE_STRING, (text)}
|
||||||
|
#define JSONTREE_PAIR(name, value) {(name), (struct jsontree_value *)(value)}
|
||||||
|
#define JSONTREE_CALLBACK(output, set) {JSON_TYPE_CALLBACK, (output), (set)}
|
||||||
|
|
||||||
|
#define JSONTREE_OBJECT(name, ...) \
|
||||||
|
static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \
|
||||||
|
static struct jsontree_object name = { \
|
||||||
|
JSON_TYPE_OBJECT, \
|
||||||
|
sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \
|
||||||
|
jsontree_pair_##name }
|
||||||
|
|
||||||
|
#define JSONTREE_PAIR_ARRAY(value) (struct jsontree_value *)(value)
|
||||||
|
#define JSONTREE_ARRAY(name, ...) \
|
||||||
|
static struct jsontree_value* jsontree_value_##name[] = {__VA_ARGS__}; \
|
||||||
|
static struct jsontree_array name = { \
|
||||||
|
JSON_TYPE_ARRAY, \
|
||||||
|
sizeof(jsontree_value_##name)/sizeof(struct jsontree_value*), \
|
||||||
|
jsontree_value_##name }
|
||||||
|
|
||||||
|
#define JSONTREE_OBJECT_EXT(name, ...) \
|
||||||
|
static struct jsontree_pair jsontree_pair_##name[] = {__VA_ARGS__}; \
|
||||||
|
struct jsontree_object name = { \
|
||||||
|
JSON_TYPE_OBJECT, \
|
||||||
|
sizeof(jsontree_pair_##name)/sizeof(struct jsontree_pair), \
|
||||||
|
jsontree_pair_##name }
|
||||||
|
|
||||||
|
void jsontree_setup(struct jsontree_context *js_ctx,
|
||||||
|
struct jsontree_value *root, int (* putchar)(int));
|
||||||
|
void jsontree_reset(struct jsontree_context *js_ctx);
|
||||||
|
|
||||||
|
const char *jsontree_path_name(const struct jsontree_context *js_ctx,
|
||||||
|
int depth);
|
||||||
|
|
||||||
|
void jsontree_write_int(const struct jsontree_context *js_ctx, int value);
|
||||||
|
void jsontree_write_int_array(const struct jsontree_context *js_ctx, const int *text, uint32 length);
|
||||||
|
|
||||||
|
void jsontree_write_atom(const struct jsontree_context *js_ctx,
|
||||||
|
const char *text);
|
||||||
|
void jsontree_write_string(const struct jsontree_context *js_ctx,
|
||||||
|
const char *text);
|
||||||
|
int jsontree_print_next(struct jsontree_context *js_ctx);
|
||||||
|
struct jsontree_value *jsontree_find_next(struct jsontree_context *js_ctx,
|
||||||
|
int type);
|
||||||
|
|
||||||
|
#endif /* __JSONTREE_H__ */
|
60
hardware/tools/esp8266/sdk/include/sntp.h
Executable file
60
hardware/tools/esp8266/sdk/include/sntp.h
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
#ifndef __SNTP_H__
|
||||||
|
#define __SNTP_H__
|
||||||
|
|
||||||
|
#include "os_type.h"
|
||||||
|
#ifdef LWIP_OPEN_SRC
|
||||||
|
#include "lwip/ip_addr.h"
|
||||||
|
#else
|
||||||
|
#include "ip_addr.h"
|
||||||
|
#endif
|
||||||
|
/**
|
||||||
|
* get the seconds since Jan 01, 1970, 00:00 (GMT)
|
||||||
|
*/
|
||||||
|
uint32 sntp_get_current_timestamp();
|
||||||
|
/**
|
||||||
|
* get real time (GTM + 8 time zone)
|
||||||
|
*/
|
||||||
|
char* sntp_get_real_time(long t);
|
||||||
|
/**
|
||||||
|
* Initialize this module.
|
||||||
|
* Send out request instantly or after SNTP_STARTUP_DELAY(_FUNC).
|
||||||
|
*/
|
||||||
|
void sntp_init(void);
|
||||||
|
/**
|
||||||
|
* Stop this module.
|
||||||
|
*/
|
||||||
|
void sntp_stop(void);
|
||||||
|
/**
|
||||||
|
* Initialize one of the NTP servers by IP address
|
||||||
|
*
|
||||||
|
* @param numdns the index of the NTP server to set must be < SNTP_MAX_SERVERS
|
||||||
|
* @param dnsserver IP address of the NTP server to set
|
||||||
|
*/
|
||||||
|
void sntp_setserver(unsigned char idx, ip_addr_t *addr);
|
||||||
|
/**
|
||||||
|
* Obtain one of the currently configured by IP address (or DHCP) NTP servers
|
||||||
|
*
|
||||||
|
* @param numdns the index of the NTP server
|
||||||
|
* @return IP address of the indexed NTP server or "ip_addr_any" if the NTP
|
||||||
|
* server has not been configured by address (or at all).
|
||||||
|
*/
|
||||||
|
ip_addr_t sntp_getserver(unsigned char idx);
|
||||||
|
/**
|
||||||
|
* Initialize one of the NTP servers by name
|
||||||
|
*
|
||||||
|
* @param numdns the index of the NTP server to set must be < SNTP_MAX_SERVERS,now sdk support SNTP_MAX_SERVERS = 3
|
||||||
|
* @param dnsserver DNS name of the NTP server to set, to be resolved at contact time
|
||||||
|
*/
|
||||||
|
void sntp_setservername(unsigned char idx, char *server);
|
||||||
|
/**
|
||||||
|
* Obtain one of the currently configured by name NTP servers.
|
||||||
|
*
|
||||||
|
* @param numdns the index of the NTP server
|
||||||
|
* @return IP address of the indexed NTP server or NULL if the NTP
|
||||||
|
* server has not been configured by name (or at all)
|
||||||
|
*/
|
||||||
|
char *sntp_getservername(unsigned char idx);
|
||||||
|
|
||||||
|
#define sntp_servermode_dhcp(x)
|
||||||
|
|
||||||
|
#endif
|
51
hardware/tools/esp8266/sdk/include/upgrade.h
Executable file
51
hardware/tools/esp8266/sdk/include/upgrade.h
Executable file
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef __UPGRADE_H__
|
||||||
|
#define __UPGRADE_H__
|
||||||
|
|
||||||
|
#define SPI_FLASH_SEC_SIZE 4096
|
||||||
|
|
||||||
|
#define USER_BIN1 0x00
|
||||||
|
#define USER_BIN2 0x01
|
||||||
|
|
||||||
|
#define UPGRADE_FLAG_IDLE 0x00
|
||||||
|
#define UPGRADE_FLAG_START 0x01
|
||||||
|
#define UPGRADE_FLAG_FINISH 0x02
|
||||||
|
|
||||||
|
#define UPGRADE_FW_BIN1 0x00
|
||||||
|
#define UPGRADE_FW_BIN2 0x01
|
||||||
|
|
||||||
|
typedef void (*upgrade_states_check_callback)(void * arg);
|
||||||
|
|
||||||
|
//#define UPGRADE_SSL_ENABLE
|
||||||
|
|
||||||
|
struct upgrade_server_info {
|
||||||
|
uint8 ip[4];
|
||||||
|
uint16 port;
|
||||||
|
|
||||||
|
uint8 upgrade_flag;
|
||||||
|
|
||||||
|
uint8 pre_version[16];
|
||||||
|
uint8 upgrade_version[16];
|
||||||
|
|
||||||
|
uint32 check_times;
|
||||||
|
uint8 *url;
|
||||||
|
|
||||||
|
upgrade_states_check_callback check_cb;
|
||||||
|
struct espconn *pespconn;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define UPGRADE_FLAG_IDLE 0x00
|
||||||
|
#define UPGRADE_FLAG_START 0x01
|
||||||
|
#define UPGRADE_FLAG_FINISH 0x02
|
||||||
|
|
||||||
|
//bool system_upgrade_start(struct upgrade_server_info *server);
|
||||||
|
bool system_upgrade_start_ssl(struct upgrade_server_info *server);
|
||||||
|
void system_upgrade_init();
|
||||||
|
void system_upgrade_deinit();
|
||||||
|
bool system_upgrade(uint8 *data, uint16 len);
|
||||||
|
|
||||||
|
#ifdef UPGRADE_SSL_ENABLE
|
||||||
|
bool system_upgrade_start_ssl(struct upgrade_server_info *server);
|
||||||
|
#else
|
||||||
|
bool system_upgrade_start(struct upgrade_server_info *server);
|
||||||
|
#endif
|
||||||
|
#endif
|
BIN
hardware/tools/esp8266/sdk/lib/libjson.a
Executable file
BIN
hardware/tools/esp8266/sdk/lib/libjson.a
Executable file
Binary file not shown.
Binary file not shown.
BIN
hardware/tools/esp8266/sdk/lib/libssc.a
Executable file
BIN
hardware/tools/esp8266/sdk/lib/libssc.a
Executable file
Binary file not shown.
BIN
hardware/tools/esp8266/sdk/lib/libupgrade.a
Executable file
BIN
hardware/tools/esp8266/sdk/lib/libupgrade.a
Executable file
Binary file not shown.
@ -1 +1 @@
|
|||||||
1.0.1_15_04_24
|
1.0.1_15_05_04_p1
|
Reference in New Issue
Block a user