Difference between revisions of "Component: WIFI (BL0136) (E-blocks 2)"
Line 25: | Line 25: | ||
==Examples== | ==Examples== | ||
− | |||
+ | The examples below are all done using a EB091 board as the host | ||
+ | |||
+ | The EB069 ESP8266 Wifi E-block is connected to PORTD 0-7 with the patch setting set to B. | ||
+ | |||
+ | The EB005 LCD E-block is connected to PORTB 0-7 with the patch setting set to Default. | ||
+ | |||
+ | Other host boards are compatible with the examples, simply change the target chip and component connection properties. | ||
+ | |||
+ | |||
+ | |||
+ | ===Firmware Test=== | ||
+ | |||
+ | This example collects the firmware version from the ESP8266 module and displays it on an LCD. Tested working with firmware version 00150900. | ||
+ | |||
+ | {{Fcfile|ESP8266_FirmwareTest.fcfx|FirmwareTest}} | ||
+ | |||
+ | |||
+ | ===Wireless Scanner=== | ||
+ | |||
+ | This example scans for wireless networks in range and prints the network IDs to the LCD along with the signal strength and security type. | ||
+ | |||
+ | {{Fcfile|ESP8266_WifiScan.fcfx|WifiScan}} | ||
+ | |||
+ | |||
+ | ===Creating An Access Point=== | ||
+ | |||
+ | This example creates an access point you can connect your phone or laptop to named Flowcode_ESP8266. The password to connect to the access point is flowcode6. | ||
+ | |||
+ | Note this example simply creates an access point, no data is transferred. | ||
+ | |||
+ | {{Fcfile|ESP8266_CreateAP.fcfx|CreateAP}} | ||
+ | |||
+ | |||
+ | ===Joining An Access Point=== | ||
+ | |||
+ | This example joins an existing access point. The network ID and Password must be altered to match your local WIFI network settings. | ||
+ | |||
+ | Note this example simply joins an access point, no data is transferred. | ||
+ | |||
+ | {{Fcfile|ESP8266_JoinAP.fcfx|JoinAP}} | ||
+ | |||
+ | |||
+ | ===TCP Client=== | ||
+ | |||
+ | This example joins an existing access point. The network ID and Password must be altered to match your local WIFI network settings. | ||
+ | |||
+ | Once joined to the network the example connects to the MatrixTSL website and requests a file which is printed out on the LCD. | ||
+ | |||
+ | {{Fcfile|ESP8266_TCPClient.fcfx|TCPClient}} | ||
+ | |||
+ | |||
+ | ===TCP Server=== | ||
+ | |||
+ | This example creates an access point you can connect your phone or laptop to named Flowcode_ESP8266. The password to connect to the access point is flowcode6. | ||
+ | |||
+ | Once the access point is created the example shows the server IP address on the LCD. | ||
+ | Connecting to the wireless network on your phone or laptop and visiting the IP address shown on the LCD using a web browser allows you to switch LED outputs on and off. | ||
+ | |||
+ | {{Fcfile|ESP8266_TCPServer.fcfx|TCPServer}} | ||
+ | |||
+ | |||
+ | ===Network Comms=== | ||
+ | |||
+ | Here are some examples using the Network Communication component linked to the ESP8266 component. | ||
+ | |||
+ | {{Fcfile|NetworkComms-ESP8266-Client.fcfx|NetworkComms ESP8266 Client}} | ||
+ | |||
+ | {{Fcfile|NetworkComms-ESP8266-Server.fcfx|NetworkComms ESP8266 Webserver}} | ||
==Downloadable macro reference== | ==Downloadable macro reference== |
Revision as of 12:15, 20 September 2019
Author | Matrix Ltd. |
Version | 2.1 (Release) |
Category | E-blocks 2 |
Contents
- 1 WIFI (BL0136) component
- 2 Examples
- 3 Downloadable macro reference
- 3.1 DisconnectFromSSID
- 3.2 SendString
- 3.3 ClientConnect
- 3.4 ControlTCPServer
- 3.5 GetFirmwareVersion
- 3.6 CheckForPageRequests
- 3.7 ClientSendRequest
- 3.8 ReadSSIDFromScan
- 3.9 CreateAccessPoint
- 3.10 SetOutValue
- 3.11 ReadSignalStrengthFromScan
- 3.12 ReadEncryptionModeFromScan
- 3.13 GetByteWithTimeout
- 3.14 GetInValue
- 3.15 ConnectToSSID
- 3.16 ScanForSSID
- 3.17 Initialise
- 3.18 CheckTCPServerIP
- 4 Simulation macro reference
- 5 Property reference
WIFI (BL0136) component
Wireless LAN component designed to work with the ESP-12S module. Provides a very simple interface to allow webpages to be hosted from hardware or simulation. Also available in the form of the BL0136 WIFI E-block.
This component can be used for connecting a system to a wifi network, by using the ‘ScanForSSID’ component macro. Then different macros can be used to read the encryption mode, the signal strength or the specific SSID of one of the networks picked up in the scan. There is also a ‘ConnectToSSID’ macro which allows you to connect your program to a wifi network (as long as you have a sufficient password) and another macro you can use to disconnect from the network again.
As well as connecting to a wifi network, there is a component macro called ‘CreateAccessPoint’ which creates an access point (with a chosen SSID, password, channel, and encryption) for other people to connect to.
Examples
The examples below are all done using a EB091 board as the host
The EB069 ESP8266 Wifi E-block is connected to PORTD 0-7 with the patch setting set to B.
The EB005 LCD E-block is connected to PORTB 0-7 with the patch setting set to Default.
Other host boards are compatible with the examples, simply change the target chip and component connection properties.
Firmware Test
This example collects the firmware version from the ESP8266 module and displays it on an LCD. Tested working with firmware version 00150900.
Wireless Scanner
This example scans for wireless networks in range and prints the network IDs to the LCD along with the signal strength and security type.
Creating An Access Point
This example creates an access point you can connect your phone or laptop to named Flowcode_ESP8266. The password to connect to the access point is flowcode6.
Note this example simply creates an access point, no data is transferred.
Joining An Access Point
This example joins an existing access point. The network ID and Password must be altered to match your local WIFI network settings.
Note this example simply joins an access point, no data is transferred.
TCP Client
This example joins an existing access point. The network ID and Password must be altered to match your local WIFI network settings.
Once joined to the network the example connects to the MatrixTSL website and requests a file which is printed out on the LCD.
TCP Server
This example creates an access point you can connect your phone or laptop to named Flowcode_ESP8266. The password to connect to the access point is flowcode6.
Once the access point is created the example shows the server IP address on the LCD. Connecting to the wireless network on your phone or laptop and visiting the IP address shown on the LCD using a web browser allows you to switch LED outputs on and off.
Network Comms
Here are some examples using the Network Communication component linked to the ESP8266 component.
NetworkComms ESP8266 Webserver
Downloadable macro reference
DisconnectFromSSID
Disconnects from the current SSID.
Returns 1 if the command was accepted and returned an "OK"
Parameters
- This macro has no parameters
Return value
SendString
Sends the given Text.
Appends a CR to the end of the string it SendCR is greater than 0.
Parameters
- <- STRING Text
- This parameter may be returned back to the caller
- BYTE SendCR
Return value
- This call does not return a value
ClientConnect
Creates a TCP or UDP connection to a remote server.
Returns the state of the connection.
0=Connection failed
1=Connection active
Parameters
- BYTE Type
- 0 = TCP, 1 = UDP
- <- STRING IPAddress
- e.g. "192.168.1.20"
- This parameter may be returned back to the caller
- UINT Port
- Remote port number to connect to, HTTP comms = Port 80
Return value
ControlTCPServer
Allows a TCP web page server to be switched on and off on the selected port.
Returns 1 if the command was completed correctly.
Parameters
- BYTE Enable
- 0 = Stop Server, 1 = Start Server
- UINT Port
- Server port to listen for incoming TCP/IP data requests
Return value
GetFirmwareVersion
Collects the firmware version from the ESP8266 module and returns it as a string.
Parameters
- This macro has no parameters
Return value
CheckForPageRequests
To be called periodically. Returns non-zero if a request has been processed
Parameters
- This macro has no parameters
Return value
ClientSendRequest
Sends out a request for data
Parameters
- <- STRING Request
- e.g. "GET / HTTP/1.0\r\n\r\n"
- This parameter may be returned back to the caller
Return value
- This call does not return a value
ReadSSIDFromScan
Collects one of the SSID name strings from the last SSID Scan.
The ScanForSSID macro must be called first.
Parameters
- BYTE Index
- SSID Index
Return value
CreateAccessPoint
Sets up the wireless LAN module into AP mode to host a wireless network.
Other WIFI enabled devices can then connect to the module.
Returns 1 for success.
Parameters
- <- STRING SSID
- Name of the wireless network to create
- This parameter may be returned back to the caller
- <- STRING Password
- Password used to gain access to the network
- This parameter may be returned back to the caller
- BYTE Channel
- 802.11 Channel Range 1-14
- BYTE Encryption
- 0=Open, 1=WEP, 2=WPA_PSK, 3=WPA2_PSK, 4=WPA_WPA2_PSK
Return value
SetOutValue
Set the value of an outbound substitution string
Parameters
- BYTE index
- Range 0-4
- <- STRING value
- This parameter may be returned back to the caller
Return value
- This call does not return a value
ReadSignalStrengthFromScan
Collects the signal strength from the last SSID Scan.
The ScanForSSID macro must be called first.
Value returned is in negative dB, smaller value = better signal
Parameters
- BYTE Index
- SSID Index
Return value
ReadEncryptionModeFromScan
Collects one of the encryption modes from the last SSID Scan.
The ScanForSSID macro must be called first.
0=Open, 1=WEP, 2=WPA_PSK, 3=WPA2_PSK, 4=WPA_WPA2_PSK
Parameters
- BYTE Index
- SSID Index
Return value
GetByteWithTimeout
Attempts to receive a byte from the circular buffer.
If nothing is available then waits up to 20 ms for data to become available.
Parameters
- This macro has no parameters
Return value
GetInValue
Returns the string value of a Request parameter
Parameters
- BYTE index
- Index of the request paramter, starting at zero Range 0-2
Return value
ConnectToSSID
Attempts to connect to the given SSID and Key values.
Returns 1 if the SSID has been connected.
Parameters
- <- STRING SSID
- This parameter may be returned back to the caller
- <- STRING Key
- This parameter may be returned back to the caller
- BYTE Timeout
- Number of seconds to wait for the connection, default 2
Return value
ScanForSSID
Checks for wireless networks in the local area which are broadcasting their SSID.
Must not be connected to a network to allow this to function.
Returns the number of wireless networks found, max 8.
Parameters
- This macro has no parameters
Return value
Initialise
Initialise the device with the property data.
Returns 1 if "ready" message successfully received
Returns 0 if no reply from module
Parameters
- This macro has no parameters
Return value
CheckTCPServerIP
Collects the local IP address of the active TCP server.
Parameters
- This macro has no parameters
Return value
Simulation macro reference
This component does not contain any simulation macros
Property reference
Receive Buffer Size
This property is of type Unsigned integer and can be referenced with the variable name RxBufferSize.
Buffer used to store incoming data ready for processing.
Default 128 Bytes.
Scan Buffer Size
This property is of type Unsigned integer and can be referenced with the variable name ScanBufferSize.
Buffer used to hold SSID names when performing a SSID network scan.
Default 100 Bytes.
Reset Mode
This property is of type Fixed list of ints and can be referenced with the variable name ResetMode.
The initialise automatically resets the WIFI module before establishing communications.
Software reset uses an AT command to preform the reset
Hardware reset uses an extra I/O pin to toggle the signal to the reset pin on the module.
Command Termination
This property is of type Fixed list of ints and can be referenced with the variable name Termination.
Older versions of the firmware require \r to terminate a AT command string.
Newer versions of the firmware have changed to use \r\n termination.
Channel
This property is of type Fixed list of ints and can be referenced with the variable name group1::cal_uart1::CHANNEL.
UART Channel selector
Software channels are bit banged using generic I/O pins but are not as reliable as hardware channels.
Hardware channels use the selected peripheral on-board the target microcontroller.
Baud Options
This property is of type Fixed list of ints and can be referenced with the variable name group1::cal_uart1::BAUD_LIST.
Baud rate option selector
Baud Rate
This property is of type Signed integer and can be referenced with the variable name group1::cal_uart1::BAUD.
No additional information
TX
This property is of type Single digital pin and can be referenced with the variable name group1::cal_uart1::TX.
Pin to be used for Transmit data
TX Remap Pin
This property is of type Fixed list of ints and can be referenced with the variable name group1::cal_uart1::OutputPins.
Allows the hardware transmit pin to be configured from a list of available pins based on your target device,
RX
This property is of type Single digital pin and can be referenced with the variable name group1::cal_uart1::RX.
Pin to be used for Receive data
RX Remap Pin
This property is of type Fixed list of ints and can be referenced with the variable name group1::cal_uart1::InputPins.
Allows the hardware receive pin to be configured from a list of available pins based on your target device,
Reset
This property is of type Single digital pin and can be referenced with the variable name RESET.
WLAN module reset pin connection
Use Flow Control
This property is of type Fixed list of ints and can be referenced with the variable name group1::cal_uart1::FLOWEN.
Flow Control (Handshake) enable or disable.
On: Two I/O pins are used to control the flow of data in and out of the device.
Off: Flow control is disabled.
Max Web Pages
This property is of type Fixed list of ints and can be referenced with the variable name PAGES.
Maximum number of individual webpages we can serve up with the component.
Web Page Timeout
This property is of type Unsigned integer and can be referenced with the variable name TIMEOUT.
Number of cycles to try and send / receive a webpage before timing out.
Line Delay
This property is of type Unsigned integer and can be referenced with the variable name LineDelay.
Fixed delay in microseconds sent in between sending a HTML line when running as a web page server.
Name Page 1
This property is of type Line of text and can be referenced with the variable name name1.
HTML name of webpage 1
HTML Page 1
This property is of type Multiple lines of text and can be referenced with the variable name html1.
HTML content for webpage 1
Name Page 2
This property is of type Line of text and can be referenced with the variable name name2.
HTML name of webpage 2
HTML Page 2
This property is of type Multiple lines of text and can be referenced with the variable name html2.
HTML content for webpage 2
Name Page 3
This property is of type Line of text and can be referenced with the variable name name3.
HTML name of webpage 3
HTML Page 3
This property is of type Multiple lines of text and can be referenced with the variable name html3.
HTML content for webpage 3
Name Page 4
This property is of type Line of text and can be referenced with the variable name name4.
HTML name of webpage 4
HTML Page 4
This property is of type Multiple lines of text and can be referenced with the variable name html4.
HTML content for webpage 4
Count
This property is of type Fixed list of ints and can be referenced with the variable name Outgoing_Count.
Maximum number of outbound string substitutions
Length 0
This property is of type Unsigned integer and can be referenced with the variable name Out_Len_0.
Number of bytes to reserve for data string.
Count
This property is of type Fixed list of ints and can be referenced with the variable name Incoming_Count.
Maximum number of inbound string substitutions
Length 0
This property is of type Unsigned integer and can be referenced with the variable name In_Len_0.
Number of bytes to reserve for data string.
Label
This property is of type Line of text and can be referenced with the variable name label.
Text label used to help identify the component on the panel.
Simulation Method
This property is of type Fixed list of ints and can be referenced with the variable name SimMethod.
Decides how to handle the simulation of the component.
TCP Base - Allows simulation of the network communications using the TCP Base component and DLL.
COM/Injector - Allows the simulation to connect to real hardware or injectors.
Scope Traces
This property is of type True or false and can be referenced with the variable name group1::cal_uart1::ScopeTraces.
Selects if the scope traces are automatically added to the data recorder window or not.
Simulation - draws an approximation of the UART data onto the scope trace.
ICT - sets up the scope trace for incoming data and adds UART packet decoding at the correct BAUD.
Console Data
This property is of type True or false and can be referenced with the variable name group1::cal_uart1::ConsoleData.
Selects if the console data is automatically generated or not
Console Columns
This property is of type Unsigned integer and can be referenced with the variable name group1::cal_uart1::ConsoleColumns.
Number of characters that can be displayed on a single line of the console.
Data Source
This property is of type Fixed list of ints and can be referenced with the variable name group1::cal_uart1::DataSource.
Simulation data source used to allow the component to connect to various remote devices
Nothing - Simulation data is ignored
COM port - Routes the communication data to and from a physical or virtual COM port
Injector - Routes the communication data via a data injector component on the Panel.