RAK439 is an ultra-low-power, low-cost module that fully supports of major encryption modes as well as WAPI encryption mode, a Wi-Fi ® module with SPI interface that supports 802.11b/g/n protocol. The module internally integrates RF station, balun, RF switch, crystal oscillator and power switch circuit, enabling fast hardware design with very little circuits for peripherals. Plus, the module has built-in IPEX external antenna base, also leads antenna foot that allows on-board antenna design。
RAK439 SDK software library has encapsulation for WIFI module interface driver, providing a platform-specific driver function, so that customers can easily integrate the module into their main platform, greatly shorten the evaluation cycle. Software library also provides a network-related API; user can quickly complete the module's network configuration and connection. Socket section uses BSD socket type operation, easy to operate.
Driver Library supports both NOS operation and OS operation; user can choose either according to actual operation flexibility.
|API Driver Function|
|int rw_sysDriverInit(rw_DriverParams_t* params);||Basic settings of driver library, driver functions, the settings of callback function, and driver initialization. If the return of drive initialization fails, check the connection, such as SPI. The API needs to be called firstly, then execute other API functions after successful initialization.|
|int rw_wlanNetworkScan(char* pssid, int channel);||This command is used to scan network AP information, user can scan the network with specified name or scan the specified channel. When use the software libraries without operating system, the scan results will be returned with rw_WlanNetworkInfoList_t * callback. When scan, the library will apply space based on the maximum number set, and sort the AP information, according to signal strength, from strong to weak. After scanning, release the portion of space to avoid repeat applications of space, wasting of resources. When use the software library with OS, scan results can be directly acquired by rw_wlanGetScanInfo function, and also need to release space resources.|
|int rw_wlanGetScanInfo(rw_WlanNetworkInfoList_t *pInfoList);||This function is used in software library with OS. The function can block the return of internal scan results. Timeout: 5s. Scan results acquired will be stored in pInfoList with rw_WlanNetworkInfoList_t type of pointer. Release the memory after processing the results.|
|int rw_wlanApConfig(uint8_t is_hidden);||The command is used to set AP name hidden status to prevent other wireless clients to join. This command needs to be called before rw_wlanConnect.|
|int rw_wlanConnect(const rw_WlanConnect_t *conn);||As the STA connecting to a router, user needs to set parameters of router, rw_WlanConnect_t structure contains the required parameters of the connection. When create AP, also need to set basic parameters, network name, channel, password, encrypted status, encryption method. AP encryption only supports WPA2-AES. For specific parameters of Structure, refer to Parameter section.|
|int rw_ipConfig(rw_IpConfig_t* ip_addr, rw_IpConfigMode_t mode);||IP set command. After a network is connected / created successfully, user needs to call this command to set IP information of module. It can be a static configuration (same as network segment of the router), or a dynamic assigned IP from the router. The callback notification will be given no matter the set is succeeded or failed. In AP mode, firsly set IP information for static module, then enable DHCPserver function of the module to assign IP for wireless client.|
|int rw_dnsRequest(const char *host_name, uint8_t name_len, uint16_t family);||DNS command is used to resolve a given domain name to an IP address, the command invokes the need in the module as STA, has networked and access to the IP address and DNS server address (usually the gateway address), when you need to set a static IP setting module available the DNS server addresses. The command is non-blocking, DNS results will be output in the callback function. See DNS callback introduction. BSD socket has a similar function: int gethostbyname (const char * hostname, uint8_t namelen, uint32_t * out_ipaddr, uint16_t family); the function is blocked calls, direct return IP addresses.|
|int rw_startEasyWps(rw_ConfigMode_t mode);||WPS and EASYconfig are two methods of easy configuration for network parameters, the module can execute these commands after a normal start. easyconfig configures phone APP, getting the required name and password information of the route to be connected, software libraries informs the upper layer with configuration results via a callback function. For WPS, you press the WPS button on route. Get the name and password, user can save them to Flash, next enabling automatically connection when power on.|
|int rw_setPwrMode(rw_PowerMode_t pwr_mode);||Set power mode for module. It is only effective in STA mode. power_max module will run in full speed with the best performance. When switch to power saving mode, the module keeps a DTIM interval with route after a successful connection, to wake, send and receive data.|
|int rw_getPMK(char* pmk);||Get the PMK value of network, effective only in STA mode, WPA or WPA2 encryption. The PMK value is fixed 32 bytes. After module successfully joined the network, PMK value is acquired (similar to a password). This way of using the PMK instead of password to join the network, can save about 1.5S time. User can use this password to connect to network in some scenes where requires a fast network connection.|
|int rw_getRSSI(void);||Get the strength of the current router connected, active in STA mode. The return value is positive (up to 96), such as return = 50, meaning the value of RSSI is -50, the smaller the value, the stronger the signal strength.|
|int rw_getMacAddr(char* mac_data);||MAC of module, globally unique MAC address is scanned after factory, 6 bytes, as module hardware identification.|
|int rw_getLibVersion(char* version);||Get software library and WIFI version, such as 1.0.4-2.1.39.|
|int rw_sysDriverDeinit(void);||Disable the module-associated hardware initialization, and software driver library. After WIFI function is disabled, user can call this function; hardware-related operations are carried out by user in driver functions, such as turning off MOS pin, pull down reset pin, setting SPI pin as input pull up, etc., to save power. When conduct software OS, module deletes WIFI driver tasks.|
|int rw_sysDriverReset(void);||Reset Software driver library and reset module hardware. When the module is abnormal, or need to re-connect to network, reset module drivers and hardware. When conduct software OS, it also deletes WIFI driver tasks.|
|int rw_sysDriverLoop(void);||It is driver loop function for driver and network connection management and timeout detection. This function is only run in software library without OS, to maintain drivers working normally and return callbacks or abnormal events. If user’s WIFI application data exchange frequently, user needs to frequently call this function so that to return the data to upper layer. In the functions of send, recv, and delay, the software library will also call this function. If this function returns failed, it is usually caused by parameter configuration.|
|void rw_sysSleep(int ms);||Delay function is used for delaying software library, mainly added rw_sysDriverLoop function in the delay, ensuring callback events, sending and receiving data in a timely manner.|
|void rwSetFutureStamp(rw_stamp_t* stamp, uint32_t msec);||This function is generally used for the software library that does not run operating system, set a timeout to judge whether it has received returns of commands within the time period from commands sent to command timeout, enabling customers to use. The function requires a a count-up counter value provided by master platform.|
|bool rwIsStampPassed(rw_stamp_t* stamp);||This function determines whether timeout, should use together with rwSetFutureStamp.|
|API Callback Function|
|typedef void(*rw_WlanScan_)(rw_WlanNetworkInfoList_t* scan_info);||This is notification of scan results. Software library should apply memory space, pay attention to the release a certain space.|
|typedef void(*rw_WlanConnEvent_)(uint8_t event, rw_WlanConnect_t* wlan_info, uint8_t dis_reasoncode);||Network event notification includes the notifications of network connection and disconnection in STA mode. Creating network in AP mode, there are events of client connection and disconnection. Callback also includes the network information of the current successful network connection, such as the name, password, channel, encryption methods, AP's BSSID, etc. When necessary, verify and save these network parameters. Disconnecting code can determine whether there is a problem for network setup parameters, or the network which is matched with network parameters (name, password, encryption, BSSID) was not found. Basically 0x01, means no matching network, and 0x0a means password error.|
|typedef void(*rw_WlanEasyWps_)(rw_WlanEasyConfigWpsResponse_t* pResponse, int status);||When conduct Easy Config and WPS configuration, once module listens to the routing information sent by mobile phone, drivers will give callback to upper layer, informing success or failure, if succeed, return the current network information.|
|typedef void(*rw_IpDhcp_)(rw_IpConfig_t* addr, int status);||When user performs a DHCP client, the function is non-blocking, the results of DHCP will be notified to upper layer via callback, according to status value to determine whether it is failed or not. When it is successful, IP address, gateway address, DNS server information can be checked.|
|typedef void(*rw_DnsResult_) (int dnsIp);||Results callback of DNS resolution, if IP address is 0, it indicates DNS failure timeout, the upper layer has to call again to resolve.|
|static void customer_assert(const char* file, int line)||To allow user to better understand and use the module drivers, here to inform the running abnormal of module driver to user, the reason of abnormal case is rather case by case in specific circumstances. Usually tt does not occur error if operate in accordance with normal operating procedures and hardware connection is stable. However, recommend that customers reset drive, do module test to investigate possible reasons if any error occurs.|
|BSD Socket Part|
|int socket(int domain, int type, int protocol);||Create socket; return a socket descriptor that will be commonly used by later functions with range of 0- socket_max_num (driver library configuration set by user).|
|int bind(int sockfd,const void *myaddr, socklen_t addrlen);||Bind socketfd to local, this function is used to specify a port number, an IP address, specify both, or specify neither. User may not use this function to call. After using the socket () to obtain a socket user can directly call function connect () or listen (). Without this function, a fixed port 1024 is assigned automatically. When in TCP connection, it is recommended for customers to bind a port, and use random port number to ensure TCP connection of server is normally release when module hardware reset.|
|int connect(int sockfd, void *serv_addr, int addrlen);||Connect to a remote server with specified IP and port, non-blocking operation with NOS, the join result (success / failure) will be given in TCPC callback function; blocking operation with OS, the function return determines whether the connection is successful.|
|int listen(int sockfd, int backlog);||Sockfd is the descriptor returned when create a TCP socket, TCP server listens TCP connections, monitoring the descriptor with select function, when a new connection is found, call accept function to receive this new connection.|
|int accept(int sockfd, void *addr, int *addrlen);||TCPServer receives a new TCP connection, the IP and port number information of the new connection are saved in addr, if the call is successful, it will return a new sockfd, new connections will communicate with the sockfd.|
|int send(int sockfd, const void *msg, int len, int flags);||Send function that is generally used to send TCP data of specified sockfd, no need to specify each other's IP and port information. In NOS, send function is non-blocking, the number of bytes will be returned when sent successfully, and transmission function can only send a packet with MAX_SEND_PACKET_LEN, typically 1400 bytes.|
|int sendto(int sockfd, const void *data, size_t size, int flags, const void *to, socklen_t tolen);||This function is mainly used to send the UDP data of specified sockfd, need to fill each other's IP address and port number. In NOS, send function is non-blocking, the number of bytes will be returned when sent successfully, transmission function can only send a packet with MAX_SEND_PACKET_LEN, typically 1400 bytes.|
|int recv(int sockfd, void *buf, int len, unsigned int flags);||This function is mainly used to receive TCP data of specified sockfd, the maximum data length of a packet to be received should be specified, MAX_RECV_PACKET_LEN, UDP: 1536 TCP: 1452. Also, same size of the buffer in upper layer should be defined, if the value is less than the set value, and receive a package of data that is greater than the set value, the drive will only copy the length of the data set to specified buffer, subsequent data will be discarded to prevent buffer overflowed. Function returns the actual length of the received data.|
|int recvfrom(int sockfd, void *mem, size_t len, int flags, void *from, socklen_t *fromlen);||This function is mainly used to receive UDP data of specified sockfd, the maximum data length of a packet to be received should be specified, MAX_RECV_PACKET_LEN, UDP: 1536 TCP: 1452. Also, same size of the buffer in upper layer should be defined, if the value is less than the set value, and receive a package of data that is greater than the set value, the drive will only copy the length of the data set to specified buffer, subsequent data will be discarded to prevent buffer overflowed. Function returns the actual length of the received data. The sender information of data will be saved and in from and fromlen.|
|int shutdown(int sockfd, int how);int close(int sockfd);||When the procedure of network transmission is completed, the connection that represented by socket descriptor needs to be closed, via close function. During the period of sending or receiving, when the connection abnormal is disconnected, RW_ERR_SOCKET_INVAILD error occurs, user can also call this function, remove internal connection.|
|int gethostbyname(const char *hostname ,uint8_t namelen ,uint32_t* out_ipaddr,uint16_t family);||When the function executes it is blocked, when NOS and OS, both are blocked, users pass domain name to be resolved and length, after function returns successfully, IP address will be saved in out_ipaddr.|
|int select(int sockfd, uint32_t timeout_ms);||This function is used to wait for a specified socket event, it can be set to always wait or specify a number of milliseconds to wait. Currently function can only be used to monitor one socket descriptor data.|
== Pleace see the programming manual for the detailed meaning of the command. ==
|5||CHIP_PWD_L||I, PU||Reset pin of the module|
|6||GSPI_MOSI||I||SPI MOSI pin of the module|
|7||GSPI_CS||I||SPI CS (chip select) pin of the module|
|9||GSPI_INT||O||SPI INT interrupt output pin of the module|
|10||GSPI_MISO||O||SPI MISO pin of the module|
|11||GSPI_CLK||I||SPI CLK clock input pin of the module|
|12||1.8V||O||1.8V power output of the module|
|13||VDD3V3||P||3.3V power input of the module|
|19||RF_OUT||O||RF output pin, capable of being designed to be connected with the on-board antenna|
|20||MODE||I||Sets the chip working mode, and the SPI mode must be pulled down|
1. Indications of letters of pin types in Table 3-1: P: power. GND: ground; I: input; O: output; PU: pull upwards.
2. Pin 19 is the RF output pin which can be connected with the on-board antenna as per design. Please hang Pin 19 in the air when not using it.
3. NC pins are hung in the air.
1. The power design of the WIFI module is important. The power should support the WIFI module to continuously receive and transmit current peak of 350ma at high WIFI rate and high RF output, and this value should be reserved with appropriate safety margin, which is generally recommended at 400-500ma.
2. Signal integrity of SPI communication lines should be considered, as distortion of the SPI Clock may lead to desynchrony in SPI communication and subsequent communication failure. Thus, the following three elements need to be considered. Firstly, SPI lines should be equal at length. Secondly, if the module and the host are connected in a wired way, the number of ground wires should be increased as much as possible, but the length should be prevented from being too long. Thirdly, if the SPI clock line is connected with a resistor in series, the default value of the resistor is 33Ω.
3. The reset line of the module should be connected with the IO port of the host, so the module can realize hardware reset from abnormality.
the SPI of the host needs to select the same polarity and phase as same as the SPI clock of the slave (module). As shown in the diagram, the SPI clock idle level is high, and the polarity is 1; data are received at the rising edge of the SPI clock (SPI_MOSI), and are sent at the falling edge of the SPI clock (SPI_MISO).
We designed for the developers of the latest compatible ARDUINO development of the RAK439 development board, and provides a complete set of code, developers can directly use the code to buy their own applications can be developed.For details:WisNode-SPI
|External supply voltage||VCC3V3||-0.3~4.0||V|
|Maximum RF Input (Reference: 50Ω)||RFin||+10||dBm|
|When voltage is 3.3V, IO Max voltage||3V3VinIOMax||VCC+0.3||V|
|When voltage is 3.3V, IO Min voltage||3V3VinIOMin||-0.3||V|
|Storage ambient temperature||Tstore||-65~+135||℃|
|Apl||Accuracy of power balance loop||±1.5||dB|
|Parameter||conditions||Test conditions||Typical Value||Unit|
|Maximum input signal||CH7||11g,54Mbps||10||dBm|
|Adjacent channel suppression||6Mbps||--||37||dBc|
|Product||Describe||Single Tray Packing||Minimum Package||Evaluation Board|
|RAK439CS-XXXX||SPI interface module,with RF-OUT antenna||32pcs/tray||320pcs||WisNode-SPI|
|RAK439BS-XXXX||SPI interface module,with external antenna||32pcs/tray||320pcs|