Improve support for espressif platform.

This commit is contained in:
Valeriy Koval
2015-05-21 17:03:53 +03:00
parent e15efa7e08
commit 9136fe9a8b
4 changed files with 49 additions and 25 deletions

View File

@ -1,29 +1,43 @@
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
const char* ssid = "*****";
const char* password = "*****";
const char* ssid = "******";
const char* password = "******";
MDNSResponder mdns;
ESP8266WebServer server(80);
const int led = 13;
void handle_root() {
void handleRoot() {
digitalWrite(led, 1);
server.send(200, "text/plain", "hello from esp8266!");
delay(100);
digitalWrite(led, 0);
}
void setup(void)
{
Serial.begin(115200);
void handleNotFound(){
digitalWrite(led, 1);
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?"GET":"POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
digitalWrite(led, 0);
}
void setup(void){
pinMode(led, OUTPUT);
digitalWrite(led, 0);
// Connect to WiFi network
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("");
@ -38,17 +52,22 @@ void setup(void)
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.on("/", handle_root);
if (mdns.begin("esp8266", WiFi.localIP())) {
Serial.println("MDNS responder started");
}
server.on("/", handleRoot);
server.on("/inline", [](){
server.send(200, "text/plain", "this works as well");
});
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
}
void loop(void)
{
void loop(void){
server.handleClient();
}

View File

@ -2,11 +2,11 @@
"esp01": {
"build": {
"core": "esp8266",
"extra_flags": "-DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266",
"extra_flags": "-DARDUINO_ESP8266_ESP01 -DARDUINO_ARCH_ESP8266 -DESP8266",
"f_cpu": "80000000L",
"ldscript": "esp8266.ld",
"ldscript": "esp8266.flash.512k.ld",
"mcu": "esp8266",
"variant": "esp01"
"variant": "generic"
},
"frameworks": ["arduino"],
"name": "Espressif ESP8266 board",

View File

@ -43,6 +43,8 @@ env.Replace(
"-Os", # optimize for size
"-mlongcalls",
"-mtext-section-literals",
"-falign-functions=4",
"-U__STRICT_ANSI__",
"-MMD" # output dependancy info
],
@ -70,12 +72,12 @@ env.Replace(
UPLOADER=join("$PIOPACKAGES_DIR", "tool-esptool", "esptool"),
UPLOADERFLAGS=[
"-vv",
"-cd", "none",
"-cd", "ck",
"-cb", "$UPLOAD_SPEED",
"-cp", "$UPLOAD_PORT",
"-ca", "0x00000",
"-cf", "${SOURCES[0]}",
"-ca", "0x40000",
"-ca", "0x10000",
"-cf", "${SOURCES[1]}"
],
UPLOADCMD='$UPLOADER $UPLOADERFLAGS'
@ -88,6 +90,9 @@ env.Append(
"$UPLOADER",
"-eo", "$SOURCES",
"-bo", "${TARGETS[0]}",
"-bm", "qio",
"-bf", "40",
"-bz", "512K",
"-bs", ".text",
"-bs", ".data",
"-bs", ".rodata",
@ -135,7 +140,7 @@ if "uploadlazy" in COMMAND_LINE_TARGETS:
else:
target_firm = env.ElfToBin(
[join("$BUILD_DIR", "firmware_00000"),
join("$BUILD_DIR", "firmware_40000")], target_elf)
join("$BUILD_DIR", "firmware_10000")], target_elf)
#

View File

@ -46,8 +46,8 @@ elif env.get("PLATFORM") == "espressif":
env.Prepend(
CPPPATH=[join("$PLATFORMFW_DIR", "sdk", "include")],
LIBPATH=[join("$PLATFORMFW_DIR", "sdk", "lib")],
LIBS=["hal", "phy", "net80211", "lwip",
"wpa", "main", "pp", "c", "gcc"]
LIBS=["smartconfig", "pp", "main", "wpa", "lwip",
"net80211", "phy", "hal", "gcc", "m"]
)
env.Replace(PLATFORMFW_DIR=PLATFORMFW_DIR)