-
Notifications
You must be signed in to change notification settings - Fork 18
Make library compatible with NINA WiFi module #15
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
facchinm
wants to merge
10
commits into
master
Choose a base branch
from
wifinina_support
base: master
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
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9851ddc
Make library compatible with MKR1010
facchinm 2b24a22
WIP: Add NINAStorage backend
facchinm cc56edb
Use downloadAPI if available
facchinm 1046173
Add Nano33IoT and MKRVidor as targets
facchinm 138e68a
Update keywords.txt
facchinm cba64b0
Use _has_include to select correct OTA medium
facchinm 615380f
Add NINAStorageRaw class to avoid forcin downloadAPI
facchinm 60be363
Mass rename of the library
facchinm b73f052
Add missing keywords
facchinm 7c02a6f
Add NINAStorage example
facchinm 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,6 @@ | |
| */ | ||
|
|
||
| #include <SPI.h> | ||
| #include <WiFi101.h> | ||
| #include <WiFi101OTA.h> | ||
|
|
||
| #include "arduino_secrets.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 |
|---|---|---|
|
|
@@ -21,7 +21,6 @@ | |
|
|
||
| #include <SPI.h> | ||
| #include <SD.h> | ||
| #include <WiFi101.h> | ||
| #include <WiFi101OTA.h> | ||
| #include <SDU.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
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,85 @@ | ||
| /* | ||
| Copyright (c) 2018 Arduino LLC. All right reserved. | ||
|
|
||
| This library is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU Lesser General Public | ||
| License as published by the Free Software Foundation; either | ||
| version 2.1 of the License, or (at your option) any later version. | ||
|
|
||
| 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 Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public | ||
| License along with this library; if not, write to the Free Software | ||
| Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| #include "NINAStorage.h" | ||
|
|
||
| #define UPDATE_FILE "/fs/UPDATE.BIN" | ||
|
|
||
| static inline void reboot() { | ||
| #ifdef __AVR__ | ||
| /* Write boot request */ | ||
| USERROW.USERROW31 = 0xEB; | ||
| _PROTECTED_WRITE_SPM(NVMCTRL.CTRLA, NVMCTRL_CMD_PAGEERASEWRITE_gc); | ||
| while(NVMCTRL.STATUS & NVMCTRL_EEBUSY_bm); | ||
|
|
||
| _PROTECTED_WRITE(RSTCTRL.SWRR, RSTCTRL_SWRE_bm); | ||
| #else | ||
| NVIC_SystemReset(); | ||
| #endif | ||
| } | ||
|
|
||
| int NINAStorageClass::open(int contentLength) | ||
| { | ||
| if (WiFiStorage.exists(UPDATE_FILE)) { | ||
| WiFiStorage.remove(UPDATE_FILE); | ||
| } | ||
|
|
||
| WiFiStorageFile file = WiFiStorage.open(UPDATE_FILE); | ||
|
|
||
| _file = &file; | ||
|
|
||
| return 1; | ||
| } | ||
|
|
||
| size_t NINAStorageClass::write(uint8_t b) | ||
| { | ||
| int ret = _file->write(&b, 1); | ||
| return ret; | ||
| } | ||
|
|
||
| void NINAStorageClass::close() | ||
| { | ||
| _file->close(); | ||
| } | ||
|
|
||
| void NINAStorageClass::clear() | ||
| { | ||
| WiFiStorage.remove(UPDATE_FILE); | ||
| } | ||
|
|
||
| void NINAStorageClass::apply() | ||
| { | ||
| WiFiDrv::applyOTA(); | ||
| reboot(); | ||
| } | ||
|
|
||
| void NINAStorageClass::download(String url) | ||
| { | ||
| WiFiStorage.download(url, "UPDATE.BIN"); | ||
| } | ||
|
|
||
| long NINAStorageClass::maxSize() | ||
| { | ||
| #ifdef __AVR__ | ||
| return (0xFFFF - 0x3FFF - 0x100); | ||
| #else | ||
| return ((256 * 1024) - 0x2000); | ||
| #endif | ||
| } | ||
|
|
||
| NINAStorageClass NINAStorage; |
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,45 @@ | ||
| /* | ||
| Copyright (c) 2017 Arduino LLC. All right reserved. | ||
|
|
||
| This library is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU Lesser General Public | ||
| License as published by the Free Software Foundation; either | ||
| version 2.1 of the License, or (at your option) any later version. | ||
|
|
||
| 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 Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public | ||
| License along with this library; if not, write to the Free Software | ||
| Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| */ | ||
|
|
||
| #ifndef _NINA_STORAGE_H_INCLUDED | ||
| #define _NINA_STORAGE_H_INCLUDED | ||
|
|
||
| #include <WiFiStorage.h> | ||
|
|
||
| #include "OTAStorage.h" | ||
|
|
||
| class NINAStorageClass : public OTAStorage { | ||
| public: | ||
| virtual int open(int length); | ||
| virtual size_t write(uint8_t); | ||
| virtual void close(); | ||
| virtual void clear(); | ||
| virtual void apply(); | ||
| virtual long maxSize(); | ||
| virtual void download(String url); | ||
| virtual bool hasDownloadAPI() { | ||
| return true; | ||
| } | ||
|
|
||
| private: | ||
| WiFiStorageFile* _file; | ||
| }; | ||
|
|
||
| extern NINAStorageClass NINAStorage; | ||
|
|
||
| #endif |
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
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.