User`s guide

134
CipherLab BASIC Compiler
User's Guide
2. Initialize the 802.11b/Bluetooth module and networking protocol stack
(1) START TCPIP
The 802.11b/Bluetooth module will not be powered until the START TCPIP
routine is called. When the application program stops using the network, the STOP
TCPIP routine can be called to terminate networking and shut down the
802.11b/Bluetooth module so that it can save power. Note that any previous
network connection and data will be lost after calling STOP TCPIP. To enable the
networking again, it is necessary to call START TCPIP again.
(2) GET_TCPIP_MESSAGE
The START TCPIP routine does the first stage of the initialization process, and it
will generate a system task to finish the rest of the process. When the START
TCPIP routine returns, the initialization process might not have been done yet.
Therefore, it is necessary for the application program to check whether the status is
“IP is ready” by calling GET_TCPIP_MESSAGE or GET_NET_STATUS before it
proceeds to perform any networking operations.
(3) GET_NET_STATUS
Once the initialization process is done, the status of the 802.11b/Bluetooth module
can be retrieved from the system. It will be periodically updated by the system. The
application program must explicitly call the GET_NET_STATUS routine to get the
latest status.
3. Open a Connection
(1) TCP_OPEN
Before reading and writing to the remote host, a connection must be established
(opened). The TCP_OPEN routine is used to open a connection. The application
program needs to define a connection number (0~3), so that it can identify a
particular connection in subsequent calls to other TCP/IP stack routines.
(2) GET_TCPIP_MESSAGE
It is necessary for the application to check whether the status of the particular
connection is “connected” by calling GET_TCPIP_MESSAGE before it proceeds
to perform any read/write operations.
4. Data transmission
(1) SOCKET_CAN_SEND
Before sending data to the network, SOCKET_CAN_SEND can be used to check if
there is enough buffer size to write out the data immediately. It also can be used to
check if the data being sent is more than 4 packets when there is no response from
the remote host.
(2) NREAD$/NWRITE
The routines NREAD$ and NWRITE are used to send and receive data on the
network respectively.