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

Restyle ESP32: OTA Requestor and OTA Provider example applications #11321

Closed
wants to merge 5 commits into from

Conversation

restyled-io[bot]
Copy link
Contributor

@restyled-io restyled-io bot commented Nov 2, 2021

A duplicate of #11320 with additional commits that automatically address
incorrect style, created by Restyled.

⚠️ Even though this PR is not a Fork, it contains outside contributions.
Please review accordingly.

Since the original Pull Request was opened as a fork in a contributor's
repository, we are unable to create a Pull Request branching from it with only
the style fixes.

The following Restylers made fixes:

To incorporate these changes, you can either:

  1. Merge this Pull Request instead of the original, or

  2. Ask your contributor to locally incorporate these commits and push them to
    the original Pull Request

    Expand for example instructions
    ```console
    git remote add upstream https://github.com/project-chip/connectedhomeip.git
    git fetch upstream pull/<this PR number>/head
    git merge --ff-only FETCH_HEAD
    git push
    ```
    

NOTE: As work continues on the original Pull Request, this process will
re-run and update (force-push) this Pull Request with updated style fixes as
necessary. If the style is fixed manually at any point (i.e. this process finds
no fixes to make), this Pull Request will be closed automatically.

Sorry if this was unexpected. To disable it, see our documentation.

@todo
Copy link

todo bot commented Nov 2, 2021

(cecille): Fix for the case where BLE and SoftAP are both enabled.`

// TODO(cecille): Fix for the case where BLE and SoftAP are both enabled.`
ConnectivityMgr().SetBLEAdvertisingEnabled(false);
ConnectivityMgr().SetWiFiAPMode(ConnectivityManager::kWiFiAPMode_Enabled);
}
else
{
// If rendezvous is bypassed, enable SoftAP so that the device can still
// be communicated with via its SoftAP as needed.
ConnectivityMgr().SetWiFiAPMode(ConnectivityManager::kWiFiAPMode_Enabled);
}


This comment was generated by todo based on a TODO comment in d42865d in #11321. cc @project-chip.

@todo
Copy link

todo bot commented Nov 2, 2021

handle this callback in switch statement

// TODO handle this callback in switch statement
ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId);
ESP_LOGI(TAG, "Current free heap: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT));
}
void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event)
{
if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established)
{
ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT);


This comment was generated by todo based on a TODO comment in d42865d in #11321. cc @project-chip.

@todo
Copy link

todo bot commented Nov 2, 2021

this should probably be done dynamically

// TODO: this should probably be done dynamically
constexpr chip::EndpointId kOtaProviderEndpoint = 0;
constexpr uint32_t kMaxBdxBlockSize = 1024;
constexpr chip::System::Clock::Timeout kBdxTimeout = chip::System::Clock::Seconds16(5 * 60); // Specifications mandates >= 5 minutes
constexpr chip::System::Clock::Timeout kBdxPollFreq = chip::System::Clock::Milliseconds32(500);
const char * gOtaFilename = "hello-world.bin";
BdxOtaSender bdxServer;
const esp_partition_t * otaPartition = nullptr;
uint32_t otaImageLen = 0;


This comment was generated by todo based on a TODO comment in d42865d in #11321. cc @project-chip.

@todo
Copy link

todo bot commented Nov 2, 2021

Use the OTA image header specified in specifications

// TODO: Use the OTA image header specified in specifications
// Right now we are using just image length instead of full header
esp_partition_read(otaPartition, 0, &otaImageLen, sizeof(otaImageLen));
if (otaImageLen > otaPartition->size)
{
otaImageLen = 0;
}
ESP_LOGI(TAG, "OTA image length %d bytes", otaImageLen);
}
else
{


This comment was generated by todo based on a TODO comment in d42865d in #11321. cc @project-chip.

@todo
Copy link

todo bot commented Nov 2, 2021

(cecille): Fix for the case where BLE and SoftAP are both enabled.`

// TODO(cecille): Fix for the case where BLE and SoftAP are both enabled.`
ConnectivityMgr().SetBLEAdvertisingEnabled(false);
ConnectivityMgr().SetWiFiAPMode(ConnectivityManager::kWiFiAPMode_Enabled);
}
else
{
// If rendezvous is bypassed, enable SoftAP so that the device can still
// be communicated with via its SoftAP as needed.
ConnectivityMgr().SetWiFiAPMode(ConnectivityManager::kWiFiAPMode_Enabled);
}


This comment was generated by todo based on a TODO comment in d42865d in #11321. cc @project-chip.

@todo
Copy link

todo bot commented Nov 2, 2021

handle this callback in switch statement

// TODO handle this callback in switch statement
ESP_LOGI(TAG, "Unhandled cluster ID: %d", clusterId);
ESP_LOGI(TAG, "Current free heap: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT));
}
void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event)
{
if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established)
{
ESP_LOGI(TAG, "Server ready at: %s:%d", event->InternetConnectivityChange.address, CHIP_PORT);


This comment was generated by todo based on a TODO comment in d42865d in #11321. cc @project-chip.

@todo
Copy link

todo bot commented Nov 2, 2021

Encapsulate these globals and the callbacks in some class

// TODO: Encapsulate these globals and the callbacks in some class
OperationalDeviceProxy gOperationalDeviceProxy;
ExchangeContext * exchangeCtx = nullptr;
BdxDownloader bdxDownloader;
uint8_t operationalDeviceContext; // 0 - none, 1 - QueryImage, 2 - ApplyUpdateRequest, 3 - NotifyUpdateApplied
ByteSpan otaUpdateToken;
/* Callbacks for QueryImage response */
Callback<OtaSoftwareUpdateProviderClusterQueryImageResponseCallback> mQueryImageResponseCallback(OnQueryImageResponse, nullptr);
Callback<DefaultFailureCallback> mOnQueryImageFailureCallback(OnQueryImageFailure, nullptr);


This comment was generated by todo based on a TODO comment in d42865d in #11321. cc @project-chip.

@todo
Copy link

todo bot commented Nov 2, 2021

support this as a list once ember adds list support

EMBER_ZCL_OTA_DOWNLOAD_PROTOCOL_BDX_SYNCHRONOUS; // TODO: support this as a list once ember adds list support
const char locationBuf[] = { 'U', 'S' };
CharSpan exampleLocation(locationBuf);
constexpr bool kExampleClientCanConsent = false;
ByteSpan metadata;
err = cluster.QueryImage(successCallback, failureCallback, kExampleVendorId, kExampleProductId, kExampleHWVersion,
kExampleSoftwareVersion, kExampleProtocolsSupported, exampleLocation, kExampleClientCanConsent,
metadata);
if (err != CHIP_NO_ERROR)
{


This comment was generated by todo based on a TODO comment in d42865d in #11321. cc @project-chip.

@todo
Copy link

todo bot commented Nov 2, 2021

Apply update after delayed action time

// TODO: Apply update after delayed action time
// TODO: Handle applying update after reboot
esp_err_t OTAUpdater::Apply(uint32_t delayedActionTime)
{
if (mOTAUpdateInProgress == true)
{
return ESP_ERR_INVALID_STATE;
}
esp_err_t err = esp_ota_set_boot_partition(mOTAUpdatePartition);
if (err != ESP_OK)


This comment was generated by todo based on a TODO comment in d42865d in #11321. cc @project-chip.

@todo
Copy link

todo bot commented Nov 2, 2021

Handle applying update after reboot

// TODO: Handle applying update after reboot
esp_err_t OTAUpdater::Apply(uint32_t delayedActionTime)
{
if (mOTAUpdateInProgress == true)
{
return ESP_ERR_INVALID_STATE;
}
esp_err_t err = esp_ota_set_boot_partition(mOTAUpdatePartition);
if (err != ESP_OK)
{


This comment was generated by todo based on a TODO comment in d42865d in #11321. cc @project-chip.

@todo
Copy link

todo bot commented Nov 2, 2021

With this approach we might end up adding callback for every bdx event/message.

// TODO: With this approach we might end up adding callback for every bdx event/message.
// Can be refactored into a single callback with events
struct BdxDownloaderCallbacks
{
chip::Callback::Callback<OnBdxBlockReceived> * onBlockReceived = nullptr;
chip::Callback::Callback<OnBdxTransferComplete> * onTransferComplete = nullptr;
chip::Callback::Callback<OnBdxTransferFailed> * onTransferFailed = nullptr;
};
class BdxDownloader : public chip::bdx::Initiator
{


This comment was generated by todo based on a TODO comment in d42865d in #11321. cc @project-chip.

@restyled-io restyled-io bot closed this Nov 2, 2021
@restyled-io restyled-io bot deleted the restyled/task/esp32_ota_apps branch November 2, 2021 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants