ArduinoOTAServerBundle
, (*1)
The ArduinoOTAServerBundle provides a HTTP Server to manage OTA
for Arduino with ESP8266 wifi chip., (*2)
Documentation
This plugin is developer for Arduino core for ESP8266 WiFi chip. See section https://github.com/esp8266/Arduino/tree/master/doc/ota_updates#http-server, (*3)
Include in version 2:, (*4)
-
New 'Program' Entity, (*5)
-
New 'ArduinoOTAServerService' Service, (*6)
-
New concole commands, (*7)
Since v.1.2.0 compatible with [Arduino core for ESP32 WiFi chip] (https://github.com/espressif/arduino-esp32)., (*8)
For documentation, see:, (*9)
Resources/doc/
Installation
Step 1: Download the Bundle
Open a command console, enter your project directory and execute the
following command to download the latest stable version of this bundle:, (*10)
$ composer require uegmobile/arduino-ota-server-bundle
This command requires you to have Composer installed globally, as explained
in the installation chapter
_ of the Composer documentation., (*11)
Step 2: Enable the Bundle
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php
file of your project:, (*12)
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new UEGMobile\ArduinoOTAServerBundle\UEGMobileArduinoOTAServerBundle(),
);
// ...
}
// ...
}
Step 3: Register the Routes
Import the routing definition in routing.yml
:, (*13)
# app/config/routing.yml
UEGMobileArduinoOTAServerBundle:
resource: "@UEGMobileArduinoOTAServerBundle/Resources/config/routing.yml"
prefix: /aotaserver
Step 4: Update Database Model
Run doctrine commands to update your database model:, (*14)
$ php app/console doctrine:migrations:diff (Symonfy 2.*)
$ php bin/console doctrine:migrations:diff (Symonfy 3.*)
$ php app/console doctrine:migrations:migrate (Symonfy 2.*)
$ php bin/console doctrine:migrations:migrate (Symonfy 3.*)
IMPORTANT NOTE: Upgrades to v2.0.0 needs some tasks:, (*15)
- create and execute doctrine migrations.
- register one program (see register program console command)
- update devices and set program and mode (see update device console command)
NOTE: Upgrades to v1.2.0 from previous versions require run doctrine commands again., (*16)
Usage
Register programs with Symfony console commands
-
Register new program to be available in OTA server, (*17)
$ php bin/console aotaserver:register:program porgramName, (*18)
Example:, (*19)
$ php bin/console aotaserver:register:program "Program A"
Register Program "Program A" with id X done!
-
List all programs availables in OTA server, (*20)
$ php bin/console aotaserver:list:program, (*21)
Example:, (*22)
$ php bin/console aotaserver:list:program
+----+-----------------+------------------+------------------+------------------+
| Id | Binary Name | Alpha | Beta | Prod |
+----+-----------------+------------------+------------------+------------------+
| 1 | Program A | (none) | (none) | (none) |
+----+-----------------+------------------+------------------+------------------+
Register binaries with Symfony console commands
-
Register new binary to be available in OTA server, (*23)
$ php bin/console aotaserver:register:binary binaryName binaryVersion userAgent sdkVersion binaryPath, (*24)
Example:, (*25)
$ php bin/console aotaserver:register:binary binary.1.bin 1.0.0 ESP8266-http-Update '1.5.3(aec24ac9)' arduino.1.2.02.bin
Register arduino.1.2.02.bin done!
-
List all binaries availables in OTA server, (*26)
$ php bin/console aotaserver:list:binary, (*27)
Example:, (*28)
$ php bin/console aotaserver:list:binary
+----+--------------+---------------------+-----------------+
| Id | Binary Name | User-Agent | SDK Version |
+----+--------------+---------------------+-----------------+
| 1 | binary.1.bin | ESP8266-http-Update | 1.5.3(aec24ac9) |
+----+--------------+---------------------+-----------------+
Register device with Symfony console commands
-
Register new device to be available in OTA server, (*29)
$ php bin/console aotaserver:register:device mac programId mode, (*30)
Example:, (*31)
$ php bin/console aotaserver:register:device '5C:CF:7F:8C:54:12' 1 BETA
Register 5C:CF:7F:8C:54:12 with id X done!
-
List all devices availables in OTA server, (*32)
$ php bin/console aotaserver:list:device, (*33)
Example:, (*34)
$ php app/console aotaserver:list:device
+----+-------------------+--------+---------------+-------+
| Id | MAC Address | Active | Program | Mode |
+----+-------------------+--------+---------------+-------+
| 11 | 5C:CF:7F:8C:54:12 | N | 1 - Program A | BETA |
+----+-------------------+--------+---------------+-------+
Update device with Symfony console commands
-
Update configuration device and set Beta, Alpha or Prod Mode in OTA server, (*35)
$ php bin/console aotaserver:update:device deviceId programId mode active, (*36)
Example:, (*37)
$ php bin/console aotaserver:update:device 1 1 BETA
Updated 12:23:44:55:66 with id 1 done!
Update device with Symfony console commands
-
Update configuration device and set Beta, Alpha or Prod Mode in OTA server, (*38)
$ php bin/console aotaserver:update:device deviceId programId mode active, (*39)
Example:, (*40)
$ php bin/console aotaserver:update:device 1 1 BETA
Updated 12:23:44:55:66 with id 1 done!
Update program with Symfony console commands
-
Update name progam in OTA server, (*41)
$ php bin/console aotaserver:update:program programId name, (*42)
Example:, (*43)
$ php bin/console aotaserver:update:program 1 "New program name"
Updated New program name with id 1 done!
Control entities from a Service
The ArduinoOTAServerService is available from the container:, (*44)
$arduinoOTAServerService = $this->container->get('arduino_ota_server_service');
ArduinoOTAServerService public methods to get entities are:, (*45)
- public function getProgram(string $programId): ?OTAProgram
- public function getDevice(string $deviceId): ?OTADeviceMac
- public function getBinary(string $binaryId): ?OTABinary
ArduinoOTAServerService public methods to search entities are:, (*46)
- public function searchPrograms(string $programName = null, int $page = 1, int $limit = 10, array $sort = []): ?Pagerfanta
- public function searchDevices(string $deviceMAC = null, int $page = 1, int $limit = 10, array $sort = []): ?Pagerfanta
- public function searchBinaries(string $binaryName = null, string $binaryVersion = null, string $userAgent = null, string $sdkVersion = null, int $page = 1, int $limit = 10,array $sort = []): ?Pagerfanta
ArduinoOTAServerService public methods to register entities are:, (*47)
- public function registerProgram(string $programName): OTAProgram
- public function registerDevice(string $deviceMAC, OTAProgram $program, string $mode = OTADeviceMac::MODE_ALPHA): OTADeviceMAC
- public function registerBinary(string $binaryName, string $binaryVersion, string $userAgent, string $sdkVersion, $binaryFile): OTABinary
ArduinoOTAServerService public methods to update entities are:, (*48)
- public function updateProgram($programId, $programName = null, $binaryAlpha = null, $binaryBeta = null, $binaryProd = null): OTAProgram
- public function updateDevice($deviceId, OTAProgram $program = null, string $mode = OTADeviceMac::MODE_ALPHA, bool $active = null): OTADeviceMAC
ArduinoOTAServerService public method to get OTA binary is:, (*49)
- public function searchBinaryByMACAddress(string $MACAddress): ?OTABinary
See section https://github.com/esp8266/Arduino/blob/master/doc/ota_updates/readme.md#http-server, (*50)
void upgrade_firmware(){
Serial.println("upgrade_firmware...");
t_httpUpdate_return ret = ESPhttpUpdate.update(CLOUD_SERVER_IP,
CLOUD_SERVER_PORT,
"/app_dev.php/aotaserver/updateBinary",
FIRMWARE_VERSION);
switch(ret) {
case HTTP_UPDATE_FAILED:
Serial.println("[update] Update failed.");
break;
case HTTP_UPDATE_NO_UPDATES:
Serial.println("[update] Update no Update.");
break;
case HTTP_UPDATE_OK:
Serial.println("[update] Update ok."); // may not called we reboot the ESP
break;
}
Serial.println("upgrade_firmware...done! ");
}
License
This bundle is released under the MIT license., (*51)