SX10509: Server Commands in more detail

Below is a full explanation of the network commands. Click here for a tutorial with examples of using several of the commands.

Idle '00 / '80

Force the SX10509 to the idle state. It's a good idea to send this command at the end of each session to idle the command processor and ensure it's ready for the next series of commands. The Xwire transmit buffer takes the following form:

Command

Once this command is executed, the Xwire receive data block takes the following form:

CommandEcho (Equal to the Command byte sent to the SX10509)

Write '01 / '81

This command is used to load the data that will be sent to the server. If using a GET request, you must ensure the data

is URL escaped according to RFC3986 Section 2 "Characters", see http://tools.ietf.org/html/rfc3986#section-2 .

A POST request has no such restriction allowing data to be sent as is. The Xwire transmit buffer takes the following form:

Command, bLength, Data...

Where:

Once this command is executed, the Xwire receive data block takes the following form:

CommandEcho (Equal to the Command byte sent to the SX10509)

Read '02 / '82

This command may be used to read data returned by the server in response to a DoGet or DoPost. The DoGet and DoPost responses will indicate how much data is available. The Xwire transmit buffer takes the following form:

Command, bOffsetInc

Where:

Once this command is executed, the Xwire receive data block takes the following form:

CommandEcho, bLength, Data...

Where:

Server '03 / '83

Set the server name where the request will be sent (example: www.splatco.com). Don't use a leading protocol, ie "http://" as this will automatically be appended by the SX10509. The server name must not exceed 63 characters in length. The Xwire transmit buffer takes the following form:

Command, bLength, Data...

Where:

Consecutive iterations of the Server command will append data to that already sent. This allows a long server string to be constructed.

Once this command is executed, the Xwire receive data block takes the following form:

CommandEcho (Equal to the Command byte sent to the SX10509)

This command is needed only if the server needs to be changed from the power-up default set in the Server tab of the SX10509 configuration screen.

Port '04 / '84

Set the server port where the request should be sent. The Xwire transmit buffer takes the following form:

Command, fPort

Where:

Once this command is executed, the Xwire receive data block takes the following form:

CommandEcho (Equal to the Command byte sent to the SX10509)

This command is needed only if the port needs to be changed from the power-up default set in the Server tab of the SX10509 configuration screen.

Path '05 / '85

Set the path to the script on the server. Don't use a leading "/". The path must not exceed 63 characters in length. The Xwire transmit buffer takes the following form:

Command, bLength, Data...

Where:

Consecutive iterations of the Path command will append data to that already sent to the SX10509. This allows a long path string to be constructed.

Once this command is executed, the Xwire receive data block takes the following form:

CommandEcho (Equal to the Command byte sent to the SX10509)

This command is needed only if the path needs to be changed from the power-up default set in the Server tab of the configuration screen.

ContentType '06 / '86

Set the content type (also known as media type) when using a POST request. This is not used when performing a GET request. The content type must not exceed 39 characters in length. The Xwire transmit buffer takes the following form:

Command, bLength, Data...

Where:

Consecutive iterations of the ContentType command will append data to that already sent to the SX10509. This allows a long type string to be constructed.

Once this command is executed, the Xwire receive data block takes the following form:

CommandEcho (Equal to the Command byte sent to the SX10509)

This command is needed only if the content type needs to be changed from the power-up default set in the Server tab of the configuration screen.

DoGet '07 / '87

Send a GET request based on the Server, Port, Path and Data that has previously been loaded into the SX10509.

The Xwire transmit buffer take ths following form:

Command

It may take several seconds for the request to be sent and the reply received. Loading any other command while the GET

request is in progress will cancel the GET request. The Xwire receive data block for the reply takes the following form:

CommandEcho,bLength,fResult

Where:

DoPost '08 / '88

This is just like the DoGet command, except a POST request will be sent instead. For this command, the ContentType string will also be used.

Otherwise, this command is identical to the DoGet command, so please refer to that section for more details.

GetID '09 / '89

This command fetches the unique ID of the SX10509. This ID is fixed and cannot be modified.

The Xwire transmit buffer takes the following form:

Command

On completion of the command the Xwire receive data block will take the form:

CommandEcho,bLength,IDString...

Where:

To help the server identify the source of each request, this ID is automatically sent to the server in the http header

within a field named "X-SPLat-ID", for example, here's a full POST request sent by the SX10509:

   -------------------------------------
   POST /sch/weather.php HTTP/1.0
   Host: www.splatco.com:80
   Content-Type: application/x-www-form-urlencoded
   Content-Length: 14
   X-SPLat-ID: 3691053277
   Connection: close
  
   city=melbourne
   -------------------------------------     

The "city=melbourne" line was sent by the SPLat application using the Write command.

If your server script is written in PHP, a simple method for the server-side script to obtain this ID is as follows:

$id = $_SERVER['HTTP_X_SPLAT_ID'];

GetGMT '0A / '8A

This command fetches the current epoch time in seconds since 1/1/1970, GMT. This time may be used in a request sent to a server as a timestamp. The Xwire transmit buffer takes the following form:

Command

On completion of the command the Xwire receive data block will take the form:

CommandEcho,bLength,GMTString...

Where:

GetIP '0B / '8B

This command returns the current LAN IP address of the SX10509. The first three bytes are the IP address as 8-bit unsigned values.

For example, an address of 192.168.1.23 is returned as 192,168,123. The Xwire transmit buffer takes the following form:

Command

On completion of the command the Xwire receive data block will take the form:

CommandEcho,IP_1,IP_2,IP_3

Where: