Ejemplo n.º 1
0
static int cfg_prof_cmd(int argc, char* argv[])
{
    if (argc < 1)
    {
show_usage:
        printf("Usuage:   prof <init|save|commit|show>\n" );
        printf("Arguments:\n");
        printf("\tinit    reset factory default.\n");
        printf("\tsave    save config to flash.\n");
        printf("\tcommit  save config to flash and notify monitor thread.\n");
        printf("\tshow    list all availble config.\n");
        return -1;
    }

    if (!strcmp(argv[0],"init"))    //reset to default
        CFG_reset_default();
    else if (!strcmp(argv[0],"save"))
        CFG_save(0);
    else if (!strcmp(argv[0],"commit"))
        CFG_commit(0);
    else if (!strcmp(argv[0],"show"))    //show profile
    {
    	if (argc > 1)
    		cfg_show_prof(argv[1]);
    	else
    		cfg_show_prof(NULL);
    }
    else
        goto show_usage;

    return 0;
}
Ejemplo n.º 2
0
void ICACHE_FLASH_ATTR config_save(serverConnData *conn, uint8_t argc, char *argv[]){
    if (argc != 0)
        espbuffsentprintf(conn, "Usage: save\r\nUse help for more details\r\n");
    else {
        char *config;
        config = cJSON_PrintUnformatted(jconfig_root);
        CFG_save(config);
        os_free(config);
        espbuffsentstring(conn, "Config saved, please restart now.");
    }
    espbuffsentstring(conn, MSG_OK);
}