Example #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
}
Example #2
0
int application_start(int argc, char *argv[])
{
#if AOS_ATCMD
    at.set_mode(ASYN);
    at.init(AT_RECV_PREFIX, AT_RECV_SUCCESS_POSTFIX,
            AT_RECV_FAIL_POSTFIX, AT_SEND_DELIMITER, 1000);
#endif


#ifdef WITH_SAL
    sal_init();
#elif defined (CSP_LINUXHOST)
    aos_post_event(EV_WIFI, CODE_WIFI_ON_GOT_IP, 0u);
#endif

    aos_set_log_level(AOS_LL_DEBUG);

    aos_register_event_filter(EV_WIFI, wifi_service_event, NULL);

    netmgr_init();
    netmgr_start(false);

    aos_cli_register_command(&mqttcmd);

    aos_loop_run();
    return 0;
}
Example #3
0
static void ota_init(void *pclient)
{
    ota_device_info.product_key=PRODUCT_KEY;
    ota_device_info.device_name=DEVICE_NAME;
    ota_device_info.pclient=pclient;
    aos_post_event(EV_SYS, CODE_SYS_ON_START_FOTA, (long unsigned int)&ota_device_info);
}
Example #4
0
static void alink_service_event(input_event_t *event, void *priv_data) {
#ifndef AOS_AT_ADAPTER
    if (event->type != EV_WIFI) {
#else
    if (event->type != EV_AT) {
#endif
        return;
    }

#ifndef AOS_AT_ADAPTER
    if (event->code != CODE_WIFI_ON_GOT_IP) {
#else
    if (event->code != CODE_AT_IF_READY) {
#endif
        return;
    }

    if(is_alink_started == 0) {
        is_alink_started = 1;
        alink_start();
    }
}
typedef struct ota_device_info {
    const char *product_key;
    const char *device_name;
    const char *uuid;
} OTA_device_info_t;

OTA_device_info_t ota_device_info;

static void alink_connect_event(input_event_t *event, void *priv_data)
{
    if (event->type != EV_SYS) {
        return;
    }

    if (event->code == CODE_SYS_ON_ALINK_ONLINE ) {

#ifdef CONFIG_YWSS
        awss_registrar_init();
#endif
        ota_device_info.uuid = config_get_main_uuid();
        aos_post_event(EV_SYS, CODE_SYS_ON_START_FOTA, (long unsigned int)&ota_device_info);
        do_report();
        return;
    }
}
static int alink_cloud_report(const char *method, const char *json_buffer)
{
    return alink_report_async(method, json_buffer, NULL, NULL);
}

static void alink_cloud_connected(void) {
    aos_post_event(EV_YUNIO, CODE_YUNIO_ON_CONNECTED, 0);
    LOG("alink cloud connected!");

    aos_cloud_register_backend(&alink_cloud_report);
    aos_cloud_trigger(CLOUD_CONNECTED, NULL);
}

static void alink_cloud_disconnected(void) {
    aos_post_event(EV_YUNIO, CODE_YUNIO_ON_DISCONNECTED, 0);
    aos_cloud_trigger(CLOUD_DISCONNECTED, NULL);
}
Example #5
0
static void ota_init(void *P)
{
    aos_post_event(EV_SYS, CODE_SYS_ON_START_FOTA, 0u);
}
Example #6
0
static void esp8266_get_ip_delayed_action(void *arg)
{
    aos_post_event(EV_WIFI, CODE_WIFI_ON_GOT_IP, 0xdeaddead);
}
Example #7
0
static void smart_config_result_cb(int result, uint32_t ip)
{
    aos_post_event(EV_WIFI, CODE_WIFI_ON_GOT_IP, 0u);
}