TA的每日心情 | 开心 2020-2-14 12:16 |
---|
签到天数: 827 天 连续签到: 1 天 [LV.10]以坛为家III
|
接上一篇帖子https://www.cirmall.com/bbs/thread-48019-1-1.html
关于WINC 1500工程发出的一个问题,一直没有解决,各位前辈帮忙看一下请问atmel_iot_gateway工程路径 - AVR系列专区 - Atmel技术社区 http://atmel.eefocus.com/module/forum/thread-6607-1-1.html参考官网教程,使用“WINC1500_IOT_CLOUD_DEMO1”工程实例,程序介绍如下
无线部分相关定义- #define MAIN_WLAN_SSID "DEMO_AP"
- * #define MAIN_WLAN_AUTH M2M_WIFI_SEC_WPA_PSK
- * #define MAIN_WLAN_PSK "12345678"
复制代码- -- WINC1500 AP scan example --
- * -- SAM_XPLAINED_PRO --
- * -- Compiled: xxx xx xxxx xx:xx:xx --
- *
- * [1] SSID:DEMO_AP1
- * [2] SSID:DEMO_AP2
- * [3] SSID:DEMO_AP
- * Found DEMO_AP
- * Wi-Fi connected
- * Wi-Fi IP is xxx.xxx.xxx.xxx
复制代码 返回wifi信息并更新,switch-case语句- static void wifi_cb(uint8_t u8MsgType, void *pvMsg)
- {
- switch (u8MsgType) {
- case M2M_WIFI_RESP_SCAN_DONE:
- {
- tstrM2mScanDone *pstrInfo = (tstrM2mScanDone *)pvMsg;
- scan_request_index = 0;
- if (pstrInfo->u8NumofCh >= 1) {
- m2m_wifi_req_scan_result(scan_request_index);
- scan_request_index++;
- } else {
- m2m_wifi_request_scan(M2M_WIFI_CH_ALL);
- }
- break;
- }
复制代码- case M2M_WIFI_RESP_SCAN_RESULT:
- {
- tstrM2mWifiscanResult *pstrScanResult = (tstrM2mWifiscanResult *)pvMsg;
- uint16_t demo_ssid_len;
- uint16_t scan_ssid_len = strlen((const char *)pstrScanResult->au8SSID);
- /* display founded AP. */
- printf("[%d] SSID:%s\r\n", scan_request_index, pstrScanResult->au8SSID);
- num_founded_ap = m2m_wifi_get_num_ap_found();
- if (scan_ssid_len) {
- /* check same SSID. */
- demo_ssid_len = strlen((const char *)MAIN_WLAN_SSID);
- if
- (
- (demo_ssid_len == scan_ssid_len) &&
- (!memcmp(pstrScanResult->au8SSID, (uint8_t *)MAIN_WLAN_SSID, demo_ssid_len))
- ) {
- /* A scan result matches an entry in the preferred AP List.
- * Initiate a connection request.
- */
- printf("Found %s \r\n", MAIN_WLAN_SSID);
- m2m_wifi_connect((char *)MAIN_WLAN_SSID,
- sizeof(MAIN_WLAN_SSID),
- MAIN_WLAN_AUTH,
- (void *)MAIN_WLAN_PSK,
- M2M_WIFI_CH_ALL);
- break;
- }
- }
- if (scan_request_index < num_founded_ap) {
- m2m_wifi_req_scan_result(scan_request_index);
- scan_request_index++;
- } else {
- printf("can not find AP %s\r\n", MAIN_WLAN_SSID);
- m2m_wifi_request_scan(M2M_WIFI_CH_ALL);
- }
- break;
- }
- case M2M_WIFI_RESP_CON_STATE_CHANGED:
- {
- tstrM2mWifiStateChanged *pstrWifiState = (tstrM2mWifiStateChanged *)pvMsg;
- if (pstrWifiState->u8CurrState == M2M_WIFI_CONNECTED) {
- m2m_wifi_request_dhcp_client();
- } else if (pstrWifiState->u8CurrState == M2M_WIFI_DISCONNECTED) {
- printf("Wi-Fi disconnected\r\n");
- /* Request scan. */
- m2m_wifi_request_scan(M2M_WIFI_CH_ALL);
- }
- break;
- }
- case M2M_WIFI_REQ_DHCP_CONF:
- {
- uint8_t *pu8IPAddress = (uint8_t *)pvMsg;
- printf("Wi-Fi connected\r\n");
- printf("Wi-Fi IP is %u.%u.%u.%u\r\n",
- pu8IPAddress[0], pu8IPAddress[1], pu8IPAddress[2], pu8IPAddress[3]);
- break;
- }
- default:
- {
- break;
- }
- }
- }
复制代码 主函数- int main(void)
- {
- tstrWifiInitParam param;
- int8_t ret;
- system_init();
- configure_console();
- printf(STRING_HEADER);
- nm_bsp_init();
- memset((uint8_t *)¶m, 0, sizeof(tstrWifiInitParam));
- param.pfAppWifiCb = wifi_cb;
- ret = m2m_wifi_init(¶m);
- if (M2M_SUCCESS != ret) {
- printf("main: m2m_wifi_init call error!(%d)\r\n", ret);
- while (1) {
- }
- }
- m2m_wifi_request_scan(M2M_WIFI_CH_ALL);
- while (1) {
- while (m2m_wifi_handle_events(NULL) != M2M_SUCCESS) {
- }
- }
- return 0;
- }
复制代码 在串口助手里面看到如下
目前还没找到WINC1500的头文件,需要修改相应的SSID和密码,才可以手机连接,实现京东物联
|
|