| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #include <rtthread.h>
- #include <wlan_mgnt.h>
- #include <wifi_config.h>
- #include <webclient.h>
- #include <ntp_client.h>
- #include <wayz_pos.h>
- #ifdef PKG_WAYZ_IOTKIT_WIFI_SSID
- #define WAYZ_WIFI_SSID PKG_WAYZ_IOTKIT_WIFI_SSID
- #else
- #define WAYZ_WIFI_SSID "thread"
- #endif
- #ifdef PKG_WAYZ_IOTKIT_WIFI_PASSWORD
- #define WAYZ_WIFI_PWD PKG_WAYZ_IOTKIT_WIFI_PASSWORD
- #else
- #define WAYZ_WIFI_PWD "12345678"
- #endif
- #define DEV_NAME "PANDDRA"
- #define VENDER "ALIENTEK"
- #define PRODUCT "FINDU01"
- #define SN "1234567"
- #define TENANT "WAYZ"
- #define POINT_FRQ 3000
- #define ACCESS_KEY "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" // 需要申请
- static void location_client_entry(void *parament)
- {
- char mac_addr[17] = {0};
- char ret = 0;
- get_sta_mac_addr(mac_addr);
- rt_kprintf("station mac : %s \r\n", mac_addr);
- twifi_info *wlan_info;
- tdeviec_info *dev_info;
- wlan_info = wifi_param_init(WAYZ_WIFI_SSID, WAYZ_WIFI_PWD);
- dev_info = dev_para_init(DEV_NAME, VENDER, PRODUCT, SN, TENANT);
- ret = dev_register_init(wlan_info, dev_info, ACCESS_KEY);
- if (ret != DEV_REGISTER_OK)
- {
- rt_kprintf("\033[31;22mdevice register failure. \033[0m\n");
- return ;
- }
- tlocation_info location = {0};
- ret = get_position_info(wlan_info, ACCESS_KEY, RT_NULL, &location);
- if (RT_ERROR == ret)
- {
- rt_kprintf("\033[31;22mthe device failed to obtain latitude and longitude information.\033[0m\n");
- }
- else
- {
- location_print(location);
- }
- while (1)
- {
- ret = get_position_info(wlan_info, ACCESS_KEY, RT_NULL, &location);
- if (RT_ERROR == ret)
- {
- rt_kprintf("\033[31;22mthe device failed to obtain latitude and longitude information.\033[0m\n");
- }
- else
- {
- location_print(location);
- }
- rt_thread_mdelay(POINT_FRQ);
- rt_memset(&location, 0, sizeof (location));
- }
- }
- int location_client_start(void)
- {
- rt_thread_t tid;
- tid = rt_thread_create("location_client", location_client_entry, RT_NULL, 6 * 1024, RT_THREAD_PRIORITY_MAX / 3 - 1, 5);
- if (tid)
- {
-
- rt_thread_startup(tid);
- return RT_EOK;
- }
- return -RT_ERROR;
- }
- #ifdef RT_USING_FINSH
- #include <finsh.h>
- FINSH_FUNCTION_EXPORT_ALIAS(location_client_start, location_test, location client test start);
- #ifdef FINSH_USING_MSH
- MSH_CMD_EXPORT_ALIAS(location_client_start, location_test, location client test start);
- #endif
- #endif
|