예제 #1
0
static void key_ps_func(void *arg)
{
	#if 0
    uint32_t level;
    uint64_t diff;

    hal_gpio_input_get(&gpio_key_ps, &level);

    if (level == 0) {
        aos_post_delayed_action(10, key_ps_func, NULL);
    } else {
        diff = aos_now_ms() - ps_time;
		if (diff > 40) {
            ps_time = 0;
            aos_post_event(EV_KEY, CODE_BOOT, VALUE_KEY_PSCLICK);
            
        }else if (diff > 2000) { /* short press */
            elink_time = 0;
            aos_post_event(EV_KEY, CODE_BOOT, VALUE_KEY_LPSCLICK);
        } else {
            aos_post_delayed_action(10, key_ps_func, NULL);
        }
    }
	#endif
}
예제 #2
0
static void auto_active_handler(input_event_t *event, void *priv_data)
{
    if (auto_netmgr == false) return;
    if (event->type != EV_YUNIO) return;
    if (event->code != CODE_YUNIO_ON_CONNECTED) return;
    aos_post_delayed_action(ACTIVE_DELAY, do_auto_active, NULL);
}
예제 #3
0
int application_start(int argc, char *argv[])
{
    aos_post_delayed_action(1000, app_delayed_action, NULL);
    aos_loop_run();

    return 0;
}
예제 #4
0
파일: blink.c 프로젝트: wosayttn/aos
int application_start(int argc, char *argv[])
{
    /* gpio port config */
    led.port = GPIO_LED_IO;
    /* set as output mode */
    led.config = OUTPUT_PUSH_PULL;
    /* configure GPIO with the given settings */
    hal_gpio_init(&led);

    /* gpio port config */
    trigger.port = GPIO_TRIGGER_IO;
    /* set as output mode */
    trigger.config = OUTPUT_PUSH_PULL;
    /* configure GPIO with the given settings */
    hal_gpio_init(&trigger);

    /* input pin config */
    input.port = GPIO_INPUT_IO;
    /* set as interrupt mode */
    input.config = IRQ_MODE;
    /* configure GPIO with the given settings */
    hal_gpio_init(&input);

    /* gpio interrupt config */
    hal_gpio_enable_irq(&input, IRQ_TRIGGER_BOTH_EDGES, gpio_isr_handler, (void *) GPIO_INPUT_IO);

    aos_post_delayed_action(1000, app_trigger_low_action, NULL);
    aos_loop_run();

    return 0;
}
예제 #5
0
/*
 * Subscribe the topic: IOT_MQTT_Subscribe(pclient, TOPIC_DATA, IOTX_MQTT_QOS1, _demo_message_arrive, NULL);
 * Publish the topic: IOT_MQTT_Publish(pclient, TOPIC_DATA, &topic_msg);
 */
static void mqtt_publish(void *pclient) {

    int rc = -1;

    if(is_subscribed == 0) {
        /* Subscribe the specific topic */
        rc = IOT_MQTT_Subscribe(pclient, TOPIC_DATA, IOTX_MQTT_QOS1, _demo_message_arrive, NULL);
        if (rc<0) {
            // IOT_MQTT_Destroy(&pclient);
             LOG("IOT_MQTT_Subscribe() failed, rc = %d", rc);
        }
        is_subscribed = 1;
        aos_schedule_call(ota_init, gpclient);
    }
    else{
        /* Initialize topic information */
        memset(&topic_msg, 0x0, sizeof(iotx_mqtt_topic_info_t));

        topic_msg.qos = IOTX_MQTT_QOS1;
        topic_msg.retain = 0;
        topic_msg.dup = 0;

        /* Generate topic message */
        int msg_len = snprintf(msg_pub, sizeof(msg_pub), "{\"attr_name\":\"temperature\", \"attr_value\":\"%d\"}", cnt);
        if (msg_len < 0) {
            LOG("Error occur! Exit program");
        }

        topic_msg.payload = (void *)msg_pub;
        topic_msg.payload_len = msg_len;

        rc = IOT_MQTT_Publish(pclient, TOPIC_DATA, &topic_msg);
        if (rc < 0) {
            LOG("error occur when publish");
        }
#ifdef MQTT_ID2_CRYPTO
        LOG("packet-id=%u, publish topic msg='0x%02x%02x%02x%02x'...",
                (uint32_t)rc,
                msg_pub[0], msg_pub[1], msg_pub[2], msg_pub[3]);
#else
        LOG("packet-id=%u, publish topic msg=%s", (uint32_t)rc, msg_pub);
#endif
    }
    cnt++;
    if(cnt < 200) {
        aos_post_delayed_action(3000, mqtt_publish, pclient);
    } else {

        IOT_MQTT_Unsubscribe(pclient, TOPIC_DATA);

        aos_msleep(200);

        IOT_MQTT_Destroy(&pclient);

        release_buff();

        is_subscribed = 0;
        cnt = 0;
    }
}
예제 #6
0
static void do_awss_reset()
{
    if (linkkit_started) {
        aos_task_new("reset", awss_report_reset, NULL, 2048);
    }
    netmgr_clear_ap_config();
    LOG("SSID cleared. Please reboot the system.\n");
    aos_post_delayed_action(1000, reboot_system, NULL);
}
예제 #7
0
파일: mqtt-example.c 프로젝트: wosayttn/aos
/*
 * Subscribe the topic: IOT_MQTT_Subscribe(pclient, TOPIC_DATA, IOTX_MQTT_QOS1, _demo_message_arrive, NULL);
 * Publish the topic: IOT_MQTT_Publish(pclient, TOPIC_DATA, &topic_msg);
 */
static void mqtt_work(void *parms)
{

    int rc = -1;

    if (is_subscribed == 0) {
        /* Subscribe the specific topic */
        rc = mqtt_subscribe(TOPIC_GET, mqtt_sub_callback, NULL);
        if (rc < 0) {
            // IOT_MQTT_Destroy(&pclient);
            LOG("IOT_MQTT_Subscribe() failed, rc = %d", rc);
        }
        is_subscribed = 1;
        aos_schedule_call(ota_init, NULL);
    }
#ifndef MQTT_PRESS_TEST
    else {
        /* Generate topic message */
        int msg_len = snprintf(msg_pub, sizeof(msg_pub), "{\"attr_name\":\"temperature\", \"attr_value\":\"%d\"}", cnt);
        if (msg_len < 0) {
            LOG("Error occur! Exit program");
        }
        rc = mqtt_publish(TOPIC_UPDATE, IOTX_MQTT_QOS1, msg_pub, msg_len);
        if (rc < 0) {
            LOG("error occur when publish");
        }

        LOG("packet-id=%u, publish topic msg=%s", (uint32_t)rc, msg_pub);
    }
    cnt++;
    if (cnt < 200) {
        aos_post_delayed_action(3000, mqtt_work, NULL);
    } else {
        aos_cancel_delayed_action(3000, mqtt_work, NULL);
        mqtt_unsubscribe(TOPIC_GET);
        aos_msleep(200);
        mqtt_deinit_instance();
        is_subscribed = 0;
        cnt = 0;
    }
#endif
}
예제 #8
0
파일: esp8266.c 프로젝트: wosayttn/aos
int esp8266_wifi_got_ip(const char *ssid, const char *psw)
{
    char rsp[LINE_LEN] = {0};

    int ret = netm_connect_to_ap(ssid, psw);

    if (ret < 0) {
        LOGE(TAG, "esp8266 config error try again");
        return ret;
    }

    ret = netm_get_local_ip(rsp, strlen(rsp));

    if (ret < 0) {
        LOGE(TAG, "esp8266 get ip error");
        return ret;
    }

    LOGD(TAG, "esp8266 got ip %s \r\n", rsp);
    /*delay 5 seconds to post got ip event*/
    aos_post_delayed_action(100, esp8266_get_ip_delayed_action, NULL);
    return 0;
}
예제 #9
0
static void wifi_service_event(input_event_t *event, void *priv_data)
{
    if (event->type != EV_WIFI) {
        return;
    }

    if (event->code != CODE_WIFI_ON_GOT_IP) {
        return;
    }

    netmgr_ap_config_t config;
    memset(&config, 0, sizeof(netmgr_ap_config_t));
    netmgr_get_ap_config(&config);
    LOG("wifi_service_event config.ssid %s", config.ssid);
    if (strcmp(config.ssid, "adha") == 0 || strcmp(config.ssid, "aha") == 0) {
        //clear_wifi_ssid();
        return;
    }

    if (awss_running) {
#ifdef AWSS_NEED_REBOOT
        aos_post_delayed_action(200, reboot_system, NULL);
        return;
#endif
    }
    if (!linkkit_started) {
#ifdef CONFIG_YWSS
        awss_success_notify();
#endif
        linkkit_app();
#ifdef CONFIG_YWSS
        awss_success_notify();
#endif
        linkkit_started = 1;
    }

}
예제 #10
0
static void app_delayed_action(void *arg)
{
    LOG("%s:%d %s\r\n", __func__, __LINE__, aos_task_name());
    aos_post_delayed_action(5000, app_delayed_action, NULL);
}
예제 #11
0
파일: blink.c 프로젝트: wosayttn/aos
static void app_trigger_high_action(void *arg)
{
    hal_gpio_output_high(&trigger);
    aos_post_delayed_action(1000, app_trigger_low_action, NULL);
}
예제 #12
0
파일: emwinapp.c 프로젝트: wosayttn/aos
static void app_delayed_action(void *arg)
{
	GUIDEMO_Main();
    LOG("helloworld %s:%d %s\r\n", __func__, __LINE__, aos_task_name());
    aos_post_delayed_action(5000, app_delayed_action, NULL);
}