From ca1bbf2e9a1625c758cfef5c235c3f9463a72cbe Mon Sep 17 00:00:00 2001 From: probonopd Date: Mon, 20 Jul 2015 12:43:29 +0200 Subject: [PATCH] Example sketch to demonstrate how to use native ESP8266 SDK functionality --- .../esp8266/examples/NativeSdk/NativeSdk.ino | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 libraries/esp8266/examples/NativeSdk/NativeSdk.ino diff --git a/libraries/esp8266/examples/NativeSdk/NativeSdk.ino b/libraries/esp8266/examples/NativeSdk/NativeSdk.ino new file mode 100644 index 000000000..013d57072 --- /dev/null +++ b/libraries/esp8266/examples/NativeSdk/NativeSdk.ino @@ -0,0 +1,33 @@ + +/* + * NativeSdk by Simon Peter + * Access functionality from the ESP8266 SDK + * This example code is in the public domain + * + * This is for advanced users. + * Note that this makes your code dependent on the ESP8266, which is generally + * a bad idea. So you should try to use esp8266/Arduino functionality + * where possible instead, in order to abstract away the hardware dependency. + */ + +// Expose Expressif SDK functionality - wrapped in ifdef so that it still +// compiles on other platforms +#ifdef ESP8266 +extern "C" { +#include "user_interface.h" +} +#endif + +void setup() { + Serial.begin(115200); +} + +void loop() { + // Call Expressif SDK functionality - wrapped in ifdef so that it still + // compiles on other platforms +#ifdef ESP8266 + Serial.print("wifi_station_get_hostname: "); + Serial.println(wifi_station_get_hostname()); +#endif + delay(1000); +}