-
-
Notifications
You must be signed in to change notification settings - Fork 194
ESP-NOW Support #3448
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
Open
torbacz
wants to merge
13
commits into
nanoframework:main
Choose a base branch
from
torbacz:espnbow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
ESP-NOW Support #3448
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
338a445
ESPNOW initial
torbacz db27416
Minor error handling
torbacz 62af28b
Add encryption
torbacz 99e3fb8
Merge branch 'main' into espnbow
torbacz 5928ae8
Remove debug code/comments
torbacz 1436bbf
PR fixes
torbacz 229ecaf
Merge branch 'espnbow' of https://github.com/torbacz/nf-interpreter i…
torbacz d631e75
Fix checksum
torbacz 2229428
Fix declarations
torbacz ca0d945
Merge branch 'main' into espnbow
torbacz 3374300
Merge branch 'nanoframework:main' into espnbow
torbacz c4c3b8d
Change implementation to internal queue.
torbacz ba3e045
Merge branch 'main' into espnbow
torbacz 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 hidden or 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 hidden or 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,43 @@ | ||
| # Copyright (c) .NET Foundation and Contributors | ||
| # See LICENSE file in the project root for full license information. | ||
| # | ||
|
|
||
| # native code directory | ||
| set(BASE_PATH_FOR_THIS_MODULE ${BASE_PATH_FOR_CLASS_LIBRARIES_MODULES}/nanoFramework.EspNow) | ||
|
|
||
|
|
||
| # set include directories | ||
| list(APPEND nanoFramework.EspNow_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/CLR/Core) | ||
| list(APPEND nanoFramework.EspNow_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/CLR/Include) | ||
| list(APPEND nanoFramework.EspNow_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/HAL/Include) | ||
| list(APPEND nanoFramework.EspNow_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/PAL/Include) | ||
| list(APPEND nanoFramework.EspNow_INCLUDE_DIRS ${BASE_PATH_FOR_THIS_MODULE}) | ||
| list(APPEND nanoFramework.EspNow_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/src/nanoFramework.EspNow) | ||
|
|
||
| # source files | ||
| set(nanoFramework.EspNow_SRCS | ||
| nanoFramework_espnow_native.cpp | ||
| nanoFramework_espnow_native_nanoFramework_Espnow_EspNowController.cpp | ||
| nanoFramework_espnow_native_nanoFramework_Espnow_EspNowController__EspNowEventHandler.cpp | ||
| ) | ||
|
|
||
| foreach(SRC_FILE ${nanoFramework.EspNow_SRCS}) | ||
| set(nanoFramework.EspNow_SRC_FILE SRC_FILE-NOTFOUND) | ||
| find_file(nanoFramework.EspNow_SRC_FILE ${SRC_FILE} | ||
| PATHS | ||
| ${BASE_PATH_FOR_THIS_MODULE} | ||
| ${TARGET_BASE_LOCATION} | ||
| ${PROJECT_SOURCE_DIR}/src/nanoFramework.EspNow | ||
| CMAKE_FIND_ROOT_PATH_BOTH | ||
| ) | ||
|
|
||
| if (BUILD_VERBOSE) | ||
| message("${SRC_FILE} >> ${nanoFramework.EspNow_SRC_FILE}") | ||
| endif() | ||
|
|
||
| list(APPEND nanoFramework.EspNow_SOURCES ${nanoFramework.EspNow_SRC_FILE}) | ||
| endforeach() | ||
|
|
||
| include(FindPackageHandleStandardArgs) | ||
|
|
||
| FIND_PACKAGE_HANDLE_STANDARD_ARGS(nanoFramework.EspNow DEFAULT_MSG nanoFramework.EspNow_INCLUDE_DIRS nanoFramework.EspNow_SOURCES) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
32 changes: 32 additions & 0 deletions
32
targets/ESP32/_nanoCLR/nanoFramework.Espnow/nanoFramework_espnow_native.cpp
This file contains hidden or 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,32 @@ | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
|
|
||
| #include "nanoFramework_espnow_native.h" | ||
|
|
||
| // clang-format off | ||
|
|
||
| static const CLR_RT_MethodHandler method_lookup[] = | ||
| { | ||
| NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | ||
| NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, | ||
| Library_nanoFramework_EspNow_native_nanoFramework_EspNow_EspNowController::NativeInitialize___I4, | ||
| Library_nanoFramework_EspNow_native_nanoFramework_EspNow_EspNowController::NativeDispose___VOID__BOOLEAN, | ||
| Library_nanoFramework_EspNow_native_nanoFramework_EspNow_EspNowController::NativeEspNowSend___I4__SZARRAY_U1__SZARRAY_U1__I4, | ||
| Library_nanoFramework_EspNow_native_nanoFramework_EspNow_EspNowController::NativeEspNowAddPeer___I4__SZARRAY_U1__U1__BOOLEAN__SZARRAY_U1, | ||
| Library_nanoFramework_EspNow_native_nanoFramework_EspNow_EspNowController::NativeGetMaximumDataLength___I4, | ||
| Library_nanoFramework_EspNow_native_nanoFramework_EspNow_EspNowController::NativeReadPacket___I4__SZARRAY_U1__SZARRAY_U1__I4, | ||
| Library_nanoFramework_EspNow_native_nanoFramework_EspNow_EspNowController::NativeGetReceiveOverflowCount___I4, | ||
| NULL, NULL, NULL, NULL, | ||
| Library_nanoFramework_EspNow_native_nanoFramework_EspNow_EspNowControllerEventListener::ProcessEvent___nanoFrameworkRuntimeEventsBaseEvent__U4__U4__SystemDateTime, | ||
| NULL, NULL, NULL, | ||
| }; | ||
|
|
||
| const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_EspNow = | ||
| { | ||
| "nanoFramework.EspNow", | ||
| 0xE70CA3CA, | ||
| method_lookup, | ||
| { 100, 0, 0, 0 } | ||
| }; | ||
|
|
||
| // clang-format on |
87 changes: 87 additions & 0 deletions
87
targets/ESP32/_nanoCLR/nanoFramework.Espnow/nanoFramework_espnow_native.h
This file contains hidden or 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,87 @@ | ||
| // Copyright (c) .NET Foundation and Contributors | ||
| // See LICENSE file in the project root for full license information. | ||
| // | ||
|
|
||
| #ifndef NANOFRAMEWORK_ESPNOW_NATIVE_H | ||
| #define NANOFRAMEWORK_ESPNOW_NATIVE_H | ||
|
|
||
| #include <nanoCLR_Interop.h> | ||
| #include <nanoCLR_Runtime.h> | ||
| #include <nanoPackStruct.h> | ||
| #include <corlib_native.h> | ||
|
|
||
| #include <esp_interface.h> | ||
| #include <esp_wifi.h> | ||
| #include <esp_now.h> | ||
|
|
||
| #ifdef ESP_NOW_MAX_DATA_LEN_V2 | ||
| #define NF_ESPNOW_MAX_DATA_LEN ESP_NOW_MAX_DATA_LEN_V2 | ||
| #else | ||
| #define NF_ESPNOW_MAX_DATA_LEN ESP_NOW_MAX_DATA_LEN | ||
| #endif | ||
|
|
||
| static constexpr uint32_t NF_ESPNOW_RX_QUEUE_DEPTH = 10; | ||
|
|
||
| struct EspNowPacket | ||
| { | ||
| uint8_t peer_mac[ESP_NOW_ETH_ALEN]; | ||
| uint8_t data[NF_ESPNOW_MAX_DATA_LEN]; | ||
| uint16_t data_len; | ||
| }; | ||
|
|
||
| struct Library_nanoFramework_EspNow_native_nanoFramework_EspNow_DataReceivedEventArgs | ||
| { | ||
| static const int FIELD__PeerMac = 1; | ||
| static const int FIELD__Data = 2; | ||
| static const int FIELD__DataLen = 3; | ||
|
|
||
| //--// | ||
| }; | ||
|
|
||
| struct Library_nanoFramework_EspNow_native_nanoFramework_EspNow_DataRecvEventInternal | ||
| { | ||
| //--// | ||
| }; | ||
|
|
||
| struct Library_nanoFramework_EspNow_native_nanoFramework_EspNow_EspNowController | ||
| { | ||
| static const int FIELD_STATIC__s_instance = 0; | ||
| static const int FIELD_STATIC__s_syncLock = 1; | ||
|
|
||
| static const int FIELD___disposed = 1; | ||
| static const int FIELD___syncLock = 2; | ||
| static const int FIELD___eventHandler = 3; | ||
| NANOCLR_NATIVE_DECLARE(NativeInitialize___I4); | ||
| NANOCLR_NATIVE_DECLARE(NativeDispose___VOID__BOOLEAN); | ||
| NANOCLR_NATIVE_DECLARE(NativeEspNowSend___I4__SZARRAY_U1__SZARRAY_U1__I4); | ||
| NANOCLR_NATIVE_DECLARE(NativeEspNowAddPeer___I4__SZARRAY_U1__U1__BOOLEAN__SZARRAY_U1); | ||
| NANOCLR_NATIVE_DECLARE(NativeGetMaximumDataLength___I4); | ||
| NANOCLR_NATIVE_DECLARE(NativeReadPacket___I4__SZARRAY_U1__SZARRAY_U1__I4); | ||
| NANOCLR_NATIVE_DECLARE(NativeGetReceiveOverflowCount___I4); | ||
|
|
||
| //--// | ||
| static void DataSentCb(const wifi_tx_info_t *tx_info, esp_now_send_status_t status); | ||
| static void DataRecvCb(const esp_now_recv_info *recv_info, const uint8_t *incomingData, int len); | ||
| }; | ||
|
|
||
| struct Library_nanoFramework_EspNow_native_nanoFramework_EspNow_EspNowControllerEventListener | ||
| { | ||
| static const int FIELD___controller = 1; | ||
|
|
||
| NANOCLR_NATIVE_DECLARE(ProcessEvent___nanoFrameworkRuntimeEventsBaseEvent__U4__U4__SystemDateTime); | ||
|
|
||
| //--// | ||
|
|
||
| static HRESULT ProcessEvent_DataRecv(CLR_RT_StackFrame &stack); | ||
| }; | ||
|
|
||
| struct Library_nanoFramework_EspNow_native_nanoFramework_EspNow_EspNowException | ||
| { | ||
| static const int FIELD__esp_err = 5; | ||
|
|
||
| //--// | ||
| }; | ||
|
|
||
| extern const CLR_RT_NativeAssemblyData g_CLR_AssemblyNative_nanoFramework_EspNow; | ||
|
|
||
| #endif // NANOFRAMEWORK_ESPNOW_NATIVE_H |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.