Commit f3d01e48 authored by Daniil Kukushkin's avatar Daniil Kukushkin

Fixed stm ota start

parents 051c67b5 dd599c5e
......@@ -337,26 +337,34 @@ void MainController::sendLogMsg(const char* str, IPAddress* ipAddr = NULL)
}
void MainController::setLEDsColors(uint8_t forwardR, uint8_t forwardG, uint8_t forwardB, uint8_t backwardR, uint8_t backwardG, uint8_t backwardB)
{
setFrontLEDColor(forwardR, forwardG, forwardB);
setBackLEDColor(backwardR, backwardG, backwardB);
}
void MainController::setLEDsColors(Color forwardColor, Color backwardColor)
{
setLEDsColors(forwardColor.R, forwardColor.G, forwardColor.B, backwardColor.R, backwardColor.G, backwardColor.B);
}
void MainController::setFrontLEDColor(uint8_t forwardR, uint8_t forwardG, uint8_t forwardB)
{
LedColor fc;
fc.R = forwardR;
fc.G = forwardG;
fc.B = forwardB;
fc.mode = COLOR_NOT_SAVE_MODE;
setParam("FrontLed", fc.floatParamValue);
}
void MainController::setBackLEDColor(uint8_t backwardR, uint8_t backwardG, uint8_t backwardB)
{
LedColor bc;
bc.R = backwardR;
bc.G = backwardG;
bc.B = backwardB;
bc.mode = COLOR_NOT_SAVE_MODE;
//for(int i = 0; i < 5; i++) {
setParam("FrontLed", fc.floatParamValue);
setParam("BackLed", bc.floatParamValue);
//}
}
void MainController::setLEDsColors(Color forwardColor, Color backwardColor)
{
setLEDsColors(forwardColor.R, forwardColor.G, forwardColor.B, backwardColor.R, backwardColor.G, backwardColor.B);
}
void MainController::switchArmDisarm(bool armState)
......
......@@ -183,6 +183,9 @@ public:
void setLEDsColors(uint8_t forwardR, uint8_t forwardG, uint8_t forwardB, uint8_t backwardR, uint8_t backwardG, uint8_t backwardB);
void setLEDsColors(Color forwardColor, Color backwardColor);
void setFrontLEDColor(uint8_t forwardR, uint8_t forwardG, uint8_t forwardB);
void setBackLEDColor(uint8_t backwardR, uint8_t backwardG, uint8_t backwardB);
};
}
......
# NanoPix ESP firmware
This repo contain Arduino project with firmware for ESP8285 part of NanoPix.
\ No newline at end of file
This repo contain Arduino project with firmware for ESP8285 part of NanoPix.
Тулчейн:
- https://github.com/esp8266/Arduino [2.3.0]
- Arduino IDE [1.6.9/1.6.12, иначе плохо работает плата]
- https://github.com/me-no-dev/ESPAsyncUDP [master]
......@@ -41,6 +41,7 @@ void flightScript()
{
// здесь вы можете написать скрипт для Nanopix
}
void loop() {
mainController.mainRoutine();
......
......@@ -38,7 +38,7 @@
namespace NanopixCore {
#define ESP_SOFTWARE_VERSION 1.3
#define ESP_SOFTWARE_VERSION 1.4
#define ESP_SOFTWARE_VERSION_ID "esp_soft_vers"
class SettingsManager {
......
......@@ -47,6 +47,7 @@ bool STM_OTA_UDP_Receiver::start(int udp_local_port, int udp_remote_port)
_udp_local_port = udp_local_port;
_udp_remote_port = udp_remote_port;
_current_state = UploadFlash;
lastPacketTimestamp = 0;
}
bool STM_OTA_UDP_Receiver::restart()
......@@ -63,6 +64,7 @@ bool STM_OTA_UDP_Receiver::handle()
int packet_size = udp_ota.parsePacket();
if (packet_size)
{
lastPacketTimestamp = millis();
int len = udp_ota.read(_rx_buffer, RX_BUFFER_SIZE);
if (len == 1) // then it is command
{
......@@ -115,6 +117,7 @@ bool STM_OTA_UDP_Receiver::handle()
break;
case FinishUpdate:
STM32_OTA::finishUpdate();
lastPacketTimestamp = 0;
return true;
default:
break;
......@@ -151,11 +154,16 @@ bool STM_OTA_UDP_Receiver::handle()
}
}
}
else {
else
{
if (STM32_OTA::isOTA_Updating() == false)
break;
if(millis() - lastPacketTimestamp > RX_PACKET_TIMEOUT_MS)
break;
}
} // while true end
STM32_OTA::finishUpdate();
lastPacketTimestamp = 0;
return false;
}
......@@ -185,5 +193,6 @@ STM_OTA_UDP_Receiver::UpdateStates STM_OTA_UDP_Receiver::_current_state;
uint8_t STM_OTA_UDP_Receiver::_rx_buffer[RX_BUFFER_SIZE];
int STM_OTA_UDP_Receiver::_udp_remote_port;
int STM_OTA_UDP_Receiver::_udp_local_port;
unsigned long STM_OTA_UDP_Receiver::lastPacketTimestamp;
}
......@@ -37,6 +37,7 @@ SUCH DAMAGE.
namespace NanopixCore {
class STM_OTA_UDP_Receiver {
static const int RX_PACKET_TIMEOUT_MS = 2000;
public:
static bool start(int udp_local_port, int udp_remote_port);
static bool restart();
......@@ -52,6 +53,7 @@ private:
static UpdateStates _current_state;
static int _udp_remote_port, _udp_local_port;
static uint8_t _rx_buffer[RX_BUFFER_SIZE];
static unsigned long lastPacketTimestamp;
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment