raburton / rboot-sample

Sample ESP 8266 SDK project demonstrating rBoot OTA
MIT License
23 stars 11 forks source link

Define your own host and port by command. #3

Open fvpalha opened 8 years ago

fvpalha commented 8 years ago

Hi @raburton

With this tiny change is possible define the host and the port of server.

A sample code:

void config_cmd_ota(uint8_t argc, char *argv[]) {
    char msg[50];
    char *val;
    char *host = argv[1], *port = argv[2];

    if (argc == 0) {
        val = "192.168.1.107";
        setOtaHostIp (val);
        setOtaHostPort (80);
    } else if (argc == 1) {
        setOtaHostIp (host);
        setOtaHostPort (80);
    } else if (argc == 2) {
        setOtaHostIp (host);
        setOtaHostPort (atoi(port));
    }

    //disable global interrupt
    ETS_GPIO_INTR_DISABLE();
    // start the upgrade process
    if (rboot_ota_start((ota_callback)OtaUpdate_CallBack)) {
        os_sprintf(msg, "Updating...");
    } else {
        os_sprintf(msg, "Updating failed!");
    }
    uart0_send(msg);
}
fvpalha commented 8 years ago

How to change the OTA Server by command