Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sming Host Emulator #1692

Merged
merged 19 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .appveyor/build.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
REM Appveyor Windows build script

SET SMING_HOME=%APPVEYOR_BUILD_FOLDER%\Sming
SET ESP_HOME=c:\Espressif
SET PATH=%PATH%;%ESP_HOME%/utils
cd %SMING_HOME%
gcc -v

make help
make list-config

REM Compile the tools first
make tools V=1 || goto :error

IF "%SDK_VERSION%" == "2.0.0" (
REM Build Host Emulator and run basic tests
set SMING_ARCH=Host
cd %SMING_HOME%
make STRICT=1 || goto :error
make Basic_Serial || goto :error
make Basic_ProgMem || goto :error
cd %SMING_HOME%\..\samples\HostTests
make flash || goto :error
)

REM Build library and test sample apps
set SMING_ARCH=Esp8266
cd %SMING_HOME%
make STRICT=1 || goto :error
cd %SMING_HOME%\..\samples\Basic_Blink
make V=1 || goto :error
cd %SMING_HOME%\..\samples\Basic_Ssl
make || goto :error
cd %SMING_HOME%\..\samples\Basic_SmartConfig
make || goto :error

goto :EOF

:error
echo Failed with error #%errorlevel%.
exit /b %errorlevel%
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ vssver2.scc

.metadata
.submodule
/Sming/Arch/Host/Components/lwip/Windows/src
/Sming/Arch/Host/Components/lwip/Windows/tmp
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,8 @@
[submodule "Libraries.ArduinoJson"]
path = Sming/Libraries/ArduinoJson
url = https://github.com/bblanchon/ArduinoJson.git

[submodule "Host.lwip"]
path = Sming/Arch/Host/Components/lwip/lwip
url = git://git.savannah.gnu.org/lwip.git
ignore = dirty
56 changes: 23 additions & 33 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ matrix:
- os: linux
env: SDK_VERSION=2.0.0
- os: linux
dist: xenial
env: SDK_VERSION=3.0.0
git:
submodules: false
Expand All @@ -28,45 +29,34 @@ addons:
- graphviz
- xmlstarlet
- clang-format-6.0
- gcc-multilib
- g++-multilib
install:
- sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-6.0 100
- if [ "$SDK_VERSION" == "1.5.0" ] && [ "$TRAVIS_OS_NAME" == "osx" ]; then export
SDK_FILE_NAME="esp-alt-sdk-v${SDK_VERSION}.${SDK_BUILD}-macos-x86_64.zip"; fi
- if [ "$SDK_VERSION" == "1.5.0" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then export
SDK_FILE_NAME="esp-alt-sdk-v${SDK_VERSION}.${SDK_BUILD}-linux-x86_64.tar.gz"; fi
- if [ "$SDK_VERSION" == "1.5.0" ] && [ "$TRAVIS_OS_NAME" == "osx" ]; then
slaff marked this conversation as resolved.
Show resolved Hide resolved
export SDK_FILE_NAME="esp-alt-sdk-v${SDK_VERSION}.${SDK_BUILD}-macos-x86_64.zip";
fi
- if [ "$SDK_VERSION" == "1.5.0" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then
export SDK_FILE_NAME="esp-alt-sdk-v${SDK_VERSION}.${SDK_BUILD}-linux-x86_64.tar.gz";
fi
- mkdir -p $TRAVIS_BUILD_DIR/opt/esp-alt-sdk
- if [ "$SDK_VERSION" == "1.5.0" ]; then wget https://bintray.com/artifact/download/kireevco/generic/${SDK_FILE_NAME};
- if [ "$SDK_VERSION" == "1.5.0" ]; then
wget https://bintray.com/artifact/download/kireevco/generic/${SDK_FILE_NAME};
fi
- if [ "$SDK_VERSION" == "1.5.0" ]; then
bsdtar -xf ${SDK_FILE_NAME} -C $TRAVIS_BUILD_DIR/opt/esp-alt-sdk;
fi
- if [ "$SDK_VERSION" == "1.5.0" ]; then bsdtar -xf ${SDK_FILE_NAME} -C $TRAVIS_BUILD_DIR/opt/esp-alt-sdk;
- if [[ "$SDK_VERSION" != "1.5.0" && "$TRAVIS_OS_NAME" == "linux" ]]; then
wget https://github.com/nodemcu/nodemcu-firmware/raw/2d958750b56fc60297f564b4ec303e47928b5927/tools/esp-open-sdk.tar.xz;
tar -Jxvf esp-open-sdk.tar.xz; ln -s `pwd`/esp-open-sdk/xtensa-lx106-elf $TRAVIS_BUILD_DIR/opt/esp-alt-sdk/.;
fi
- if [[ "$SDK_VERSION" != "1.5.0" && "$TRAVIS_OS_NAME" == "linux" ]]; then wget https://github.com/nodemcu/nodemcu-firmware/raw/2d958750b56fc60297f564b4ec303e47928b5927/tools/esp-open-sdk.tar.xz;
tar -Jxvf esp-open-sdk.tar.xz; ln -s `pwd`/esp-open-sdk/xtensa-lx106-elf $TRAVIS_BUILD_DIR/opt/esp-alt-sdk/.
; fi
- if [ "$SDK_VERSION" == "2.0.0" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then wget
https://www.espressif.com/sites/default/files/sdks/esp8266_nonos_sdk_v2.0.0_16_08_10.zip
-O sdk.zip; unzip sdk.zip; ln -s `pwd`/ESP8266_NONOS_SDK/ $TRAVIS_BUILD_DIR/opt/esp-alt-sdk/sdk;
export DEPLOY='true'; fi
script:
- env
- unset SPIFFY
- unset ESPTOOL2

- export SMING_HOME=$TRAVIS_BUILD_DIR/Sming
- export ESP_HOME=$TRAVIS_BUILD_DIR/opt/esp-alt-sdk
- if [ "$SDK_VERSION" == "3.0.0" ]; then export SDK_BASE=$SMING_HOME/third-party/ESP8266_NONOS_SDK;
- if [ "$SDK_VERSION" == "2.0.0" ] && [ "$TRAVIS_OS_NAME" == "linux" ]; then
wget https://www.espressif.com/sites/default/files/sdks/esp8266_nonos_sdk_v2.0.0_16_08_10.zip -O sdk.zip;
unzip sdk.zip;
ln -s `pwd`/ESP8266_NONOS_SDK/ $TRAVIS_BUILD_DIR/opt/esp-alt-sdk/sdk;
export DEPLOY='true';
fi
- export PATH=$PATH:$ESP_HOME/xtensa-lx106-elf/bin:$ESP_HOME/utils/:$SMING_HOME/../.travis/tools
- cd $SMING_HOME
- if [ "$SDK_VERSION" == "2.0.0" ]; then ../.travis/tools/clang/format-pr.sh; fi
- cd $SMING_HOME
- make help
- make list-config
- make STRICT=1
- make samples
- make clean samples-clean
- make ENABLE_CUSTOM_HEAP=1 STRICT=1
- make Basic_Blink ENABLE_CUSTOM_HEAP=1 DEBUG_VERBOSE_LEVEL=3
- make dist-clean; make HttpServer_ConfigNetwork ENABLE_CUSTOM_LWIP=2 STRICT=1
script: sh $TRAVIS_BUILD_DIR/.travis/build.sh
deploy:
provider: script
script: sh $TRAVIS_BUILD_DIR/.travis/deploy.sh $TRAVIS_TAG
Expand Down
41 changes: 41 additions & 0 deletions .travis/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
set -e # exit with nonzero exit code if anything fails

env
unset SPIFFY
unset ESPTOOL2

export SMING_HOME=$TRAVIS_BUILD_DIR/Sming
export ESP_HOME=$TRAVIS_BUILD_DIR/opt/esp-alt-sdk
if [ "$SDK_VERSION" = "3.0.0" ]; then
export SDK_BASE=$SMING_HOME/third-party/ESP8266_NONOS_SDK
fi

cd $SMING_HOME

export PATH=$PATH:$ESP_HOME/xtensa-lx106-elf/bin:$ESP_HOME/utils/:$SMING_HOME/../.travis/tools
if [ "$SDK_VERSION" = "2.0.0" ]; then
../.travis/tools/clang/format-pr.sh;
fi

if [ "$SDK_VERSION" = "3.0.0" ]; then
slaff marked this conversation as resolved.
Show resolved Hide resolved
export SMING_ARCH=Host
export STRICT=1
make help
make list-config
make
make Basic_Blink Basic_DateTime Basic_Delegates Basic_Interrupts Basic_ProgMem Basic_Serial Basic_Servo LiveDebug DEBUG_VERBOSE_LEVEL=3
cd ../samples/HostTests
make flash
cd $SMING_HOME
fi

export SMING_ARCH=Esp8266
make help
make list-config
make STRICT=1
make samples
make clean samples-clean
make ENABLE_CUSTOM_HEAP=1 STRICT=1
make Basic_Blink ENABLE_CUSTOM_HEAP=1 DEBUG_VERBOSE_LEVEL=3
make dist-clean; make HttpServer_ConfigNetwork ENABLE_CUSTOM_LWIP=2 STRICT=1
11 changes: 11 additions & 0 deletions Sming/Arch/Esp8266/Components/driver/include/driver/pwm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#if defined(__cplusplus)
extern "C" {
#endif

#include <pwm.h>

#if defined(__cplusplus)
}
#endif
12 changes: 12 additions & 0 deletions Sming/Arch/Esp8266/Components/esp_wifi/include/esp_smartconfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

#if defined (__cplusplus)
extern "C" {
#endif

#include <smartconfig.h>

#if defined (__cplusplus)
}
#endif

11 changes: 11 additions & 0 deletions Sming/Arch/Esp8266/Components/esp_wifi/include/esp_wifi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <user_interface.h>

#ifdef __cplusplus
}
#endif
42 changes: 1 addition & 41 deletions Sming/Arch/Esp8266/Platform/WifiEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,7 @@ WifiEventsClass WifiEvents;

WifiEventsClass::WifiEventsClass()
{
wifi_set_event_handler_cb(staticWifiEventHandler);
}

void WifiEventsClass::onStationConnect(StationConnectDelegate delegateFunction)
{
onSTAConnect = delegateFunction;
}

void WifiEventsClass::onStationDisconnect(StationDisconnectDelegate delegateFunction)
{
onSTADisconnect = delegateFunction;
}

void WifiEventsClass::onStationAuthModeChange(StationAuthModeChangeDelegate delegateFunction)
{
onSTAAuthModeChange = delegateFunction;
}

void WifiEventsClass::onStationGotIP(StationGotIPDelegate delegateFunction)
{
onSTAGotIP = delegateFunction;
}

void WifiEventsClass::onAccessPointConnect(AccessPointConnectDelegate delegateFunction)
{
onSOFTAPConnect = delegateFunction;
}

void WifiEventsClass::onAccessPointDisconnect(AccessPointDisconnectDelegate delegateFunction)
{
onSOFTAPDisconnect = delegateFunction;
}

void WifiEventsClass::onAccessPointProbeReqRecved(AccessPointProbeReqRecvedDelegate delegateFunction)
{
onSOFTAPProbeReqRecved = delegateFunction;
}

void WifiEventsClass::staticWifiEventHandler(System_Event_t* evt)
{
WifiEvents.WifiEventHandler(evt);
wifi_set_event_handler_cb([](System_Event_t* evt) { WifiEvents.WifiEventHandler(evt); });
}

void WifiEventsClass::WifiEventHandler(System_Event_t* evt)
Expand Down
3 changes: 2 additions & 1 deletion Sming/Arch/Esp8266/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
#
##############

CFLAGS += -DARCH_ESP8266
CFLAGS += -DARCH_ESP8266
CXXFLAGS += -fno-rtti -fno-exceptions

ifndef ESP_HOME
$(error ESP_HOME variable is not set to a valid directory.)
Expand Down
15 changes: 15 additions & 0 deletions Sming/Arch/Host/Components/driver/include/driver/adc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once
#include "c_types.h"

#ifdef __cplusplus
extern "C" {
#endif

uint16_t system_adc_read(void);
void system_adc_read_fast(uint16_t* adc_addr, uint16_t adc_num, uint8_t adc_clk_div);
uint16_t system_get_vdd33(void);

#ifdef __cplusplus
}
#endif

22 changes: 22 additions & 0 deletions Sming/Arch/Host/Components/driver/include/driver/gpio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#pragma once
#include "c_types.h"

#ifdef __cplusplus
extern "C" {
#endif

/* Core/Interrupts.h */

typedef enum {
GPIO_PIN_INTR_DISABLE = 0,
GPIO_PIN_INTR_POSEDGE = 1,
GPIO_PIN_INTR_NEGEDGE = 2,
GPIO_PIN_INTR_ANYEDGE = 3,
GPIO_PIN_INTR_LOLEVEL = 4,
GPIO_PIN_INTR_HILEVEL = 5
} GPIO_INT_TYPE;

#ifdef __cplusplus
}
#endif

65 changes: 65 additions & 0 deletions Sming/Arch/Host/Components/driver/include/driver/pwm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* ESPRESSIF MIT License
*
* Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
*
* Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
* it is free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished
* to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/

#ifndef __PWM_H__
#define __PWM_H__

#pragma once

#if defined(__cplusplus)
extern "C" {
#endif

/*pwm.h: function and macro definition of PWM API , driver level */
/*user_light.h: user interface for light API, user level*/
/*user_light_adj: API for color changing and lighting effects, user level*/

/*NOTE!! : DO NOT CHANGE THIS FILE*/

/*SUPPORT UP TO 8 PWM CHANNEL*/
#define PWM_CHANNEL_NUM_MAX 8

//struct pwm_param {
// uint32_t period;
// uint32_t freq;
// uint32_t duty[PWM_CHANNEL_NUM_MAX]; //PWM_CHANNEL<=8
//};
//
///* pwm_init should be called only once, for now */
//void pwm_init(uint32_t period, uint32_t* duty, uint32_t pwm_channel_num, uint32_t (*pin_info_list)[3]);
//void pwm_start(void);
//
//void pwm_set_duty(uint32_t duty, uint8_t channel);
//uint32_t pwm_get_duty(uint8_t channel);
//void pwm_set_period(uint32_t period);
//uint32_t pwm_get_period(void);
//
//uint32_t get_pwm_version(void);
//void set_pwm_debug_en(uint8_t print_en);

#if defined(__cplusplus)
}
#endif

#endif
4 changes: 4 additions & 0 deletions Sming/Arch/Host/Components/driver/include/driver/uart.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@


#include <espinc/peri.h>
#include_next <driver/uart.h>
Loading