Git Product home page Git Product logo

clpopescu-1999-02 / sming Goto Github PK

View Code? Open in Web Editor NEW

This project forked from slaff/sming

0.0 2.0 0.0 51.08 MB

Sming - Open Source framework for high efficiency native ESP8266 development

License: GNU Lesser General Public License v3.0

C++ 33.95% C 32.45% Objective-C 2.76% Processing 1.39% HTML 26.71% CSS 0.63% Perl 0.05% JavaScript 0.47% Python 0.02% Shell 0.27% Elixir 0.01% XSLT 0.04% Makefile 1.01% CMake 0.01% Assembly 0.20%

sming's Introduction

Sming

Sming - Open Source framework for high efficiency WiFi SoC ESP8266 native development with C++ language.

ESP8266 C++ development framework

Gitter (chat) Donate Download Build

"Tasty" branch

This branch contains all "tasty" features that are not merged into the official Sming develop branch. For the moment these include:

  • Be able to configure the address location of rBoot roms. Be able to use the factory-default reset rom.
  • Allow setting the wifi station configuration without persisting it in flash. ( PR 734 )
  • Better Heap Allocation. ( PR 696 )
  • SSL with the help of AXTLS-8266 ( PR 596)
  • MQTT callback on delivering a message with QoS 1 or 2. ( PR 617 )
  • Fix for loosing final bytes when using rBoot Over-The-Air. ( PR 769 )
  • Faster interrupts so that there is less flickering. ( PR 774 )
  • MQTT: Better memory usage and no limits for username, password and clientid. Merged
  • Fix for slow booting. Merged
  • rBoot Makefile switch to enable the switch temp functions. Merged
  • Debug support with the help of ESPGDBStub Merged
  • rBoot with support for temporary switching to a ROM. Merged

Summary

  • Fast & user friendly development
  • Work with GPIO in Arduino style
  • High effective in perfomance and memory usage (this is native firmware!)
  • Compatible with standard Arduino libraries - use any popular hardware in few lines of code
  • rBoot OTA firmware updating
  • Built-in file system: spiffs
  • Built-in powerfull network and wireless modules
  • Built-in JSON library: ArduinoJson
  • HTTP, AJAX, WebSockets support
  • MQTT protocol based on [libemqtt] (https://github.com/menudoproblema/libemqtt)
  • Networking based on LWIP stack
  • Simple and powerfull hardware API wrappers
  • Based on Espressif NONOS SDK. Tested with versions 1.4 and 1.5.

Latest Release

Getting started

Additional needed software

You can find more information about compilation and flashing process by reading esp8266.com forum discussion thread.

Examples

More information at Wiki Examples page.

Simple GPIO input/output

#define LED_PIN 2 // GPIO2
...
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, HIGH);

Connect to WiFi and start Serial communication

Serial.begin(9600);
Serial.println("Hello Sming! Let's do smart things.");

WifiStation.enable(true);
WifiStation.config("LOCAL-NETWORK", "123456789087"); // Put you SSID and Password here

Read DHT22 sensor

#include <Libraries/DHT/DHT.h> // This is just popular Arduino library!

#define WORK_PIN 0 // GPIO0
DHT dht(WORK_PIN, DHT22);

void init()
{
  dht.begin();

  float h = dht.readHumidity();
  float t = dht.readTemperature();
}

HTTP client

HttpClient thingSpeak;
...
thingSpeak.downloadString("http://api.thingspeak.com/update?key=XXXXXXX&field1=" + String(sensorValue), onDataSent);

void onDataSent(HttpClient& client, bool successful)
{
  if (successful)
    Serial.println("Successful!");
  else
    Serial.println("Failed");
}

OTA application update based on rBoot

void OtaUpdate() {
	
	uint8 slot;
	rboot_config bootconf;
	
	Serial.println("Updating...");
	
	// need a clean object, otherwise if run before and failed will not run again
	if (otaUpdater) delete otaUpdater;
	otaUpdater = new rBootHttpUpdate();
	
	// select rom slot to flash
	bootconf = rboot_get_config();
	slot = bootconf.current_rom;
	if (slot == 0) slot = 1; else slot = 0;

	// flash rom to position indicated in the rBoot config rom table
	otaUpdater->addItem(bootconf.roms[slot], ROM_0_URL);

	// and/or set a callback (called on failure or success without switching requested)
	otaUpdater->setCallback(OtaUpdate_CallBack);

	// start update
	otaUpdater->start();
}

Embedded HTTP WebServer

server.listen(80);
server.addPath("/", onIndex);
server.addPath("/hello", onHello);
server.setDefaultHandler(onFile);

Serial.println("=== WEB SERVER STARTED ===");
Serial.println(WifiStation.getIP());

...

void onIndex(HttpRequest &request, HttpResponse &response)
{
  TemplateFileStream *tmpl = new TemplateFileStream("index.html");
  auto &vars = tmpl->variables();
  vars["counter"] = String(counter);
  vars["IP"] = WifiStation.getIP().toString();
  vars["MAC"] = WifiStation.getMAC();
  response.sendTemplate(tmpl);
}

void onFile(HttpRequest &request, HttpResponse &response)
{
  String file = request.getPath();
  if (file[0] == '/')
    file = file.substring(1);
    
  response.setCache(86400, true);
  response.sendFile(file);
}

sming's People

Contributors

anakod avatar raburton avatar hreintke avatar automationd avatar adiea avatar alonewolfx2 avatar flexiti avatar avr39-ripe avatar tavalin avatar harry-boe avatar nik-sharky avatar patrickjahns avatar danielnilsson9 avatar zendes avatar piperpilot avatar dmarkey avatar johndoe8967 avatar festlv avatar dseliskar avatar hrsavla avatar aglitchman avatar crosofg avatar ashubhatt avatar qtonthat avatar informatic avatar gernoteger avatar cvgaviao avatar straga avatar dpwhittaker avatar ystrem avatar

Watchers

James Cloos avatar Con L Popescu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.