GithubHelp home page GithubHelp logo

esp32-ota-server's Introduction

ESP-IDF OTA server component

A component for ESP-IDF that adds OTA capability for your project easily.

See also: https://github.com/yanbe/esp-idf-ota-template

Usage

This repository is served as a "component" for ESP-IDF project so you can add OTA capability to your existing project easily.

$ cd path/to/your/esp-idf-project
$ git remote add esp32-ota-server https://github.com/yanbe/esp32-ota-server.git
$ git subtree add --prefix components/ota_server esp32-ota-server master --squash
$ make menuconfig

In make menuconfig,

  • In Partition Table: select "Factory app, two OTA definitions"
  • In Wifi Configuration section: set your Wifi access point's SSID / password

Integrate OTA capability to your project

You have to add small portion of code to integrate OTA capability to your project.

OTA server have to started after ESP32 joined to WiFi network. So you have to implement event handler (if not yet) and then emit CONNECTED_BIT event which ota_server_task waits for.

In your main/main.c,

#include "ota_server.h"

static EventGroupHandle_t wifi_event_group;

static const int CONNECTED_BIT = BIT0;

static esp_err_t event_handler(void *ctx, system_event_t *event)
{
    switch(event->event_id) {
    /* ... */
    case SYSTEM_EVENT_STA_GOT_IP:
        xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
        break;
    /* ... */
    }
    return ESP_OK;
}

static void initialise_wifi(void)
{
/* snip. wifi initialization code... */
}


static void ota_server_task(void * param)
{
    xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, false, true, portMAX_DELAY);
    ota_server_start();
    vTaskDelete(NULL);
}


void app_main() {
    initialise_wifi();
    xTaskCreate(&ota_server_task, "ota_server_task", 4096, NULL, 5, NULL);
}

Inital flashing and OTA

To enable OTA capability, your have to configure partition table and flash your code via UART once.

$ make erase_flash flash

Then, via serial output, confirm which IP address is assigned to a ESP32. It should be something like below.

$ make monitor
...
I (4086) event: ip: 192.168.10.10, mask: 255.255.255.0, gw: 192.168.10.1

After that, you can use flashing capability via special make target.

$ cp components/ota-server/Makefile.example Makefile # For additional make target "ota"
$ make ota ESP32_IP=192.168.10.10
200 OK

Success. Next boot partition is ota_0

Modifing and Updating OTA server component

As components/ota_server is introduced as via git subtree command, your can modify components/ota_server and commit it as your project's seamlessly,

If you want to merge any changes have made to https://github.com/yanbe/esp32-ota-server , you can merge them into your project by following command.

$ git pull -s subtree --squash --allow-unrelated-histories esp32-ota-server master

esp32-ota-server's People

Contributors

yanbe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

esp32-ota-server's Issues

Porting to esp-idf 4.0

Hi,

I am porting my code that uses this functionality from esp-idf 3.3.2 to esp-idf 4.0
I need help with the necessary updates from Makefile to CmakeLists.txt of the following code

ota: app curl ${ESP32_IP}:8032 --data-binary @- < build/$(PROJECT_NAME).bin

Thanks for help extended.

Regards
Deepak

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.