User manual

!
www.rovingnetworks.com Version 1.1 9/20/2012 11
RN-131/171-PICTAIL-UM
Initialize the PIC’s UART
The void ConsoleInit(void) API function initializes the PIC’s UART1, which communicates with the RN-131/RN-171
module. It sets the UART’s baud rate to 9600 baud, 8 bits data, 1 stop bit, no parity, and no flow control. These settings
are the default for the RN-131/RN-171 module. To change the baud rate, modify the #define BAUD_RATE 9600 macro
in the console.h header file, and re-initialize the UART.
The ConsoleInit( ) function enables both transmit and receive UART capabilities, but their respective interrupts are
disabled until the application is prepared to receive them. Later, receive interrupts are enabled. Transmit interrupts remain
disabled.
Reset the RN-171 Module
The PICtail connector has an active-low reset pin (RB1) that is used to reset the RN-131/RN-171 module after the PIC18
Explorer Board and UART are properly initialized. The void rn_reset_wifi(void) API function is used for this reset operation.
It transitions the reset pin from high to low, holds the pin low for 10 ms, and then returns it high. This reset action triggers
the module to begin its joining procedure.
Check Module’s Status
Immediately after resetting the module, the PIC’s UART receiver interrupt is enabled. This process prepares the PIC to
receive the information that is transmitted from the RN-171’s UART as it goes through its start up procedure.
The PIC18 parses the RN-171 output and searches for the module’s IP address if it was successful in associating with an
access point. If a valid IP address is received, the assumption is made that the device is safely on a network and is in data
mode. In this case, the PIC18 waits to receive commands from the RN-131/RN-171 module in an endless loop. The PIC18
acts on each valid command as it receives it.
Command Mode
If the PIC18 application detects that the RN-171 module was not successful in its start-up attempt to associate with an
access point, the PIC’s application attempts to instruct the module to associate with a specific access point. The PIC18
application sends the following commands to the module in sequence:
$$$ Put the module into command mode.
set wlan ssid <string> Set the network’s SSID where <string> is the SSID.
set wlan pass <string> Set the passphrase to use when joining where <string> is the passphrase.
save Save the settings to persistent storage; reused when joining.
reboot Reboot the module so that the settings take effect.
When successful, the module reboots and associates with the specified access point. The following section describes the
APIs used to carry out these operations.