0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00
};
+
+// WiFiͼ±ê 32*32
+const unsigned char pic_wifi_32x32[128] = { /* 0X00,0X01,0X20,0X00,0X20,0X00, */
+0X00,0X07,0XF0,0X00,0X00,0X3F,0XFE,0X00,0X00,0XFF,0XFF,0X00,0X03,0XFF,0XFF,0XC0,
+0X07,0XFF,0XFF,0XE0,0X0F,0XFF,0XFF,0XF8,0X3F,0XE0,0X0F,0XFC,0X7F,0X80,0X01,0XFE,
+0XFF,0X00,0X00,0XFF,0X7C,0X00,0X00,0X3E,0X38,0X00,0X00,0X1E,0X30,0X07,0XE0,0X0C,
+0X00,0X1F,0XF8,0X00,0X00,0X7F,0XFE,0X00,0X00,0XFF,0XFF,0X00,0X01,0XFF,0XFF,0X80,
+0X03,0XFF,0XFF,0XC0,0X03,0XF0,0X0F,0XC0,0X01,0XE0,0X07,0XC0,0X00,0X80,0X01,0X80,
+0X00,0X80,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0XC0,0X00,0X00,0X07,0XF0,0X00,
+0X00,0X1F,0XF8,0X00,0X00,0X0F,0XF0,0X00,0X00,0X07,0XF0,0X00,0X00,0X07,0XE0,0X00,
+0X00,0X03,0XC0,0X00,0X00,0X01,0XC0,0X00,0X00,0X01,0X80,0X00,0X00,0X00,0X00,0X00,
+};
+
+const unsigned char pic_wifi_err_32x32[128] = { /* 0X00,0X01,0X20,0X00,0X20,0X00, */
+0X00,0X07,0XF0,0X04,0X00,0X3F,0XFE,0X0E,0X00,0XFF,0XFF,0X1E,0X03,0XFF,0XFF,0XFC,
+0X07,0XFF,0XFF,0XF8,0X0F,0XFF,0XFF,0XF8,0X3F,0XE0,0X0F,0XFC,0X7F,0X80,0X03,0XFE,
+0XFF,0X00,0X07,0XFF,0X7C,0X00,0X0F,0X3E,0X38,0X00,0X1E,0X1E,0X30,0X07,0XFC,0X0C,
+0X00,0X1F,0XFC,0X00,0X00,0X7F,0XFE,0X00,0X00,0XFF,0XFF,0X00,0X01,0XFF,0XFF,0X80,
+0X03,0XFF,0XFF,0XC0,0X03,0XFF,0X0F,0XC0,0X01,0XFE,0X07,0XC0,0X00,0XFC,0X01,0X80,
+0X00,0XF8,0X00,0X00,0X00,0XF0,0X00,0X00,0X01,0XE3,0XC0,0X00,0X03,0XC7,0XF0,0X00,
+0X07,0X9F,0XF8,0X00,0X0F,0X0F,0XF0,0X00,0X1E,0X07,0XF0,0X00,0X3C,0X07,0XE0,0X00,
+0X38,0X03,0XC0,0X00,0X10,0X01,0XC0,0X00,0X00,0X01,0X80,0X00,0X00,0X00,0X00,0X00,
+};
#include "../FreeRTOS/include/FreeRTOS.h"
#include "../FreeRTOS/include/task.h"
+static int g_wifi_st = -1;
TaskHandle_t WifiTask_Handler = NULL;
TaskHandle_t AtTask_Handler = NULL;
+typedef struct{
+ uint8_t data;
+}wrench_server_t;
+
// ÃüÁî½âÎöÏà¹Ø¶¨Òå
typedef struct {
char mid[5]; // ÃüÁîID£¬ÈçRSVI¡¢RSTSµÈ
}
}
+void connect_handler(at_urc_ctx_t *ctx)
+{
+ int linkid;
+ printf("connect handler, ctx:%p\n", ctx);
+ if( sscanf( ctx->buf, "%d,CONNECT", &linkid ) == 1 ){
+ printf( "LINK:%d ---> CONNECT!\n", linkid );
+ g_wifi_st = 1;
+ }
+}
+
+void closed_handler(at_urc_ctx_t *ctx)
+{
+ int linkid;
+ printf("closed handler, ctx:%p\n", ctx);
+ if( sscanf( ctx->buf, "%d,CLOSED", &linkid ) == 1 ){
+ printf( "LINK:%d ---> CLOSED!\n", linkid );
+ g_wifi_st = 0;
+ }
+}
+
urc_item_t wifi_utc_tbl[]={
- {
+ { "+IPD", "\r\n", ipd_handler },
+ { "CONNECT", "\r\n", connect_handler },
+ { "CLOSED", "\r\n", closed_handler },
- "+IPD", "\r\n", ipd_handler
- },
};
return at_do_work(&wifi_at, (at_work)tcp_send_handler, &tx_data);
}
+int wifi_cipstate( at_obj_t *at )
+{
+ int ret = 0;
+ //AT+CIPSTATE?
+ //ÏìÓ¦£ºµ±ÓÐÁ¬½Óʱ£¬ AT ·µ»Ø£º
+ //+CIPSTATE:<link ID>,<"type">,<"remote IP">,<remote port>,<local port>,<tetype>
+ //OK
+ //µ±Ã»ÓÐÁ¬½Óʱ£¬ AT ·µ»Ø£º
+ //OK
+ //return 0: δÁ¬½Ó ´óÓÚ0: Á¬½ÓÊý -1: Ä£¿éͨÐŹÊÕÏ
+ //½ÓÊÕ»º³åÇø
+ char *p;
+ int linkid;
+ char recvbuf[256];
+ //ATÓ¦´ð
+ at_respond_t r = {"OK", NULL, sizeof(recvbuf), 3000};
+ r.recvbuf = recvbuf;
+ //
+ if (at_do_cmd(at, &r, "AT+CIPSTATE?") != AT_RET_OK){
+ ret = -1;
+ }else{
+ ret = 0;
+ p = strstr( recvbuf, "+CIPSTATE:");
+ while(p){
+ if( sscanf(p, "+CIPSTATE:%d", &linkid) == 1){
+ printf( "read wifi cipstate, linkid:%d\n", linkid );
+ ret++;
+ }
+ p = strstr( p+10, "+CIPSTATE:");
+ }
+ }
+ return ret;
+
+}
+
int wifi_init(at_obj_t *at )
{
//½ÓÊÕ»º³åÇø
else if (at_do_cmd(at, &r, "AT+CIPSERVER=1,8888") != AT_RET_OK)
return -1; //AT+CIPSERVER=1
+ g_wifi_st = 0;
printf( "wifi init ok\n" );
return 0;
}
size_t min_free_heap = xPortGetMinimumEverFreeHeapSize();
printf("FreeRTOS Heap Status - Free: %u bytes, Min Free: %u bytes\n",
(unsigned int)free_heap, (unsigned int)min_free_heap);
+
+ wifi_cipstate(&wifi_at); //check wifi connection status
}
vTaskDelay(10);
}
}
+
+int Get_Wifi_Status( void )
+{
+ return g_wifi_st;
+}