-
-
Notifications
You must be signed in to change notification settings - Fork 617
[On Hold] Add stage 1 host test rollout #1698
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
540lyle
wants to merge
3
commits into
bdring:main
Choose a base branch
from
540lyle:codex/integration-test-suite
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
Changes from all commits
Commits
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,66 @@ | ||
| #pragma once | ||
|
|
||
| #include <functional> | ||
|
|
||
| typedef int ota_error_t; | ||
|
|
||
| static constexpr ota_error_t OTA_AUTH_ERROR = 1; | ||
| static constexpr ota_error_t OTA_BEGIN_ERROR = 2; | ||
| static constexpr ota_error_t OTA_CONNECT_ERROR = 3; | ||
| static constexpr ota_error_t OTA_RECEIVE_ERROR = 4; | ||
| static constexpr ota_error_t OTA_END_ERROR = 5; | ||
| static constexpr int U_FLASH = 0; | ||
| static constexpr int U_FS = 100; | ||
|
|
||
| class ArduinoOTAClass { | ||
| public: | ||
| bool mdnsEnabled = true; | ||
| const char* hostname = nullptr; | ||
| int command = U_FLASH; | ||
| int beginCalls = 0; | ||
| int endCalls = 0; | ||
| int handleCalls = 0; | ||
| std::function<void()> onStartHandler; | ||
| std::function<void()> onEndHandler; | ||
| std::function<void(unsigned int, unsigned int)> onProgressHandler; | ||
| std::function<void(ota_error_t)> onErrorHandler; | ||
|
|
||
| ArduinoOTAClass& setMdnsEnabled(bool enabled) { | ||
| mdnsEnabled = enabled; | ||
| return *this; | ||
| } | ||
| ArduinoOTAClass& setHostname(const char* next) { | ||
| hostname = next; | ||
| return *this; | ||
| } | ||
| ArduinoOTAClass& onStart(std::function<void()> handler) { | ||
| onStartHandler = std::move(handler); | ||
| return *this; | ||
| } | ||
| ArduinoOTAClass& onEnd(std::function<void()> handler) { | ||
| onEndHandler = std::move(handler); | ||
| return *this; | ||
| } | ||
| ArduinoOTAClass& onProgress(std::function<void(unsigned int, unsigned int)> handler) { | ||
| onProgressHandler = std::move(handler); | ||
| return *this; | ||
| } | ||
| ArduinoOTAClass& onError(std::function<void(ota_error_t)> handler) { | ||
| onErrorHandler = std::move(handler); | ||
| return *this; | ||
| } | ||
| void begin() { | ||
| ++beginCalls; | ||
| } | ||
| void end() { | ||
| ++endCalls; | ||
| } | ||
| void handle() { | ||
| ++handleCalls; | ||
| } | ||
| int getCommand() const { | ||
| return command; | ||
| } | ||
| }; | ||
|
|
||
| inline ArduinoOTAClass ArduinoOTA; |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| #include "Stage1HostSupport.h" | ||
|
|
||
| #include "ArduinoOTA.h" | ||
| #include "WiFi.h" | ||
| #include "WiFiClientSecure.h" | ||
| #include "mdns.h" | ||
|
|
||
| namespace Stage1HostSupport { | ||
| I2CState g_i2c; | ||
| SPIState g_spi; | ||
| I2SOState g_i2so; | ||
|
|
||
| void resetBusState() { | ||
| g_i2c = {}; | ||
| g_spi = {}; | ||
| g_i2so = {}; | ||
| } | ||
|
|
||
| void resetWebUiState() { | ||
| WiFi.setMode(WIFI_OFF); | ||
| WiFi.setHostname("fluidnc-host"); | ||
|
|
||
| g_mdnsInitResult = 0; | ||
| g_mdnsHostnameSetResult = 0; | ||
| g_mdnsFreeCalls = 0; | ||
| g_mdnsAddedServices.clear(); | ||
| g_mdnsRemovedServices.clear(); | ||
|
|
||
| g_wifiClientConnectResult = true; | ||
| g_wifiClientConnected = false; | ||
| g_wifiClientStopCalls = 0; | ||
| g_wifiClientSetInsecureCalls = 0; | ||
| g_wifiClientWrites.clear(); | ||
| g_wifiClientReadLines.clear(); | ||
| g_wifiClientLastErrorCode = 0; | ||
| g_wifiClientLastErrorText.clear(); | ||
|
|
||
| ArduinoOTA.mdnsEnabled = true; | ||
| ArduinoOTA.hostname = nullptr; | ||
| ArduinoOTA.command = U_FLASH; | ||
| ArduinoOTA.beginCalls = 0; | ||
| ArduinoOTA.endCalls = 0; | ||
| ArduinoOTA.handleCalls = 0; | ||
| ArduinoOTA.onStartHandler = nullptr; | ||
| ArduinoOTA.onEndHandler = nullptr; | ||
| ArduinoOTA.onProgressHandler = nullptr; | ||
| ArduinoOTA.onErrorHandler = nullptr; | ||
| } | ||
| } | ||
|
|
||
| bool i2c_master_init(objnum_t bus_number, pinnum_t sda_pin, pinnum_t scl_pin, uint32_t frequency) { | ||
| ++Stage1HostSupport::g_i2c.initCalls; | ||
| Stage1HostSupport::g_i2c.initBus = bus_number; | ||
| Stage1HostSupport::g_i2c.initSda = sda_pin; | ||
| Stage1HostSupport::g_i2c.initScl = scl_pin; | ||
| Stage1HostSupport::g_i2c.initFrequency = frequency; | ||
| return Stage1HostSupport::g_i2c.initError; | ||
| } | ||
|
|
||
| int i2c_write(objnum_t bus_number, uint8_t address, const uint8_t* data, size_t count) { | ||
| Stage1HostSupport::g_i2c.lastWriteBus = bus_number; | ||
| Stage1HostSupport::g_i2c.lastWriteAddress = address; | ||
| Stage1HostSupport::g_i2c.lastWriteData.assign(data, data + count); | ||
| return Stage1HostSupport::g_i2c.writeResult; | ||
| } | ||
|
|
||
| int i2c_read(objnum_t bus_number, uint8_t address, uint8_t* data, size_t count) { | ||
| Stage1HostSupport::g_i2c.lastReadBus = bus_number; | ||
| Stage1HostSupport::g_i2c.lastReadAddress = address; | ||
| for (size_t i = 0; i < count; ++i) { | ||
| data[i] = i < Stage1HostSupport::g_i2c.readData.size() ? Stage1HostSupport::g_i2c.readData[i] : 0; | ||
| } | ||
| return Stage1HostSupport::g_i2c.readResult; | ||
| } |
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.