Merged in masayuki2009/nuttx.nuttx/gs2200m_with_dhcp (pull request #958)
gs2200m with dhcp * include/nuttx/wireless: Add GS2200M_IOC_IFREQ to gs2200m.h Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com> * drivers/wireless: Add GS2200M_IOC_IFREQ to gs2200m.c Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com> * configs/spresense/wifi: Enable NuttX's DHCP client instead of GS2200M's Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com> * configs/spresense: Add descriptions on wifi in README.txt Signed-off-by: Masayuki Ishikawa <Masayuki.Ishikawa@jp.sony.com> Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
parent
f2b96016ad
commit
4c9508fc50
@ -18,3 +18,75 @@ as the more advanced NuttX based SDK.
|
||||
|
||||
Refer to https://developer.sony.com/develop/spresense/ for further information
|
||||
about this board.
|
||||
|
||||
Configuration sub-directories
|
||||
-----------------------------
|
||||
|
||||
wifi
|
||||
|
||||
This is a configuration for Spresense + Wi-Fi addon (Telit GS2200M) module.
|
||||
With this configuration, (1) you can connect Spresense to an existing Wi-Fi
|
||||
access point (2.4GHz 802.11b/g/n are supported) or (2) you can make
|
||||
Spresense as a Wi-Fi access point. In both cases, you can login to the
|
||||
Spresense with telnet, also access to a webserver (NOTE: this case you need
|
||||
an extension board with microSDHC card)
|
||||
|
||||
(1) Station (STA) mode
|
||||
|
||||
To run the module in Station mode (i.e. to connect to an existing Wi-Fi
|
||||
access point), You need to specify SSID with passcode.
|
||||
|
||||
nsh> gs2200m ssid-to-connect passcode &
|
||||
|
||||
If the connection succeeded, IP address is statically assigned.
|
||||
|
||||
nsh> ifconfig
|
||||
eth0 Link encap:Ethernet HWaddr 3c:95:09:00:69:92 at UP
|
||||
inet addr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0
|
||||
|
||||
Then, you can run DHCP client (renew command) to obtain IP address as well
|
||||
as DNS server information. (NOTE: In current configuration, DHCP client on
|
||||
GS2200M is disabled. If you enable the internal DHCP client, you can not
|
||||
use DNS client on NuttX)
|
||||
|
||||
nsh> renew eth0 &
|
||||
renew [6:100]
|
||||
nsh> ifconfig
|
||||
eth0 Link encap:Ethernet HWaddr 3c:95:09:00:69:92 at UP
|
||||
inet addr:192.168.1.101 DRaddr:192.168.1.1 Mask:255.255.255.0
|
||||
|
||||
Now, you can run telnetd and webserver on Spresense.
|
||||
|
||||
nsh> telnetd &
|
||||
telnetd [7:100]
|
||||
nsh> webserver &
|
||||
webserver [9:100]
|
||||
nsh> Starting webserver
|
||||
|
||||
Also, you can run NTP client to adjust the RTC on Spresense. (NOTE: we
|
||||
assume your network can access to pool.ntp.org, otherwise, you can specify
|
||||
CONFIG_NETUTILS_NTPCLIENT_SERVER)
|
||||
|
||||
nsh> date
|
||||
Jan 01 00:00:36 1970
|
||||
nsh> ntpcstart
|
||||
Started the NTP daemon as PID=11
|
||||
nsh> date
|
||||
Jul 30 06:42:13 2019
|
||||
|
||||
(2) Acess Point (AP) mode
|
||||
|
||||
To run the module in AP mode, you need to specify SSID to advertise and
|
||||
WEP-key. (NOTE: in AP mode, you can also specify channel number to use)
|
||||
|
||||
nsh> gs2200m -a ssid-to-advertise 10-hex-digits-wep-key &
|
||||
|
||||
If the module was initialized in AP mode, you can see a new IP address is
|
||||
assigned.
|
||||
|
||||
nsh> ifconfig
|
||||
eth0 Link encap:Ethernet HWaddr 3c:95:09:00:69:93 at UP
|
||||
inet addr:192.168.11.1 DRaddr:192.168.11.1 Mask:255.255.255.0
|
||||
|
||||
Now you can connect your PC to the AP with the above SSID and WEP-key
|
||||
which you specified.
|
||||
|
@ -61,10 +61,10 @@ CONFIG_NETUTILS_CODECS=y
|
||||
CONFIG_NETUTILS_FTPC=y
|
||||
CONFIG_NETUTILS_HTTPD_DIRLIST=y
|
||||
CONFIG_NETUTILS_HTTPD_SENDFILE=y
|
||||
CONFIG_NETUTILS_NTPCLIENT_SERVER="133.243.238.243"
|
||||
CONFIG_NETUTILS_TELNETD=y
|
||||
CONFIG_NETUTILS_WEBCLIENT=y
|
||||
CONFIG_NETUTILS_WEBSERVER=y
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NET_ICMP=y
|
||||
CONFIG_NET_LOCAL=y
|
||||
CONFIG_NET_TCP_NO_STACK=y
|
||||
@ -101,6 +101,7 @@ CONFIG_START_DAY=16
|
||||
CONFIG_START_MONTH=7
|
||||
CONFIG_START_YEAR=2019
|
||||
CONFIG_SYSLOG_TIMESTAMP=y
|
||||
CONFIG_SYSTEM_DHCPC_RENEW=y
|
||||
CONFIG_SYSTEM_NSH=y
|
||||
CONFIG_SYSTEM_NSH_CXXINITIALIZE=y
|
||||
CONFIG_SYSTEM_NTPC=y
|
||||
@ -115,4 +116,5 @@ CONFIG_USBMSC_REMOVABLE=y
|
||||
CONFIG_USER_ENTRYPOINT="spresense_main"
|
||||
CONFIG_WIRELESS_GS2200M=y
|
||||
CONFIG_WL_GS2200M=y
|
||||
CONFIG_WL_GS2200M_DISABLE_DHCPC=y
|
||||
CONFIG_WL_GS2200M_SPI_FREQUENCY=10000000
|
||||
|
@ -1538,10 +1538,6 @@ static enum pkt_type_e gs2200m_enable_dhcpc(FAR struct gs2200m_dev_s *dev,
|
||||
{
|
||||
char cmd[16];
|
||||
|
||||
#ifdef CONFIG_WL_GS2200M_DISABLE_DHCPC
|
||||
on = 0;
|
||||
#endif
|
||||
|
||||
snprintf(cmd, sizeof(cmd), "AT+NDHCP=%d\r\n", on);
|
||||
return gs2200m_send_cmd(dev, cmd, NULL);
|
||||
}
|
||||
@ -2308,10 +2304,26 @@ static int gs2200m_ioctl_assoc_sta(FAR struct gs2200m_dev_s *dev,
|
||||
t = gs2200m_set_opmode(dev, 0);
|
||||
ASSERT(TYPE_OK == t);
|
||||
|
||||
#ifdef CONFIG_WL_GS2200M_DISABLE_DHCPC
|
||||
/* Disable DHCP Client */
|
||||
|
||||
t = gs2200m_enable_dhcpc(dev, 0);
|
||||
ASSERT(TYPE_OK == t);
|
||||
|
||||
|
||||
/* Set static address */
|
||||
t = gs2200m_set_addresses(dev,
|
||||
"10.0.0.2",
|
||||
"255.255.255.0",
|
||||
"10.0.0.1"
|
||||
);
|
||||
ASSERT(TYPE_OK == t);
|
||||
#else
|
||||
/* Enable DHCP Client */
|
||||
|
||||
t = gs2200m_enable_dhcpc(dev, 1);
|
||||
ASSERT(TYPE_OK == t);
|
||||
#endif
|
||||
|
||||
/* Get mac address info */
|
||||
|
||||
@ -2405,6 +2417,67 @@ static int gs2200m_ioctl_assoc_ap(FAR struct gs2200m_dev_s *dev,
|
||||
return OK;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gs2200m_ifreq_ifreq
|
||||
****************************************************************************/
|
||||
|
||||
static int gs2200m_ioctl_ifreq(FAR struct gs2200m_dev_s *dev,
|
||||
FAR struct gs2200m_ifreq_msg *msg)
|
||||
{
|
||||
FAR struct sockaddr_in *inaddr;
|
||||
struct in_addr in[3];
|
||||
char addr[3][17];
|
||||
int ret = OK;
|
||||
|
||||
wlinfo("+++ start: cmd=%x \n", msg->cmd);
|
||||
|
||||
inaddr = (FAR struct sockaddr_in *)&msg->ifr.ifr_addr;
|
||||
|
||||
switch (msg->cmd)
|
||||
{
|
||||
case SIOCSIFADDR:
|
||||
memcpy(&dev->net_dev.d_ipaddr,
|
||||
&inaddr->sin_addr, sizeof(inaddr->sin_addr)
|
||||
);
|
||||
break;
|
||||
|
||||
case SIOCSIFDSTADDR:
|
||||
memcpy(&dev->net_dev.d_draddr,
|
||||
&inaddr->sin_addr, sizeof(inaddr->sin_addr)
|
||||
);
|
||||
break;
|
||||
|
||||
case SIOCSIFNETMASK:
|
||||
memcpy(&dev->net_dev.d_netmask,
|
||||
&inaddr->sin_addr, sizeof(inaddr->sin_addr)
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (OK == ret)
|
||||
{
|
||||
memcpy(&in[0], &dev->net_dev.d_ipaddr, sizeof(in[0]));
|
||||
memcpy(&in[1], &dev->net_dev.d_netmask, sizeof(in[1]));
|
||||
memcpy(&in[2], &dev->net_dev.d_draddr, sizeof(in[2]));
|
||||
strncpy(addr[0], inet_ntoa(in[0]), sizeof(addr[0]));
|
||||
strncpy(addr[1], inet_ntoa(in[1]), sizeof(addr[1]));
|
||||
strncpy(addr[2], inet_ntoa(in[2]), sizeof(addr[2]));
|
||||
|
||||
(void)gs2200m_set_addresses(dev,
|
||||
addr[0],
|
||||
addr[1],
|
||||
addr[2]
|
||||
);
|
||||
}
|
||||
|
||||
wlinfo("+++ end: \n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: gs2200m_ioctl
|
||||
****************************************************************************/
|
||||
@ -2502,6 +2575,15 @@ static int gs2200m_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
break;
|
||||
}
|
||||
|
||||
case GS2200M_IOC_IFREQ:
|
||||
{
|
||||
struct gs2200m_ifreq_msg *msg =
|
||||
(struct gs2200m_ifreq_msg *)arg;
|
||||
|
||||
ret = gs2200m_ioctl_ifreq(dev, msg);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ASSERT(false);
|
||||
}
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <stdint.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet/in.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/irq.h>
|
||||
@ -69,6 +70,9 @@ extern "C"
|
||||
#define GS2200M_IOC_BIND _WLCIOC(GS2200M_FIRST + 4)
|
||||
#define GS2200M_IOC_ACCEPT _WLCIOC(GS2200M_FIRST + 5)
|
||||
#define GS2200M_IOC_ASSOC _WLCIOC(GS2200M_FIRST + 6)
|
||||
#define GS2200M_IOC_IFREQ _WLCIOC(GS2200M_FIRST + 7)
|
||||
|
||||
/* NOTE: do not forget to update include/nuttx/wireless/ioctl.h */
|
||||
|
||||
struct gs2200m_connect_msg
|
||||
{
|
||||
@ -127,6 +131,12 @@ struct gs2200m_assoc_msg
|
||||
uint8_t ch;
|
||||
};
|
||||
|
||||
struct gs2200m_ifreq_msg
|
||||
{
|
||||
uint32_t cmd;
|
||||
struct ifreq ifr;
|
||||
};
|
||||
|
||||
struct gs2200m_lower_s
|
||||
{
|
||||
int (*attach)(xcpt_t handler, FAR void *arg);
|
||||
|
@ -100,7 +100,7 @@
|
||||
/* See include/nuttx/wireless/gs2200m.h */
|
||||
|
||||
#define GS2200M_FIRST (SX127X_FIRST + SX127X_NCMDS)
|
||||
#define GS2200M_NCMDS 7
|
||||
#define GS2200M_NCMDS 8
|
||||
|
||||
/************************************************************************************
|
||||
* Public Types
|
||||
|
Loading…
Reference in New Issue
Block a user