-
-
Notifications
You must be signed in to change notification settings - Fork 345
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
Feature: component hosted #2305
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
304c805
Drafting ideas about app on host and some parts on the device.
slav-at-attachix 7334e0b
further research ...
slav-at-attachix 60a6960
And we have a running minimal HostedServer using Tcp transport.
slav-at-attachix b0bd00a
Replaced nanopb code with submodule.
slav-at-attachix 3fe8f77
Ready with the initial version of Hosted.
slav-at-attachix 5aa9226
Added initial documentation.
slav-at-attachix 27633cb
Initial work on SPI support.
slav-at-attachix 711ddc3
Feature/component hosted review (#68)
mikee47 48abae7
Removed Components/nanopb. Will be using Libraries/nanopb.
slav-at-attachix 4093b3f
Trying to compile the code with the latest develop version.
slav-at-attachix 9658b9e
Initial code. Nothing to see yet.
slav-at-attachix c17a553
Untested changes.
slav-at-attachix 6ce358f
Some progress ....
slav-at-attachix c4755f3
PoC is ready.
slav-at-attachix 49013b8
Initial version of the SimpleRPC stream parser for the headers.
slav-at-attachix 9d56171
Fixes.
slav-at-attachix b9115e5
Added Hosted tests.
slav-at-attachix a465ba1
Headers and coding style.
slav-at-attachix e0a2128
Travis is up and clang-format has to be updated.
slav-at-attachix b51536a
Run Hosted Tcp tests only if network is present.
slav-at-attachix d67b771
Update Travis to use GCC 9.
slav-at-attachix be59a41
Final touches for the initial and not reviewed yet version.
slav-at-attachix cbb1f81
Applied recommendations from mikee.
slav-at-attachix 583b640
Applying review recommendations.
slav-at-attachix 563f25a
Decrease lag when using TCP.
slav-at-attachix 54882dc
Moving the main_loop function to a separate header. Should fix issue …
slav-at-attachix 24ec69e
Replace weak function with function wrapper.
slav-at-attachix 369c483
Use only Esp8266 EQT for Travis builds.
slav-at-attachix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/**** | ||
* Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. | ||
* Created 2015 by Skurydin Alexey | ||
* http://github.com/SmingHub/Sming | ||
* All files of the Sming Core are provided under the LGPL v3 license. | ||
* | ||
* emu.h | ||
* | ||
****/ | ||
|
||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief Executing this function will run once the main emulator loop. | ||
*/ | ||
void host_main_loop(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* hostlib.h | ||
* | ||
* Copyright 2019 mikee47 <[email protected]> | ||
* | ||
* This file is part of the Sming Framework Project | ||
* | ||
* This library is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, version 3 or later. | ||
* | ||
* 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with SHEM. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
****/ | ||
|
||
#pragma once | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
void host_init(); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* init.cpp - Sming Host Emulator startup code | ||
* | ||
* Copyright 2019 mikee47 <[email protected]> | ||
* | ||
* This file is part of the Sming Framework Project | ||
* | ||
* This library is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, version 3 or later. | ||
* | ||
* 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with SHEM. | ||
* If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
****/ | ||
|
||
#include "include/hostlib/init.h" | ||
|
||
extern void init(); | ||
|
||
void host_init() | ||
{ | ||
init(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include "SPI.h" | ||
|
||
bool SPIClass::begin() | ||
{ | ||
return false; | ||
} | ||
|
||
void SPIClass::transfer(uint8_t* buffer, size_t numberBytes) | ||
{ | ||
} | ||
|
||
void SPIClass::prepare(SPISettings& settings) | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
COMPONENT_SRCDIRS := $(COMPONENT_PATH)/src | ||
COMPONENT_DEPENDS := Hosted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/**** | ||
* Sming Framework Project - Open Source framework for high efficiency native ESP8266 development. | ||
* Created 2015 by Skurydin Alexey | ||
* http://github.com/SmingHub/Sming | ||
* All files of the Sming Core are provided under the LGPL v3 license. | ||
* | ||
* Digital.cpp | ||
* | ||
* @author 2021 Slavey Karadzhov <[email protected]> | ||
* | ||
* | ||
****/ | ||
|
||
#include <Digital.h> | ||
#include <Hosted/Client.h> | ||
|
||
extern Hosted::Client* hostedClient; | ||
|
||
void pinMode(uint16_t pin, uint8_t mode) | ||
{ | ||
hostedClient->send(__func__, pin, mode); | ||
} | ||
|
||
void digitalWrite(uint16_t pin, uint8_t val) | ||
{ | ||
hostedClient->send(__func__, pin, val); | ||
} | ||
|
||
uint8_t digitalRead(uint16_t pin) | ||
{ | ||
hostedClient->send(__func__, pin); | ||
return hostedClient->wait<uint8_t>(); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
HostEd | ||
====== | ||
|
||
.. highlight:: bash | ||
|
||
The hosted component allows Sming's host emulator to run parts of the commands on an actual microcontroller. | ||
The communication is done via `simplePRC <https://simplerpc.readthedocs.io/>`_ and the microcontroller has to be flashed with a special application. | ||
|
||
Overview | ||
-------- | ||
Sming's host emulator allows easier debugging and development of embedded applications. This component named "HostEd" extends the host emulator | ||
and facilitates testing functionality that only a real microcontroller can provide as for example digital I/O operations or SPI operations. | ||
|
||
For example in order to run the Basic_Blink application under the host emulator and run the actual blinking of a LED on a microcontroller | ||
we can compile the application using the following directives:: | ||
|
||
make SMING_ARCH=Host ENABLE_HOSTED=tcp HOSTED_SERVER_IP=192.168.4.1 | ||
|
||
`SMING_ARCH=Host` instructs the build system to build the application for the Host architecture. | ||
`ENABLE_HOSTED=tcp` instructs the host emulator to communication with the real microcontroller using TCP | ||
`HOSTED_SERVER_IP=192.168.4.1` instructs the host emulator to connect to IP `192.168.4.1`. | ||
|
||
We need to compile and flash also a special application on the desired microcontroller. | ||
This application will act as an RPC Server and will execute the commands from the host emulator on the microcontroller. | ||
|
||
In the sub-directory ``samples`` inside this directory you will find the sample applications that will turn your microcontroller into | ||
RCP server. | ||
|
||
The compilation and flashing for ESP32, for example, can be done using the following commands:: | ||
|
||
cd samples/tcp | ||
make SMING_ARCH=Esp32 WIFI_SSID=YourSSID WIFI_PWD=YourPassword | ||
make flash | ||
|
||
If you replace ``SMING_ARCH=Esp32`` with ``SMING_ARCH=Esp8266`` then the hosted application will be compiled and flashed on a ESP8266 microcontroller. | ||
Make sure to replace the values of WIFI_SSID and WIFI_PWD with the actual name and password for the Access Point (AP). | ||
|
||
Communication | ||
------------- | ||
At the moment the communication between an application running on the Host and the RCP server running on a microcontroller | ||
can be done using TCP or serial interface. | ||
The ``transport`` classes are located under ``include/Hosted/Transport``. | ||
|
||
Configuration | ||
------------- | ||
.. envvar:: ENABLE_HOSTED | ||
|
||
Default: empty (disabled) | ||
|
||
Enables the hosted component. Valid values for the moment are: | ||
- tcp - for communication over TCP network. | ||
- serial - for communication over serial interface |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
COMPONENT_SRCDIRS := $(COMPONENT_PATH)/src | ||
COMPONENT_INCDIRS := $(COMPONENT_SRCDIRS) $(COMPONENT_PATH)/include | ||
COMPONENT_DEPENDS := simpleRPC | ||
|
||
# Architecture of the device where the hosted service will be flashed | ||
HOSTED_ARCH ?= Esp8266 | ||
|
||
COMPONENT_RELINK_VARS += ENABLE_HOSTED | ||
COMPONENT_VARS := ENABLE_HOSTED | ||
|
||
ENABLE_HOSTED ?= | ||
|
||
ifneq ($(ENABLE_HOSTED),) | ||
COMPONENT_SRCDIRS += $(COMPONENT_PATH)/init/$(ENABLE_HOSTED) | ||
EXTRA_LDFLAGS := -Wl,-wrap,host_init | ||
endif | ||
|
||
COMPONENT_VARS += HOSTED_SERVER_IP | ||
|
||
COMPONENT_CFLAGS = -DHOSTED_SERVER_IP=$(HOSTED_SERVER_IP) | ||
COMPONENT_CXXFLAGS := $(COMPONENT_CFLAGS) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You've added
SPI.cpp
but not made any changes to the code. Revert SPI.cpp and SPI.h.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have split them into header and implementation to make it easier for the hosted component to replace the
real
implementation with its own implementation. I would prefer to leave it as it is and add the SPI hosted implementation in a separate PR if that is ok for you.