a (probably incorrect) interpretation of writing firmware
This commit is contained in:
parent
0617cc3bf6
commit
9168f1b98c
@ -253,6 +253,43 @@ void Widget::setTxRate(uint8_t rate)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Widget::writeFirmware
|
||||
* @param data
|
||||
* @param size
|
||||
* @return
|
||||
*/
|
||||
bool Widget::writeFirmware(const uint8_t *data, const size_t size)
|
||||
{
|
||||
/**
|
||||
* While the API documents the message formats, there is little discussion of the
|
||||
* implimentation for updating firmware. As such, do nothing and return false.
|
||||
*/
|
||||
return false;
|
||||
|
||||
// reboot the device into the fw loader
|
||||
rebootBootloader();
|
||||
|
||||
auto msg = std::make_shared<Pro::MsgProgramFlashPageRequest>();
|
||||
std::future<bool> ftr;
|
||||
bool success;
|
||||
for (uint i = 0; i < size / sizeof(msg->page);)
|
||||
{
|
||||
{
|
||||
std::scoped_lock lock(mtx_metadata_);
|
||||
reply_firmwarePage_ = std::promise<bool>(); // expect a reply to this message
|
||||
ftr = reply_firmwarePage_.get_future();
|
||||
}
|
||||
std::copy(data + (i*sizeof(msg->page)), data + ((i+1)*sizeof(msg->page)), msg->page);
|
||||
sendMessage(msg);
|
||||
success = ftr.get();
|
||||
if (success)
|
||||
i++; // page write was successful, do the next.
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Widget::routeRxMessage
|
||||
* @param msg
|
||||
@ -528,7 +565,7 @@ void Widget::rxMsgProgramFlashPageRequest(std::shared_ptr<Pro::MsgProgramFlashPa
|
||||
*/
|
||||
void Widget::rxMsgProgramFlashPageReply(std::shared_ptr<Pro::MsgProgramFlashPageReply> msg)
|
||||
{
|
||||
(void)msg;
|
||||
reply_firmwarePage_.set_value(msg->success);
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,6 +72,7 @@ public:
|
||||
uint8_t txRate() const;
|
||||
void setTxRate(uint8_t);
|
||||
|
||||
bool writeFirmware(const uint8_t *, const size_t);
|
||||
|
||||
protected:
|
||||
void routeRxMessage(std::shared_ptr<Pro::MessageData>);
|
||||
@ -124,6 +125,7 @@ private:
|
||||
|
||||
mutable std::mutex mtx_metadata_;
|
||||
std::shared_ptr<void> token_data_changed_;
|
||||
std::promise<bool> reply_firmwarePage_;
|
||||
std::promise<bool> reply_parameters_;
|
||||
std::promise<bool> reply_serialNumber_;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user