Development Examples

[中文版]

Bluetooth Networking

FeasyBlue Bluetooth Networking

APP Download

Networking Guide

  1. Open the FeasyBlue app and click on Settings - WiFi Parameter Settings in sequence.

  2. Check BLE in the upper right corner of the application interface, scan and select the Bluetooth device BW256B you want to upgrade.

  3. Select and click on Bluetooth Distribution Network - In the pop-up SSIDPassword window, enter the SSIDpassword of the Wi-Fi AP to be connected, and click Start Distribution Network. After the distribution network is completed, It will display the successful network distribution and the obtained IP address .

../_images/bw256b-bt-network-en.png

Data Throughput Mode Application

What Is Throughput Mode?

FSC-BW256x series Bluetooth & Wi-Fi module features two data transmission modes: Throughput Mode and Command Mode .

The default command mode of the general data transmission application firmware. If you need to switch, you can refer to [FSC-BW256B General Data AT Command Set] , and using the AT+TPMODE command.

The working mechanisms and differences of the two data transmission modes are as follows:

  • Throughput Mode:

Without Bluetooth or Wi-Fi connection ,the data received through the serial port is parsed in the format of AT instructions;

Bluetooth or Wi-Fi connection has been established ,All the data received through the serial port is sent to the remote end as is.

  • Command Mode:

Without Bluetooth or Wi-Fi connection ,The data received through the serial port is parsed in the format of AT instructions;

Bluetooth or Wi-Fi connection has been established ,The data received through the serial port is still parsed in the AT instruction format and needs to be sent to the remote end via AT instructions. For example, when connecting with BLE, use the AT+LESEND command to send data. When establishing a TCP connection, use the AT+WFSEND command to send data.

Switch To Throughput Mode

Enter the Throughput Mode: Before establishing a Bluetooth or Wi-Fi connection, the FSC-BW256B module can use the command AT+TPMODE=1 to activate the transparent transmission mode. The operation example is as follows:

Send:>> AT+TPMODE=1                                         //Set it to transparent transmission mode
Response:<< OK

When Bluetooth or Wi-Fi connection has been established, exit throughput mode:

Send:>> +++          //Send "+++". Note: When operating on the host computer's serial port tool, please uncheck "New Line" at this time.
Response:<< a                 //Received response "a"
Send:>> a                     //Send "a". Note: When operating on the host computer's serial port tool, please uncheck "New Line" at this time.
Response:<< +ok       //Successfully exited

Note

  • Throughput Mode only takes effect when connections (such as Bluetooth, TCP/UDP) have been established. Therefore, the methods to exit transparent transmission also only work under such circumstances. When no connections have been established, you can directly use the AT command (AT+TPMODE) to switch (modes).

  • The data format for sending and receiving mentioned above differs from that of AT commands. Standard AT commands end with <CR><LF> , while the above-mentioned control commands are strings that do not come with <CR><LF>.

Throughput Mode Application

Module to Phone Communication

../_images/bw256-app-com-en.png

TCP Server Application

Tools

TCP Server Application Block Diagram

../_images/db105-bw256-tcps-200dpi-en.png

TCP Server Application Flowchart

@startuml
hide footbox
skinparam sequenceMessageAlign center

box  #LightBlue
actor “ ” as person
participant “USER MCU” as mcu
participant MODULE as module
participant " " as nu
participant "TCP Client" as client
end box

person ->> mcu: Start the operation
mcu -> module: AT+ROLE=1
note left
    Switch to STA mode
end note
module --> mcu: OK
mcu -> module: AT+RAP=SSID,PASSWORD
note left
    Connect to AP
end note
module --> mcu: OK
group LOOP Query until the IP address\nis obtained
mcu -> module: AT+LIP
note left
    Query the module's IP
end note
module --> mcu: +LIP=0.0.0.0
note right
    Not connected to AP
end note
end
module --> mcu: +LIP=192.168.0.97
note right
    Connected to AP
end note
mcu --> module: AT+SOCK=TCPS,9100
note left
    Set module
    as TCP Server
end note
module --> mcu: OK
mcu --> module: AT+WLANC=3
note left
    Start TCP Server
end note
module --> mcu: OK

client -> nu: The client \ninitiates a connection
nu -> module: The module is connected
client -> nu: The client send data\n:1234567890
module --> mcu: +WFDATA=0,10,1234567890
note right
    module outputs
    the received data
end note
mcu --> module: AT+WFSEND=0,3,abc
note left
    module sends data
    to the remote end
end note
module --> mcu: OK
nu -> client: abc
@enduml

TCP Server Application Example

  1. Set the module to Wi-Fi mode. If it is already in the current mode, you can skip this step. The operation example of the AT command is as follows:

Send:<<AT+ROLE=1
Response:>> OK
  1. The module is connected to the AP hotspot. An example of AT command operation is as follows:

Send:<< AT+RAP=ssid,password
Response: > OK
  1. Query the IP address of the module to confirm that it has been connected to the network. The operation example of the AT command is as follows:

Send:<< AT+LIP
Response:>> +LIP=192.168.0.97  //For local examples, please refer to the actual IP address obtained by connecting to the AP
Response:>> OK
  1. Set the module to TCP server with port 9100. The operation example of the AT command is as follows:

Send:<< AT+SOCK=TCPS,9100
Response:>> OK
  1. To create a TCP server for the module, an example of the AT command operation is as follows:

Send:<< AT+WLANC=3
Response:>> OK
  1. The PC and the module (FSC-BW256B) are connected to the same AP hotspot. On the PC, a third-party network debugging tool is used to create an IP address for the TCP connection to the TCP Server (module) as a TCP client. And after establishing a TCP connection, send TCP data to the TCP Server (module), such as 1234567890

../_images/tcptool-tcpc-en.png
  1. The module receives TCP data sent by the TCP Client. In instruction mode, an example of the received data format serial port response is as follows:

Response:>> +WFDATA=0,10,1234567890   //Supports simultaneously receiving data sent from multiple TCP clients to the TCP Server, with the first parameter being the connection ID
Response:>> +WFDATA=1,10,1234567890
Response:>> +WFDATA=2,10,1234567890
  1. The module supports the simultaneous reception of data sent from multiple TCP clients to the TCP Server. The first parameter is the connection ID. In command mode, an example of the AT command operation is as follows:

Send:<< AT+WFSEND=0,3,abc
Response:>> OK

TCP Client Application

Tools

TCP Client application block diagram

../_images/db105-bw256-tcpc-200dpi-en.png

TCP Client Application Flowchart

@startuml
hide footbox
skinparam sequenceMessageAlign center

box  #LightBlue
actor “ ” as person
participant “USER MCU” as mcu
participant MODULE as module
participant " " as nu
participant "TCP Server" as server
end box

person ->> mcu: Start the operation
mcu -> module: AT+ROLE=1
note left
    Switch to STA mode
end note
module --> mcu: OK
mcu -> module: AT+RAP=SSID,PASSWORD
note left
    Connect to AP
end note
module --> mcu: OK
group LOOP Query until the IP address\nis obtained
mcu -> module: AT+LIP
note left
    Query the module's IP
end note
module --> mcu: +LIP=0.0.0.0
note right
    Not connected to AP
end note
end
module --> mcu: +LIP=192.168.0.97
note right
    Connected to AP
end note
mcu -> module: AT+SOCK=\nTCPC,9100,192,168.0.100,6000
note left
    Set module
    as TCP Client
end note
module --> mcu: OK
mcu -> module: AT+WLANC=3
note left
    Start TCP Client
end note
module --> mcu: OK

module-> nu: Module initiates\nconnection
server -> nu: Module is connected
server -> nu: The server send data
module --> mcu: +WFDATA=3,10,1234567890
note right
    module outputs
    the received data
end note
mcu -> module: AT+WFSEND=3,3,abc
note left
    module sends data
    to the remote end
end note
module --> mcu: OK
nu -> server: abc
@enduml

TCP Server Application Example

  1. Set the module to Wi-Fi mode. If it is already in the current mode, you can skip this step. The operation example of the AT command is as follows:

Send:<< AT+ROLE=1
Response:>> OK
  1. Connect the module to the AP hotspot. The AT command operation example is as follows:

Send:<< AT+RAP=ssid,password
Response:>> OK
  1. To query the IP address of the module, an example of the AT command operation is as follows:

Send:<< AT+LIP
Response:>> +LIP=192.168.0.97   //For local examples, please refer to the actual IP address obtained by connecting to the AP
Response:>> OK
  1. Connect the PC and the module to the same AP hotspot. Use a third-party network debugging tool on the PC to create a TCP Server. For example, the IP address of the TCP Server is 192.168.0.79 and the port number is 8080.

  2. Set the module as TCP client and configure the IP and port number of the remote TCP Server. The operation example of the AT command is as follows:

Send:<< AT+SOCK=TCPC,9100,192.168.0.79,8080
Response:>> OK
  1. The module acts as a TCP client to initiate the establishment of a TCP connection with the remote TCP Server. An example of the AT command operation is as follows:

Send:<< AT+WLANC=3
Response:>> OK
  1. After the TCP connection is successfully established, the PC-end network debugging tool will display the successful connection, as well as the data sending area and receiving area. TCP data sending and receiving can be carried out, such as sending data 1234567890 to the remote TCP Client module

  2. The module receives TCP data sent from the TCP Server. In instruction mode, an example of the received data format response is as follows:

Response:>> +WFDATA=3,10,1234567890

UDP Application

UDP Application Flowchart

@startuml
hide footbox
skinparam sequenceMessageAlign center

box  #LightBlue
actor “ ” as person
participant “USER MCU” as mcu
participant MODULE as module
participant " " as nu
participant "UDP" as udp
end box
person ->> mcu: Start the operation
mcu -> module: AT+ROLE=1
note left
    Switch to STA mode
end note
module --> mcu: OK
mcu -> module: AT+RAP=SSID,PASSWORD
note left
    Connect to AP
end note
module --> mcu: OK
group LOOP Query until the IP address\nis obtained
mcu -> module: AT+LIP
note left
    Query the module's IP
end note
module --> mcu: +LIP=0.0.0.0
note right
    Not connected to AP
end note
end
module --> mcu: +LIP=192.168.0.97
note right
    Connected to AP
end note
mcu -> module: AT+SOCK=UDP,4000
note left
    Set module
    as UDP
end note
module --> mcu: OK
mcu -> module: AT+WLANC=3
note left
    Start UDP
end note
module --> mcu: OK

udp -> nu: The remote end\ninitiates a connection
nu -> module: Module is connected
udp -> nu: The remote end sends data\n:1234567890
module --> mcu: +WFDATA=4,10,1234567890
note right
    module outputs
    the received data
end note
mcu -> module: AT+WFSEND=4,3,abc
note left
    module sends data
    to the remote end
end note
module --> mcu: OK
nu -> udp: abc
@enduml

UDP Application Example

  1. Set the Wi-Fi mode. If you are already in the current mode, you can skip this step

Send:<< AT+ROLE=1
Response:>> OK
  1. Connect to AP

Send:<< AT+RAP=ssid,password
Response:>> OK
  1. Query the IP address of the module

Send:<< AT+LIP
Response:>> +LIP=192.168.0.97   //For local examples, please refer to the actual IP address obtained by connecting to the AP
Response:>> OK
  1. Set module as UDP

Send:<< AT+SOCK=UDP,4000
Response:>> OK
  1. Start UDP Server

Send:<< AT+WLANC=3
Response:>> OK
  1. The PC and the module are connected to the same hotspot. On the PC, a network debugging tool is used to start a UDP Client with the target IP 192.168.0.97 and the target port number 4000.

  2. Receive data

Response:>> +WFDATA=4,10,1234567890
  1. Send data

Send:<< AT+WFSEND=4,3,abc
Response:>> OK

Note

  • To use transparent data transmission, simply send “AT+TPMODE=1” before setting the Wi-Fi mode.

SSL Client Application

SSL Client Application Flowchart

@startuml
hide footbox
skinparam sequenceMessageAlign center

box  #LightBlue
actor “ ” as person
participant “USER MCU” as mcu
participant MODULE as module
participant " " as nu
participant "SSL Server" as server
end box

person ->> mcu: Start the operation
mcu -> module: AT+ROLE=1
note left
    Switch to STA mode
end note
module --> mcu: OK
mcu -> module: AT+RAP=SSID,PASSWORD
note left
    Connect to AP
end note
module --> mcu: OK
group LOOP Query until the IP address\nis obtained
mcu -> module: AT+LIP
note left
    Query the module's IP
end note
module --> mcu: +LIP=0.0.0.0
note right
    Not connected to AP
end note
end
module --> mcu: +LIP=192.168.0.97
note right
    Connected to AP
end note
mcu -> module: AT+SOCK=\nSSL,9100,httpbin.org,443
note left
    Set module
    as SSL Client
end note
module --> mcu: OK
mcu -> module: AT+WLANC=3
note left
    Start SSL Client
end note
module --> mcu: OK

module-> nu: The remote end\ninitiates a connection
server -> nu: Module is connected
mcu -> module: AT+SSLSEND=\n40,GET /get HTTP/1.1\\r\\n\nHost: httpbin.org\\r\\n\\r\\n
note left
    send GET request
end note
module --> nu: module send\nHTTPS request
server -> nu: Server response
note right
    module outputs
    the received data
end note
@enduml

SSL Client Application Example

  1. Set the Wi-Fi mode. If you are already in the current mode, you can skip this step

Send:<< AT+ROLE=1
Response:>> OK
  1. Connect to AP

Send:<< AT+RAP=ssid,password
Response:>> OK
  1. Query the IP address of the module

Send:<< AT+LIP
Response:>> +LIP=192.168.0.97   //For local examples, please refer to the actual IP address obtained by connecting to the AP
Response:>> OK
  1. Set the module as SSL client and configure the remote server and port number

Send:<< AT+SOCK=SSL,9100,httpbin.org,443
Response:>> OK
  1. The module initiates a connection to the remote end as an SSL client

Send:<< AT+WLANC=3
Response:>> OK
  1. Send relevant requests, such as GET requests

Send:<< AT+SSLSEND=40,GET /get HTTP/1.1\\r\\nHost: httpbin.org\\r\\n\\r\\n
Response:>> OK
  1. Receive data

Response:>> +SSLDATA=Specific data

Note

  • Note: If you want to use transparent data transmission, just send AT+TPMODE=1 before setting the Wi-Fi mode.

MQTT Application

MQTT Application Flowchart

@startuml
hide footbox
skinparam sequenceMessageAlign center

box  #LightBlue
actor “ ” as person
participant “USER MCU” as mcu
participant MODULE as module
participant " " as nu
participant "AliCloud" as cloud
end box

person ->> mcu: Start the operation
module --> mcu:
note right
    Connected to AP
end note
mcu -> module: AT+BROKER=addr
note left
    Set BROKER address
end note
module --> mcu: OK
mcu -> module: AT+USERNAME=username
note left
    Set UserName
end note
module --> mcu: OK
mcu -> module: AT+MQTTPWD=password
note left
    Set PassWord
end note
module --> mcu: OK
mcu -> module: AT+CLIENTID=ID
note left
    Set ClientID
end note
module --> mcu: OK
mcu -> module: AT+SUBTPC=tpoic,qos
note left
    Subscribe to topics
end note
module --> mcu: OK
mcu -> module: AT+WLANC=4
note left
    Module initiated
    connection
end note
module --> mcu: OK
module -> nu: Start connection
nu -> cloud: Connect to MQTT
cloud -> nu: Data sent from the\ncloud :1234567890
note right
    module outputs
    the received data
end note
note left
    module sends data
    to the cloud
end note
module --> mcu: OK
nu -> cloud: abc
@enduml

MQTT Application Example

  1. Set the Wi-Fi mode

Send:<< AT+ROLE=1
Response:>> OK
  1. Connect to AP

Send:<< AT+RAP=ssid,password
Response:>> OK
  1. Query the IP address of the module

Send:<< AT+LIP
Response:>> +LIP=192.168.0.97   //For local examples, please refer to the actual IP address obtained by connecting to the AP
Response:>> OK
  1. Set the BROKER address

Send:<< AT+BROKER=gpssensor.ddns.net
Response:>> OK
  1. Set User Name

Send:<< AT+USERNAME=admin
Response:>> OK
  1. Set Password

Send:<< AT+MQTTPWD=12345678
Response:>> OK
  1. Subscribe to topics

Send:<< AT+SUBTPC=user/get,0
Response:>> OK
  1. Connect to MQTT

Send:<< AT+WLANC=4
Response:>> OK
  1. Receive the data sent by the cloud platform

1234567890
  1. Send data to the cloud platform

Send:<< AT+MQTTPUB=user/post,0,3,abc
Response:>> OK