When you construct Server application by using ARM CMSIS WIFI DRIVER
WizFi360 or ESP series, you will run into a problem.
I also did. I will share some nested problem and fixed code lines.
1. Client Connection (AT Notify)
ARM WiFi Driver receives AT Notification in case of a client connection from WIFI module.
Format: <link id>, CONNECT
2. Server Application
Above code runs well, if you make server application run. To make run server application, you have to use
static int32_t ARM_WIFI_SocketAccept (int32_t socket, uint8_t *ip, uint32_t *ip_len, uint16_t *port)
If it runs, ARM_WIFI_SocketAccept()
affects to the code "while (Socket[n].backlog != sock->backlog);" : refer to the below.
Below code handles client's AT Notification's CONNECT.
for (n = 0U; n < WIFI_SOCKET_NUM; n++) {
if (Socket[n].state == SOCKET_STATE_SERVER) {
/* Set pointer to server socket */
sock = &Socket[n];
do {
n = Socket[n].backlog;
if (Socket[n].state == SOCKET_STATE_LISTEN) {
/* Set connection id and change state */
Socket[n].conn_id = conn.link_id;
Socket[n].state = SOCKET_STATE_CONNECTED;
break;
}
}
while (Socket[n].backlog != sock->backlog);
break;
}
}
Because of ARM_WIFI_SocketAccept()'s wrong handling, 2nd ~ 4th Client's connections are Ignored after 1st Client is correctly connected.
So to Fix it, added socket index n++.
Then, ARM_WIFI_SocektAccept()
function affects Socketp[n].backlog. And Socketp[n].backlog affects <link id>, CONNECT such as link connection while loop. So Socket[n] (n >=2)'s state can not be update to SOCKET_STATE_CONNECTED
(refer to 1. Client Connection (AT Notify) ). It occured a nested problem.
So blocked it, refer to the blow.
3. Other Modifications are below: Modification for WizFi360
diff --git a/WiFi/WizFi360/WiFi_WizFi360.c b/WiFi/WizFi360/WiFi_WizFi360.c
index 714c233..9bdb09e 100644
--- a/WiFi/WizFi360/WiFi_WizFi360.c
+++ b/WiFi/WizFi360/WiFi_WizFi360.c
@@ -61,8 +76,11 @@
/* Number of supported simultaneus connections */
#define WIFI_SOCKET_NUM 5
+/*
+* Wizent: modified to reference for Server Application
+* Origin code: static WIFI_SOCKET Socket[WIFI_SOCKET_NUM]; */
/* Array of sockets */
-static WIFI_SOCKET Socket[WIFI_SOCKET_NUM];
+WIFI_SOCKET Socket[WIFI_SOCKET_NUM];
/* Driver control block */
static WIFI_CTRL WIFI_Ctrl;
@@ -365,14 +400,17 @@ void AT_Notify (uint32_t event, void *arg) {
else if (event == AT_NOTIFY_STATION_CONNECTED) {
/* Station connects to the local AP */
ex = AT_Resp_StaMac (mac);
+ //pCtrl->cb_event (ARM_WIFI_EVENT_AP_CONNECT, mac);
- pCtrl->cb_event (ARM_WIFI_EVENT_AP_CONNECT, mac);
}
else if (event == AT_NOTIFY_STATION_DISCONNECTED) {
/* Station disconnects from the local AP */
ex = AT_Resp_StaMac (mac);
-
- pCtrl->cb_event (ARM_WIFI_EVENT_AP_DISCONNECT, mac);
+ //pCtrl->cb_event (ARM_WIFI_EVENT_AP_DISCONNECT, mac);
}
else if (event == AT_NOTIFY_CONNECTED) {
/* Local station connected to an AP */
@@ -791,6 +829,7 @@ static int32_t ARM_WIFI_PowerControl (ARM_POWER_STATE state) {
if (ex == 0) {
/* Configure system messages */
ex = AT_Cmd_SysMessages (3U);
+ //Wiznet, AT+SYSMSG_CUR is Not now supported on WizF360
if (ex == 0) {
/* Wait until response arrives */
@@ -1773,7 +1812,8 @@ static int32_t ARM_WIFI_Activate (uint32_t interface, const ARM_WIFI_CONFIG_t *c
ap_cfg.ecn = config->security;
/* Optional parameters, set default values */
- ap_cfg.max_conn = 8; //Set maximum supported
+ //ap_cfg.max_conn = 8; //Set maximum supported
+ ap_cfg.max_conn = 4; //Wiznet, Set maximum supported, WizFi360 supports max. 4
ap_cfg.ssid_hide = 0; //(0:default)
ex = AT_Cmd_ConfigureAP (AT_CMODE_SET, &ap_cfg);
@@ -1781,7 +1821,9 @@ static int32_t ARM_WIFI_Activate (uint32_t interface, const ARM_WIFI_CONFIG_t *c
case 2:
/* Set access point MAC (must be different from station) */
- ex = AT_Cmd_AccessPointMAC (AT_CMODE_SET, pCtrl->options.ap_mac);
+ //Wiznet,
+ //No need to setup Mac addr, if you need it, you can do this
+ //ex = AT_Cmd_AccessPointMAC (AT_CMODE_SET, pCtrl->options.ap_mac);
break;
case 3:
diff --git a/WiFi/WizFi360/WiFi_WizFi360.h b/WiFi/WizFi360/WiFi_WizFi360.h
index ea0dc45..62d1b57 100644
--- a/WiFi/WizFi360/WiFi_WizFi360.h
+++ b/WiFi/WizFi360/WiFi_WizFi360.h
@@ -41,7 +41,8 @@
/* Connection open timeout [ms] (default) */
#ifndef WIFI_CONNOPEN_TIMEOUT
-#define WIFI_CONNOPEN_TIMEOUT (20000)
+//#define WIFI_CONNOPEN_TIMEOUT (20000) //Wiznet, modified
+#define WIFI_CONNOPEN_TIMEOUT (10000)
#endif
/* Socket accept timeout */
@@ -56,7 +57,9 @@
/* Access point default channel (used when channel not specified in Activate) */
#ifndef WIFI_AP_CHANNEL
-#define WIFI_AP_CHANNEL (2)
+//#define WIFI_AP_CHANNEL (2) //Wiznet, modified
+#define WIFI_AP_CHANNEL (1)
+
#endif
/* AT response echo enable/disable */
diff --git a/WiFi/WizFi360/WizFi360.c b/WiFi/WizFi360/WizFi360.c
index 270d1cb..b4c37d1 100644
--- a/WiFi/WizFi360/WizFi360.c
+++ b/WiFi/WizFi360/WizFi360.c
@@ -102,10 +102,14 @@ static STRING_LIST_t List_PlusResp[] = {
{ "CIPSERVERMAXCONN" },
{ "RST" },
{ "GMR" },
- { "LINK_CONN" },
+ //{ "LINK_CONN" }, //ESP Series
+ { "CONNECT" }, //WizFi360
{ "STA_CONNECTED" },
{ "STA_DISCONNECTED" },
{ "SLEEP" },
{ "E" },
{ "" }
};
@@ -142,10 +146,13 @@ typedef enum {
CMD_CIPSERVERMAXCONN,
CMD_RST,
CMD_GMR,
CMD_STA_CONNECTED,
CMD_STA_DISCONNECTED,
CMD_SLEEP,
+
+ CMD_RESTORE, //Wiznet: added WizFi360 Factory Reset
+
CMD_ECHO = 0xFD, /* Command Echo */
CMD_TEST = 0xFE, /* AT startup (empty command) */
CMD_UNKNOWN = 0xFF /* Unknown or unhandled command */
Comments
Please log in or sign up to comment.