first init
This commit is contained in:
43
has_project/has_app/wifi/has_wifi.c
Normal file
43
has_project/has_app/wifi/has_wifi.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#include "has_platform.h"
|
||||
|
||||
|
||||
void msg_handle_cb(unsigned char module_id, const unsigned char *buf, unsigned int len)
|
||||
{
|
||||
printf("wifi msg handle\n");
|
||||
}
|
||||
|
||||
static OS_THREAD_ID wifi_tid;
|
||||
void *wifi_task(void *param)
|
||||
{
|
||||
uint8_t buffer[10] = {1, 2, 8};
|
||||
uint8_t data[2];
|
||||
data[0] = 0x5c;
|
||||
data[1] = 0x5d;
|
||||
/* 操作硬件 */
|
||||
if (has_dev_write(UART, 0, buffer, sizeof(buffer)) != 0) {
|
||||
printf("wifi task: write uart failed\n");
|
||||
}
|
||||
while (1)
|
||||
{
|
||||
/* 发布消息 */
|
||||
// has_msg_publish(WIFI, buffer, sizeof(buffer));
|
||||
/* 处理接收的消息 */
|
||||
has_msg_handle(WIFI, msg_handle_cb, 1000);
|
||||
has_msg_publish(WIFI, data, sizeof(data));
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int example_wifi_init(void)
|
||||
{
|
||||
printf("module:WIFI\n");
|
||||
// has_msg_printf_subscribe(WIFI);
|
||||
|
||||
/* 创建线程 */
|
||||
if (has_task_create("wifi", TASK_PRIORITY_NORMAL, 1024, wifi_task, NULL, &wifi_tid) != 0) {
|
||||
printf("module:WIFI create task failed\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
HAS_DECLARE_MODULE(WIFI, example_wifi_init)
|
||||
Reference in New Issue
Block a user