nRF51 SDK - S210 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
ANT-FS Client

The ANT-FS client device simulator example illustrates the basic operations of an ANT-FS client.

This example supports all three methods of authentication defined in the ANT-FS specification: pairing, passkey and pass-thru. It also supports the simulation of downloading, uploading and erasing files. Other functionality that is not defined in the ANT-FS specification, such as file system implementation and data decoding/encoding are outside of scope of this implementation.

Note
This example does not implement the client undiscoverable mode as defined by the ANT-FS specification.

The general architecture of the ANT-FS client device simulator is illustrated in the picture below.

ant_fs_embedded_client_device_simulator_architecture.png
Architecture overview
ANT-FS specific configuration options

The following compile time configuration options are available to suite various ANT-FS implementations:

  • ANTFS_NETWORK_KEY The ANT-FS Network Key.
  • ANTFS_DEVICE_TYPE The Device Type (Channel ID).
  • ANTFS_TRANS_TYPE Transmission Type (Channel ID).
  • ANTFS_LINK_FREQ RF channel frequency of the client device while in the Link layer. The default value is 2450MHz.
  • ANTFS_BEACON_PERIOD_STATUS Message period of the client device while in the Link layer. The default value is 4 Hz.
  • ANTFS_LINK_COMMAND_TIMEOUT Time (in seconds) the client device will wait without receiving any commands from the host before switching to the Link layer.
  • ANTFS_PAIRING_TIMEOUT Time (in seconds) the client will wait for user response to a pairing request during the authentication stage.
  • ANTFS_CLIENT_SERIAL_NUMBER Serial number of the client device. The device number in the Channel ID is derived from the lower two bytes of the serial number. The four bytes of the serial number are sent to the host during the Authenticate layer as the device ID.
  • ANTFS_CLIENT_NAME Friendly name of the client device. The length of this string should not exceed ANTFS_REMOTE_FRIENDLY_NAME_MAX.
  • ANTFS_CLIENT_DEV_TYPE Device Type (ANT-FS Client Identifier).
  • ANTFS_CLIENT_MANUF_ID Manufacturing ID (ANT-FS Client Identifier).
  • ANTFS_CLIENT_PASSKEY Passkey used in the pairing and passkey authentication methods. Its length should be equal to ANTFS_PASSKEY_SIZE.

This example implements the pairing, pass key and pass-thru authentication methods, which can be enabled using compile switches. All three authentication methods are enabled by default. Upload functionality can also be enabled through a compile switch and it is by default turned on. The compile switches can be set on antfs.c and are listed below.

  • ANTFS_AUTH_TYPE_PAIRING Pairing authentication supported.
  • ANTFS_AUTH_TYPE_PASSKEY Passkey authentication supported.
  • ANTFS_AUTH_TYPE_PASSTHROUGH Pass-through authentication supported.
  • ANTFS_INCLUDE_UPLOAD Upload operation is supported.

To establish communication, the host and client devices shall have corresponding configurations. The host device may wish to wildcard any of the fields in the Channel ID and Client Identifier by setting them to zero, but the network key and RF channel frequency shall be the same. The channel period of the client need not match the channel period of the host.

A simple user interface exists consisting of 2 keypad buttons, which are active during pairing authentication for user to accept or reject the authentication, and 2 LEDs which are active during reception of EVENT_TX and pairing authentication mode. LED1 been toggled for every EVENT_TX received from the and stack and LED2 turned on when in pairing authentication mode. The LEDs can be configured in the leddriver.c file.

General operation

The ANT-FS client device simulator executes automatically through each ANT-FS layer, as per the commands received from the ANT-FS host. User interaction is only required when using pairing authentication, to confirm or reject a pairing request.

Once a ANT-FS host detects a client with ANT channel and ANT-FS client parameters matching its search criteria, it will send a Link command to the client, specifying the Link RF channel frequency and channel period. The client will automatically switch to the new frequency and channel period, and indicate in its beacon that it has moved to the Authentication stage.

Authenticate

Once both the ANT-FS client and host are in the authentication layer the host can send a request to client device for pairing. The ANT-FS client example supports three methods of authentication: pairing, passkey and pass-thru. When using the passkey and pass-thru authentication methods, the client will automatically accept or reject the authentication as outlined by the ANT-FS specification. Intervention from the user is only required when using the pairing authentication method. If the client receives a pairing request from the host, it will turn on a LED to let the user know that a host device wishes to pair with it. The user can accept or reject the pairing request by pressing the one of the appropriate buttons. If no response from the user is received before the pairing timeout expires, the request will be rejected.

Download

A sample directory structure is implemented in this example, however, no actual files or file systems are present in the example. The client will send the directory to the host if it receives a request to download the directory (file index0). When the host requests a download for any other files, the client will check if the file exists in its directory, and if there is permission to download that file. If the file can be downloaded, the client will simulate a file by sending sequential data with size matching the requested file size; otherwise, it will reject the download.

Upload

When the host requests an upload, the client will check if the file index exists in its directory, if there is permission to write on that file, and if there is enough space to write the requested data. Once the client sends a response accepting the upload request, the host can start uploading data. The device simulator does not include actual files, so data is not written to memory; however, the client keeps track of the CRC of the received data to verify the integrity of the upload.

Erase

If the client receives a request to erase a file, it will check in its directory to see if the file exists and if there is permission to erase that file. As there are no actual files to delete in this example, if the file can be erased, the client will simply send a response to the host indicating the file was erased; otherwise, it will reject the request.

Development phase configuration options

The ANT-FS client device simulator will trace out ANT-FS protocol state information to UART when AN-FS protocol events occur. The UART peripheral can be configured in the main.c file.

The following compile time configuration options are available to assist in the development phase of the ANT-FS client implementation:

  • TRACE_MEM_WRITE_OFF When defined tracing the file upload content buffer to UART is disabled.
  • LEDDRIVER_ACTIVE When defined LED usage is enabled (disabled by default).
  • TRACE_UART When defined UART trace outputting is enabled (disabled by default).

The name of the example is ant_fs_client_s210_pca10028. If you are not using the Keil Pack Installer, you can find the source code and project file of the example in the following folder: <InstallFolder>\Nordic\nrf51\examples\ant\ant_fs\client