90 lines
1.6 KiB
C
90 lines
1.6 KiB
C
#include "app_config.h"
|
|
#include "system/includes.h"
|
|
#include "os/os_api.h"
|
|
|
|
#include "app_log.h"
|
|
#include "wifi_manager.h"
|
|
#include "audio_test.h"
|
|
#include "led.h"
|
|
#include "mqtt_config.h"
|
|
#include "mqtt_manager.h"
|
|
|
|
|
|
//#define WIFI_TEST_PASSWORD "12345678"
|
|
//#define WIFI_TEST_SSID "JLTEST24"
|
|
//#define WIFI_TEST_PASSWORD "12345678"
|
|
#define WIFI_TEST_SSID "超导体"
|
|
#define WIFI_TEST_PASSWORD "12345678"
|
|
/*
|
|
* MQTT测试回调
|
|
*
|
|
* 接收服务器下发消息
|
|
*/
|
|
static void mqtt_message_handler(const char *topic,
|
|
const uint8_t *payload,uint32_t len)
|
|
{
|
|
APP_LOG("\n======== MQTT RX ========\n");
|
|
APP_LOG("topic:%s\n", topic);
|
|
APP_LOG(
|
|
"payload:%.*s\n",
|
|
len,
|
|
payload
|
|
);
|
|
APP_LOG("=========================\n");
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
* wifi任务
|
|
*/
|
|
static void wifi_connect_task(void *arg)
|
|
{
|
|
int msg[4];
|
|
os_taskq_pend("taskq",msg,ARRAY_SIZE(msg));
|
|
const char *ssid = (const char *)msg[1];
|
|
const char *password = (const char *)msg[2];
|
|
APP_LOG("ssid=%s,password=%s\n",ssid,password);
|
|
wifi_manager_connect(ssid,password);
|
|
os_time_dly(1);
|
|
}
|
|
|
|
|
|
/*
|
|
* AC79入口
|
|
*/
|
|
void app_main(void)
|
|
{
|
|
int ret;
|
|
|
|
led_init();
|
|
APP_LOG("===START===\n");
|
|
wifi_manager_init();
|
|
|
|
//mqtt_manager_set_callback(mqtt_message_handler);
|
|
|
|
|
|
thread_fork
|
|
(
|
|
"wifi_connect_task",
|
|
9,
|
|
2048,
|
|
16,
|
|
NULL,
|
|
wifi_connect_task,
|
|
NULL
|
|
);
|
|
|
|
os_taskq_post(
|
|
"wifi_connect_task",
|
|
2,
|
|
(int)WIFI_TEST_SSID,
|
|
(int)WIFI_TEST_PASSWORD
|
|
);
|
|
mqtt_manager_init();
|
|
mqtt_manager_start();
|
|
|
|
|
|
|
|
} |