RAK RAK411 Programming Manual

RAK RAK411 Programming Manual

Spi-wifi module

Advertisement

Quick Links

RAK411 SPI-WIFI Module
Programming Manual
Shenzhen Rakwireless Technology Co., Ltd
www.rakwireless.com info@rakwireless.com
V1.7
© 2015 Rakwireless all rights reserved.
Mentioned in this document , the actual company and product names,
trademarks are their respective owners.
After update the new version, this document without prior notice.
1
RAK411 PROGRAMMING MANUAL
SHENZHEN RAKWIRELESS TECHNOLOGY CO., LTD
V1.7
COPYRIGHT ©
ETDX1602191815

Advertisement

Table of Contents
loading

Summary of Contents for RAK RAK411

  • Page 1 RAK411 PROGRAMMING MANUAL V1.7 RAK411 SPI-WIFI Module Programming Manual V1.7 Shenzhen Rakwireless Technology Co., Ltd www.rakwireless.com info@rakwireless.com © 2015 Rakwireless all rights reserved. Mentioned in this document , the actual company and product names, trademarks are their respective owners. After update the new version, this document without prior notice.
  • Page 2: Table Of Contents

    RAK411 PROGRAMMING MANUAL V1.7 Content 1 Overview ............................1 1.1 Module Introduction ..........................1 1.2 Device Features ............................1 1.3 Key Applications ............................2 2 Functional Description ....................... 3 2.1 HW Interface .............................. 3 2.2 Wireless Driver ............................3 2.3 TCP/IP ................................3 2.4 Power Consumption ..........................
  • Page 3 RAK411 PROGRAMMING MANUAL V1.7 4.2.4 Setting Channel ........................... 23 4.2.5 Connecting Wireless Network ....................24 4.2.6 Configuring Static IP Address ....................25 4.2.7 Setting DHCP Mode ........................26 4.2.8 Connecting Network by Easyconfig ..................27 4.2.9 Connecting Network by WPS ....................28 4.2.10 Getting Network Connection Status ...................
  • Page 4: Overview

    1 Overview 1.1 Module Introduction RAK411 module is a Wi-Fi module that fully compliant with IEEE 802.11b/g/n wireless standards, with internally integrated TCP / IP protocol stack, supporting numerous protocols such as ARP, IP, ICMP, TCP, UDP, DHCP CLIENT, DHCP SERVER, DNS and other etc. It supports AP mode, Station mode and Ad-hoc and mode.
  • Page 5: Key Applications

    RAK411 PROGRAMMING MANUAL V1.7 On-board ceramic antenna or U.FL antenna connector  Operating voltage: 3.3V  4 kinds power working modes, with minimum power consumption as  1-2uA  Small package size: 28.75mmX23.14mmX3.40mm FCC, RoHS and CE compliant  1.3 Key Applications Portable products ...
  • Page 6: Functional Description

    RAK411 PROGRAMMING MANUAL V1.7 2 Functional Description 2.1 HW Interface Support clock 16MHz Maximum  Interface actual throughput up to 2Mbps  Four-wire SPI interface, support SPI data interrupt pin  2.2 Wireless Driver Compliant with IEEE 802.11b/g/n standards ...
  • Page 7: Spi Interface

    RAK411 PROGRAMMING MANUAL V1.7 3 SPI Interface RAK411 communicates with the host through a standard 4-wire SPI interface. SPI clock supports maximum 16MHZ and optional SPI-INT pin. The SPI interface configuration diagram is as follows: 3.1 Hardware Connection 3.2 SPI Timing Diagram...
  • Page 8: Interrupt Pin

    V1.7 3.3 Interrupt Pin RAK411 provides an optional INT pin, so that the host can quickly respond to module data requests via the INT pin. The normal INT pin is low level voltage, when there is abnormal data to be sent, the module pulls INT to high level. After the host receives the rising edge, the module can read the data by sending read frames directly.After reading a package, INT pin goes low.
  • Page 9: Read Status

    RAK411 PROGRAMMING MANUAL V1.7 3.4.2 Read Status Description: 1.The Host end loop sends the Head CMD to the module, and the sending process requires a query if there is received ACK (0x85) . 2.If received CMD then stop the current Head ACK send.
  • Page 10: Read Data

    RAK411 PROGRAMMING MANUAL V1.7 3.4.3 Read Data Description: 1.The Host end loop sends the Head CMD to the module, and the sending process requires a query if there is received ACK (0x85) . 2.If received CMD then stop the current Head ACK send.
  • Page 11: Write Data

    RAK411 PROGRAMMING MANUAL V1.7 3.4.4 Write Data Description: 1.The Host end loop sends the Head CMD to the module, and the sending process requires a query if there is received ACK (0x85) . 2.If received CMD then stop the current Head ACK send.
  • Page 12: Command Example

    RAK411 PROGRAMMING MANUAL V1.7 reference "4.2.1 scanning wireless network" and "4.1.2 query software version" command. 3.4.5 Command example Set the network channel command, channel set to 7 1.CMD to fill in the corresponding set channel command code 0xAB. 2.0x97 fixed.
  • Page 13 RAK411 PROGRAMMING MANUAL V1.7 COPYRIGHT © SHENZHEN RAKWIRELESS TECHNOLOGY CO., LTD ETDX1603021415...
  • Page 14 RAK411 PROGRAMMING MANUAL V1.7 Description: 1.The Host terminal loop sends the Head CMD to the module of the "set channel" command code 0xAB, sending process requires query whether received ACK (0x85). 2.If received CMD then stop the current Head ACK send.
  • Page 15: Status Register

    RAK411 PROGRAMMING MANUAL V1.7 3.4.6 Status Register Description: Here is the byte of status read, the last two bits representative the data type of module feedback. Bit7: SPI_STATUS Bit6: reserve Bit5: reserve Bit4: reserve Bit3: Send_full, Indicates that the module is unable to respond to the command...
  • Page 16: Boot

    RAK411 PROGRAMMING MANUAL V1.7 3.5 Boot RAK411’s reboot time is about 210ms. After a normal start, the host sends the initialization command, and the module will return start information: ASCII------- Welcome to RAK411 HEX-------- 57 65 6C 63 6F 6D 65 20 74 6F 20 52 41 4B 34 31 31 3.6 Power Mode...
  • Page 17: Operational Process

    3.7 Operational Process RAK411 SPI command operation feature completes a few basic steps of WIFI communication, including network scanning, joining network and obtaining an IP address, and eventually establishing Socket communication. RAK411 provides a variety of convenient operation to implement networking, so that customers can easily complete the network configuration, and concentrate on the management of socket and their own data protocols.
  • Page 18 RAK411 PROGRAMMING MANUAL V1.7 COPYRIGHT © SHENZHEN RAKWIRELESS TECHNOLOGY CO., LTD ETDX1603021415...
  • Page 19: At Command

    RAK411 PROGRAMMING MANUAL V1.7 4. AT Command The SPI commands are divided into four parts:module management commands, network operations commands, socket operation commands, and parameters storing commands, shown as the followings: Command Description Module Management Commands rak_sys_init Initialize module, read boot information...
  • Page 20: Module Management Commands

    RAK411 PROGRAMMING MANUAL V1.7 rak_socket_close Close an opened socket handle rak_get_tcps Gets the number and the information for the tcp sever to connect to client rak_send_data Send data to an opened socket handle rak_read_data Read command returns / network data /...
  • Page 21: Checking Software Version

    RAK411 PROGRAMMING MANUAL V1.7 4.1.2 Checking Software Version Command: rak_get_version Syntax: uint32_tcmd; Parameter: Parameter Bytes Value Description 0xBE,0x00,0x00,0x00 Command Code Parameter: It is used to check module versions, including versions of host and WLAN. Return Value: Parameter Bytes Value Description <CODE>...
  • Page 22: Reading Module Status

    RAK411 PROGRAMMING MANUAL V1.7 powermode 0--3 Power mode Parameter: It is used to set module power mode.Detailed reference “3.6 power mode ”. Return Value: N/A 4.1.4 Reading Module Status Command: rak_read_status Syntax: uint32_t cmd; Parameter: Parameter Bytes Value Description 0xA1,0x00,0x00,0x00...
  • Page 23: Module Firmware Upgrade

    RAK411 PROGRAMMING MANUAL V1.7 Syntax: uint32_t cmd; Parameter: Parameter Bytes Value Description 0xBF,0x00,0x00,0x00 Command Code Parameter: It is used to resets the entire module via command. Return Value: N/A 4.1.6 Module firmware upgrade Command: rak_reset_upgrade Syntax: typedef struct { uint32_t cmd;...
  • Page 24: Network Operation Commands

    RAK411 PROGRAMMING MANUAL V1.7 Description: Use the command to upgrade the module firmware. A firmware file is required to generate an array of bytes by means of the tool, and then load in the host code (approximately 500KByte). After the host code through this command array data packets are sent into the internal module.
  • Page 25: Getting Scanned Information

    RAK411 PROGRAMMING MANUAL V1.7 Parameter Bytes Value Description <CODE> 0xA3,0x00 Response Code <AP_NUM> 0x08,0x00 Scan to the number of wireless networks, up to 8 <STATUS> Command successful Command failed 4.2.2 Getting Scanned Information Command: rak_getscan Syntax: typedef struct { uint32_t cmd;...
  • Page 26: Setting Password

    RAK411 PROGRAMMING MANUAL V1.7 Length of SSID <SSID_LEN> SSID <SSID> BSSID <BSSID> Command successful <STATUS> Command failed 4.2.3 Setting Password Command: rak_set_psk Syntax: typedef struct { uint32_t cmd; char psk[64]; }rak_psk_t; Parameter: Parameter Bytes Value Description 0xA5,0x00,0x00,0x00 Command Code Network password Description: It is used to set network password.
  • Page 27: Connecting Wireless Network

    RAK411 PROGRAMMING MANUAL V1.7 uint32_t cmd; uint32_t channel; }rak_channel_t; Parameter: Parameter Bytes Value Description 0xAB,0x00,0x00,0x00 Command Code channel 0--13 SettingAP / Ad-Hoc channel Description: It is used to set network channel. Return Value: Parameter Bytes Value Description <CODE> 0xAB,0x00 Response Code <STATUS>...
  • Page 28: Configuring Static Ip Address

    RAK411 PROGRAMMING MANUAL V1.7 Description: It is used to connect an AP/ADHOC network or establish a specified AP Network. Return Value: Parameter Bytes Value Description <CODE> 0xA6,0x00 Response Code <STATUS> Command successful Cannot find the SSID Command failed 4.2.6 Configuring Static IP Address...
  • Page 29: Setting Dhcp Mode

    RAK411 PROGRAMMING MANUAL V1.7 Descriptionr: This command is used to assign static IP address for module. Return Value: Parameter Bytes Value Description <CODE> 0xAD,0x00 Response Code Command successful <STATUS> Command failed 4.2.7 Setting DHCP Mode Command: rak_ipconfig_dhcp Syntax: typedef struct { uint32_t cmd;...
  • Page 30: Connecting Network By Easyconfig

    RAK411 PROGRAMMING MANUAL V1.7 DHCP CLENT: Parameter Bytes Value Description <CODE> 0xAC,0x00 Response Code <MAC> MAC address <ADDR> IP address <MASK> Subnet mask <GW> Gateway <DNS1> DNS server 1 <DNS2> DNS server 2 <STATUS> Command successful Command failed Get ip information failure 4.2.8 Connecting Network by Easyconfig...
  • Page 31: Connecting Network By Wps

    RAK411 PROGRAMMING MANUAL V1.7 Return Value: Parameter Bytes Value Description <CODE> 0xC2, Response Code 0x00 <SSID> ASCII SSID <SEC_MO Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 DE> 802. Tkip ASCII Network password Command successful <STATUS cannot find the ap >...
  • Page 32: Getting Network Connection Status

    RAK411 PROGRAMMING MANUAL V1.7 Return Value: Parameter Bytes Value Description <CODE> 0xC3,0x00 Response Code <SSID> ASCII SSID SEC_MODE Bit7 Bit5 Bit4 Bit1 Bit0 802. Tkip ASCII Network password <STATUS> Command successful Cannot find AP Join the router failed Ip failed to get Wps failed 4.2.10 Getting Network Connection Status...
  • Page 33: Querying Module Ip Information

    RAK411 PROGRAMMING MANUAL V1.7 Return Value: Parameter Bytes Value Description <CODE> 0xA7,0x00 Response Code Command successful <STATUS> Command failed 4.2.11 Querying module IP information Command: rak_ipconfig_query Syntax: uint32_t cmd; Parameter: Parameter Bytes Value Description 0xAE,0x00,0x00,0x00 Command Code Description:: It is used to get module IP information, including MAC address, IP address, subnet mask, gateway, and DNS server.
  • Page 34: Getting Network Signal Strength

    RAK411 PROGRAMMING MANUAL V1.7 4.2.12 Getting Network Signal Strength Command: rak_get_rssi Syntax: uint32_t cmd; Parameter: Parameter Bytes Value Description 0xA9,0x00,0x00,0x00 Command Code Description: It is used to get the current signal strength of the network. Return Value: Parameter Bytes Value Description <CODE>...
  • Page 35: Ping

    RAK411 PROGRAMMING MANUAL V1.7 Description: It is used to convert domain to the corresponding IP address, the domain must be configured available DNS server. Return Value: Parameter Bytes Value Description <CODE> 0xAF,0x00 Response Code <ADDR> Ip address <STATUS> Command successful DNS resolution failure 4.2.14 PING...
  • Page 36: Ap Network Advanced Settings

    RAK411 PROGRAMMING MANUAL V1.7 <CODE> 0xB0,0x00 Response Code <STATUS> Command successful Cannot access host 4.2.15 AP Network Advanced Settings Command: rak_apconfig Syntax: Typedef struct { uint32_t cmd; uint8_t hidden; uint8_t countryCode[3]; }rak_apconfig_t; Parameter: Parameter Bytes Value Description 0xAA,0x00,0x00,0x00 Command Code...
  • Page 37: Setting Network Listening Intervals

    RAK411 PROGRAMMING MANUAL V1.7 4.2.16 Setting Network Listening Intervals Command: rak_set_listen Syntax: typedef struct { uint32_t cmd; uint32_t time; }rak_beacon_t; Parameter: Parameter Bytes Value Description 0xA8,0x00,0x00,0x00 Command Code time 20--1000 Need to refer to the wireless router settings for specific...
  • Page 38: Socket Operation Commands

    RAK411 PROGRAMMING MANUAL V1.7 rak_disconnect Syntax: uint32_t cmd; Parameter: Parameter Bytes Value Description 0xB7,0x00,0x00,0x00 Command Code Description: It is used to disconnect the current wireless network. Return Value: Parameter Bytes Value Description <CODE> 0xB7,0x00 Response Code <STATUS Command successful Current network is disconnected 4.3 Socket Operation Commands...
  • Page 39: Tcp Client

    RAK411 PROGRAMMING MANUAL V1.7 Description: Module as a TCP server and create a listening port, if the operation is successful, the module will return a hexadecimal identifier (Socket ID), is used to manage the connection. Establish a TCP server can connect up to seven clients. Establish a TCP server on a different port, allows you to create up to four.
  • Page 40: Udp Client

    RAK411 PROGRAMMING MANUAL V1.7 local_port 0-65535 Local port number Description: This command is to create a TCP CLIENT and connect with the remote TCP SERVER, if the operation is successful, the module will return a hexadecimal identifier that is used to manage the connection.
  • Page 41: Udp Server

    RAK411 PROGRAMMING MANUAL V1.7 dest_port 1-65535 Target port number local_port 0-65535 Local port number Description: This command is to create a UDP port on the module and set remote IP address and port number, if you create successful, the module will return a hexadecimal identifier that is used to manage the connection.
  • Page 42: Udp Multicast

    RAK411 PROGRAMMING MANUAL V1.7 Description: Returns a hexadecimal after this command is to create a UDP listening locally on the specified port, create success identifier (Socket ID), waiting to receive the remote port data. If the remote port to send data to this port, the received data will be included in each other's IP and port information;...
  • Page 43: Query Tcp Server Connections

    RAK411 PROGRAMMING MANUAL V1.7 Parameter Bytes Value Description 0xC4,0x00,0x00,0x00 Command code dest_addr 224.0.0.1-239.255.255.255 Target multicast address dest_port 1-65535 Target port number local_port 1-65535 Local port number Description: This command is to create a UDP multicast socket on the module, you can specify the multicast IP multicast, in the group for data communications.
  • Page 44: Closing Socket

    RAK411 PROGRAMMING MANUAL V1.7 0xCD,0x00,0x00,0x00 Command Code tcpsever_flag 8-11 Query corresponding TCP server Description: By identifier corresponding server, TCP server queries the number of client connections,and client information. Return Value: Parameter Bytes Value Description <CODE> 0xCD,0x00 Response Code The maximum number of connections <TCP_NUM>...
  • Page 45: Sending Data

    RAK411 PROGRAMMING MANUAL V1.7 Description: It is used to close the already opened socket identifier,Close port monitoring or connection. Return Value: Parameter Bytes Value Description <CODE> 0xB5,0x00 Response Code Command successful <STATUS> Specified port does not exist Disable to close 4.3.8 Sending Data...
  • Page 46: Receiving Data

    RAK411 PROGRAMMING MANUAL V1.7 Description: This command is used to send data to the target (port identifier), the maximum data length is 1400, buffer can be data in any format, module will send data without any treatment. If the connection is a TCP connection, then the destination IP and destination port can be omitted, entered with value 0.
  • Page 47 0xCC,0x00 Response Code <STATUS> Successful Note: RAK411 modules within the network to automatically connect, disconnect from the network will notify the host.After disconnecting the network module, the internal reconnection interval is:1s,2s , 4s,4s,4s,4s..COPYRIGHT © SHENZHEN RAKWIRELESS TECHNOLOGY CO., LTD...
  • Page 48: Save Parameters Commands

    RAK411 PROGRAMMING MANUAL V1.7 4.4 Save Parameters Commands 4.4.1 Storing Network Configuration Parameters Command: rak_storeconfig_data Syntax: typedef struct { uint32_t cmd uint32_t feature_bitmap; uint8_t net_type; uint8_t channel; uint8_t sec_mode; uint8_t dhcp_mode; char ssid[32]; char psk[64]; ip_param_t ip_param; ap_config_t ap_config; }config_t...
  • Page 49: Storing Current Network Parameters

    RAK411 PROGRAMMING MANUAL V1.7 dummy Null data ip_param IP parameters ap_config AP advanced parameters Description: It is used to save user parameters, including password, SSID, IP address, and scan information. Return Value: Parameter Bytes Value Description <CODE> 0xC0,0x00 Response Code Command successful <STATUS>...
  • Page 50: Modifying Web Parameters

    RAK411 PROGRAMMING MANUAL V1.7 4.4.3 Modifying Web Parameters Command: rak_web_store Syntax: typedef struct { uint32_t cmd; config_t params; char user_name[17]; char user_psk[17]; }web_t Parameter: Parameter Bytes Value Description 0xC5,0x00,0x00,0x00 Command Code params Network parameters User_name ASCII authentication user name User_psk...
  • Page 51: Enabling Automatic Connection

    RAK411 PROGRAMMING MANUAL V1.7 net_type Station Ad-hoc channel 0-13 Channel sec_mode network encrypted Network encryption dhcp_mode STA:Dhcp client STA:ip static ssid ASCII Network identifier ASCII Network key dummy Null data ip_param IP parameter ap_config AP advanced parameters Ip_param: Parameter Bytes...
  • Page 52: Starting Web Server

    RAK411 PROGRAMMING MANUAL V1.7 uint32_t cmd; Parameter: Parameter Bytes Value Description 0xC6,0x00,0x00,0x00 Command Code Description: saved network parameters enable automatic networking. Automatically run internal scan, join and IP setting, and then return IP allocation results. Return Value: Parameter Bytes Value Description <CODE>...
  • Page 53: Getting Saved Network Parameters

    RAK411 PROGRAMMING MANUAL V1.7 Description: It is used to start the embedded WEB service. Module will start the WEB with default parameters,typically in AP mode. When user is added, user can use the browser to configure the module parameters for wireless modules or wireless firmware upgrade.
  • Page 54 RAK411 PROGRAMMING MANUAL V1.7 <CHANNEL> 0-13 Channel <sec_mode> Network is not encrypted Network is encrypted <dhcp_mode> STA:DHCP client STA:ip static <ssid> Network identifier <psk> Network key <DUMMY> Null data <ip_param> IP parameters <ap_config> AP parameters <STATUS> Command successful Command failed, or timeout Related parameters:...
  • Page 55 RAK411 PROGRAMMING MANUAL V1.7 Parameter Bytes Value Description 0Xba,0x00,0x00,0x00 Command Code Description: This command is available to save network parameters. Return Value: Parameter Bytes Value Description <CODE> 0xba,0x00 Response Code params Network parameters User_name User name User_psk Network encryption Password <STATUS>...
  • Page 56 RAK411 PROGRAMMING MANUAL V1.7 parameter Bytes Value Description addr IP address mask Subnet mask Gateway dnssvr1 DNS serve 1 dnssvr2 DNS serve 2 Ap_config parameter Bytes Value Description hidden Network name is visible The network name is not visible countrycode...
  • Page 57: Sales And Service

    RAK411 PROGRAMMING MANUAL V1.7 5 Sales and Service Shanghai FAE mailbox: allan.jin@rakwireless.com Tel:021- 61553990 Fax:021- 54721038 Address: Room B205, Green light kechuang garden, 2588 Lane, Hongmei South road, Minhang District, Shanghai Shenzhen FAE mailbox: steven.tang@rakwireless.com Tel : 0755-26506594 Fax: 0755-86152201 Address: Room 802, Yongfu building, No.1s06, Yongfu road, Baoan District , Shengzhen...
  • Page 58: Revision History

    RAK411 PROGRAMMING MANUAL V1.7 6 Revision History Version Author Modification Date 2014-03-11 V1.0 Initial Draft Modify draft and release 2014-03-28 V1.1 Modify command returns status, data structure 2014-06-09 V1.2 Update the contact way,Update the document format 2014-08-22 V1.3 1. Add a new command rak_tcpsever_status (check TCP server connections) and description 2.

Table of Contents