Example #1
0
static uint16_t hal_ota_get_crc16(void)
{
    int len = 2;
    uint16_t crc16=0;
    aos_kv_get(KV_HAL_OTA_CRC16, &crc16, &len);
    return crc16;
}
Example #2
0
static void handle_model_cmd(char *pwbuf, int blen, int argc, char **argv)
{
    #define MAX_MODEL_LENGTH 30
    char model[MAX_MODEL_LENGTH] = "light";
    int  model_len = sizeof(model);
    aos_kv_get("model", model, &model_len);

    if (argc == 1) {
        aos_cli_printf("Usage: model light/gateway. Model is currently %s\r\n", model);
        return;
    }

    if (strcmp(argv[1], "gateway") == 0) {
        if (strcmp(model, argv[1])) {
            aos_kv_del("alink");
            aos_kv_set("model", "gateway", sizeof("gateway"), 1);
            aos_cli_printf("Swith model to gateway, please reboot\r\n");
        } else {
            aos_cli_printf("Current model is already gateway\r\n");
        }
    } else {
        if (strcmp(model, argv[1])) {
            aos_kv_del("alink");
            aos_kv_set("model", "light", sizeof("light"), 1);
            aos_cli_printf("Swith model to light, please reboot\r\n");
        } else {
            aos_cli_printf("Current model is already light\r\n");
        }
    }
}
Example #3
0
static int get_hotspot_timeout()
{
    char timeout_s[10];
    int len = sizeof(timeout_s);
    int timeout;

    if (aos_kv_get(HOTSPOT_TIMEOUT_KV_NAME, (void *)timeout_s, &len) == 0) {
        LOG("hotspot_timeout KV value will be used: %s seconds", timeout_s);
        timeout = atoi(timeout_s);
    } else {
        timeout = AUTO_HOTSPOT_TIMEOUT_S;
        LOG("Default hotspot timeout (%s) will be used.", timeout);
    }

    return timeout * 1000; // s -> ms
}
Example #4
0
static bool get_auto_netmgr_config()
{
    char c[5];
    int len = sizeof(c);
    bool ret;

    if (aos_kv_get(AUTO_NETMGR_KEY, (void *)c, &len) != 0) {
        ret = false;
        LOGI("alink", "kv(%s) not set, auto_netmgr will be disabled",
          AUTO_NETMGR_KEY);
    } else {
        ret = true;
        LOGD("alink", "kv(%s) found, auto_netmgr will be enabled",
          AUTO_NETMGR_KEY);
    }

    return ret;
}
Example #5
0
int be_osal_kv_get(const char *key, void *buffer, int *buffer_len)
{
	return aos_kv_get(key, buffer, buffer_len);
}