ANT-FS client device simulator

nRF5 SDK v14.2.0

The ANT-FS client device simulator. More...

Data Structures

union antfs_beacon_status_byte1_t
ANT-FS beacon status. More...
struct antfs_event_return_t
ANT-FS <-> application event communication object. More...
struct antfs_params_t
ANT-FS parameters. More...
struct antfs_dir_header_t
ANT-FS directory header. More...
struct antfs_dir_struct_t
ANT-FS directory entry. More...
struct antfs_request_info_t
ANT-FS download/upload request context. More...

Macros

#define ANTFS_VERSION_MAJOR 1u
#define ANTFS_VERSION_MINOR 0
#define ANTFS_VERSION_ITERATION 0
#define ANTFS_VERSION_TYPE 'R'
#define ANTFS_VERSION_SPEC '0.AK'
#define ANTFS_DIR_STRUCT_VERSION 1u
#define ANTFS_VERSION_DATE 20090522u
#define ANTFS_LINK_FREQ 50u
#define ANTFS_CHANNEL_TYPE CHANNEL_TYPE_MASTER
#define ANTFS_AUTH_STRING_MAX 255u
#define ANTFS_PASSKEY_SIZE 16u
#define ANTFS_FRIENDLY_NAME_MAX 16u
#define ANTFS_REMOTE_FRIENDLY_NAME_MAX 16u
#define BEACON_PERIOD_SHIFT 0x00
#define BEACON_PERIOD_MASK (0x07u << BEACON_PERIOD_SHIFT)
#define BEACON_PERIOD_0_5_HZ (0x00 << BEACON_PERIOD_SHIFT)
#define BEACON_PERIOD_1_HZ (0x01u << BEACON_PERIOD_SHIFT)
#define BEACON_PERIOD_2_HZ (0x02u << BEACON_PERIOD_SHIFT)
#define BEACON_PERIOD_4_HZ (0x03u << BEACON_PERIOD_SHIFT)
#define BEACON_PERIOD_8_HZ (0x04u << BEACON_PERIOD_SHIFT)
#define PAIRING_AVAILABLE_FLAG_SHIFT 0x03u
#define PAIRING_AVAILABLE_FLAG_MASK (0x01u << PAIRING_AVAILABLE_FLAG_SHIFT)
#define UPLOAD_ENABLED_FLAG_SHIFT 0x04u
#define UPLOAD_ENABLED_FLAG_MASK (0x01u << UPLOAD_ENABLED_FLAG_SHIFT)
#define DATA_AVAILABLE_FLAG_SHIFT 0x05u
#define DATA_AVAILABLE_FLAG_MASK (0x01u << DATA_AVAILABLE_FLAG_SHIFT)
#define RESPONSE_MESSAGE_OK 0x00u
#define RESPONSE_MESSAGE_NOT_EXIST 0x01u
#define RESPONSE_MESSAGE_NOT_AVAILABLE 0x02u
#define RESPONSE_INVALID_OPERATION 0x04u
#define RESPONSE_MESSAGE_NOT_READY 0x03u
#define RESPONSE_INVALID_CRC 0x05u
#define RESPONSE_MESSAGE_NOT_ENOUGH_SPACE 0x03u
#define RESPONSE_MESSAGE_UPLOAD_NOT_READY 0x05u
#define RESPONSE_MESSAGE_FAIL 0x01u
#define ANTFS_DIR_READ_MASK 0x80u
#define ANTFS_DIR_WRITE_MASK 0x40u
#define ANTFS_DIR_ERASE_MASK 0x20u
#define ANTFS_DIR_ARCHIVE_MASK 0x10u
#define ANTFS_DIR_APPEND_MASK 0x08u
#define ANTFS_MAX_FILE_SIZE 0xFFFFFFFFu
#define ANTFS_BURST_BLOCK_SIZE 16u

Typedefs

typedef void(* antfs_burst_wait_handler_t )(void)
The burst wait handler can be configured by the application to customize the code that is executed while waiting for the burst busy flag.

Functions

void antfs_init (const antfs_params_t *const p_params, antfs_burst_wait_handler_t burst_wait_handler)
Function for setting initial ANT-FS configuration parameters. More...
const char * antfs_hostname_get (void)
Function for getting host name if received. More...
bool antfs_pairing_resp_transmit (bool accept )
Function for transmitting a response to a pairing request issued by ANT-FS host. More...
void antfs_download_req_resp_prepare (uint8_t response, const antfs_request_info_t *const p_request_info)
Function for doing calculations prior downloading the data to the ANT-FS host. More...
uint32_t antfs_input_data_download (uint16_t index, uint32_t offset, uint32_t num_bytes, const uint8_t *const p_message)
Function for downloading requested data. More...
bool antfs_upload_req_resp_transmit (uint8_t response, const antfs_request_info_t *const p_request_info)
Function for transmitting upload request response to a upload request command by ANT-FS host. More...
bool antfs_upload_data_resp_transmit (bool data_upload_success)
Function for transmitting upload data response to a upload data command by ANT-FS host. More...
void antfs_erase_req_resp_transmit (uint8_t response)
Function for transmitting erase response to a erase request. More...
bool antfs_event_extract ( antfs_event_return_t *const p_event)
Function for extracting possible pending ANT-FS event. More...
void antfs_message_process (uint8_t *p_message)
Function for processing ANT events and data received from the ANT-FS channel. More...
void antfs_channel_setup (void)
Function for setting up the ANT-FS channel.

Detailed Description

The ANT-FS client device simulator.

Note
The ANT-FS Network Key is available for ANT+ Adopters. Please refer to http://thisisant.com to become an ANT+ Adopter and access the key.

Macro Definition Documentation

#define ANTFS_AUTH_STRING_MAX   255u

Maximum size of authentication strings (passkey/friendly name).

#define ANTFS_BURST_BLOCK_SIZE   16u

Size of each block of burst data that the client attempts to send when it processes a data request event.

#define ANTFS_CHANNEL_TYPE CHANNEL_TYPE_MASTER

ANT-FS Client Channel Type.

#define ANTFS_DIR_APPEND_MASK   0x08u

Append (can append to file only).

#define ANTFS_DIR_ARCHIVE_MASK   0x10u

Archive (has been downloaded).

#define ANTFS_DIR_ERASE_MASK   0x20u

Erase (can erase).

#define ANTFS_DIR_READ_MASK   0x80u

Read (can download).

#define ANTFS_DIR_STRUCT_VERSION   1u

Version of the directory file structure.

#define ANTFS_DIR_WRITE_MASK   0x40u

Write (can upload).

#define ANTFS_FRIENDLY_NAME_MAX   16u

Maximum size of friendly name received from host.

#define ANTFS_LINK_FREQ   50u

RF Frequency (+2400MHz).

#define ANTFS_MAX_FILE_SIZE   0xFFFFFFFFu

Maximum file size, as specified by directory structure.

#define ANTFS_PASSKEY_SIZE   16u

Passkey size.

#define ANTFS_REMOTE_FRIENDLY_NAME_MAX   16u

Maximum size of client's friendly name.

#define ANTFS_VERSION_DATE   20090522u

Version date.

#define ANTFS_VERSION_ITERATION   0

Version iteration.

#define ANTFS_VERSION_MAJOR   1u

Version major number.

#define ANTFS_VERSION_MINOR   0

Version minor number.

#define ANTFS_VERSION_SPEC   '0.AK'

Version of the ANT-FS Technology Specification.

#define ANTFS_VERSION_TYPE   'R'

Version type is release.

#define BEACON_PERIOD_0_5_HZ   (0x00 << BEACON_PERIOD_SHIFT)

Value for 0,5Hz beacon period.

#define BEACON_PERIOD_1_HZ   (0x01u << BEACON_PERIOD_SHIFT)

Value for 1Hz beacon period.

#define BEACON_PERIOD_2_HZ   (0x02u << BEACON_PERIOD_SHIFT)

Value for 2Hz beacon period.

#define BEACON_PERIOD_4_HZ   (0x03u << BEACON_PERIOD_SHIFT)

Value for 4Hz beacon period.

#define BEACON_PERIOD_8_HZ   (0x04u << BEACON_PERIOD_SHIFT)

Value for 8Hz beacon period.

#define BEACON_PERIOD_MASK   (0x07u << BEACON_PERIOD_SHIFT)

Beacon period bitmask.

#define BEACON_PERIOD_SHIFT   0x00

Shift value for masking out beacon period.

#define DATA_AVAILABLE_FLAG_MASK   (0x01u << DATA_AVAILABLE_FLAG_SHIFT)

Data available bitmask.

#define DATA_AVAILABLE_FLAG_SHIFT   0x05u

Shift value for masking out data available bit.

#define PAIRING_AVAILABLE_FLAG_MASK   (0x01u << PAIRING_AVAILABLE_FLAG_SHIFT)

Pairing enabled bitmask.

#define PAIRING_AVAILABLE_FLAG_SHIFT   0x03u

Shift value for masking out pairing enabled bit.

#define RESPONSE_INVALID_CRC   0x05u

CRC incorrect.

#define RESPONSE_INVALID_OPERATION   0x04u

Request invalid.

#define RESPONSE_MESSAGE_FAIL   0x01u

Data File Index does not exist / Erase failed.

#define RESPONSE_MESSAGE_NOT_AVAILABLE   0x02u

File can not be read/written to (download/upload respectively).

#define RESPONSE_MESSAGE_NOT_ENOUGH_SPACE   0x03u

Not enough space to to complete write.

#define RESPONSE_MESSAGE_NOT_EXIST   0x01u

File does not exist.

#define RESPONSE_MESSAGE_NOT_READY   0x03u

Not ready to download.

#define RESPONSE_MESSAGE_OK   0x00u

Download request ok.

#define RESPONSE_MESSAGE_UPLOAD_NOT_READY   0x05u

Not ready to upload

#define UPLOAD_ENABLED_FLAG_MASK   (0x01u << UPLOAD_ENABLED_FLAG_SHIFT)

Upload enabled bitmask.

#define UPLOAD_ENABLED_FLAG_SHIFT   0x04u

Shift value for masking out upload enabled bit.

Enumeration Type Documentation

Enumerator
ANTFS_AUTH_SUBSTATE_NONE

None state.

ANTFS_AUTH_SUBSTATE_PAIR

Pairing state.

ANTFS_AUTH_SUBSTATE_PASSKEY

Passkey state.

ANTFS_AUTH_SUBSTATE_ACCEPT

Authenticate accept state.

ANTFS_AUTH_SUBSTATE_REJECT

Authenticate reject state.

Enumerator
ANTFS_EVENT_PAIRING_REQUEST

Pairing request event.

ANTFS_EVENT_PAIRING_TIMEOUT

Pairing timeout event.

ANTFS_EVENT_OPEN_COMPLETE

Channel setup complete event.

ANTFS_EVENT_CLOSE_COMPLETE

Channel closed event.

ANTFS_EVENT_LINK

Enter link layer event.

ANTFS_EVENT_AUTH

Enter authenticate layer event.

ANTFS_EVENT_TRANS

Enter transport layer event.

ANTFS_EVENT_DOWNLOAD_REQUEST

Download request event.

ANTFS_EVENT_DOWNLOAD_REQUEST_DATA

Download request data event.

ANTFS_EVENT_DOWNLOAD_START

Download started event.

ANTFS_EVENT_DOWNLOAD_COMPLETE

Download completed event.

ANTFS_EVENT_DOWNLOAD_FAIL

Download failed event.

ANTFS_EVENT_UPLOAD_REQUEST

Upload request event.

ANTFS_EVENT_UPLOAD_DATA

Upload data available for read event.

ANTFS_EVENT_UPLOAD_START

Upload begin event.

ANTFS_EVENT_UPLOAD_COMPLETE

Upload completed event.

ANTFS_EVENT_UPLOAD_FAIL

Upload process failed event.

ANTFS_EVENT_ERASE_REQUEST

Erase request event.

Enumerator
ANTFS_LINK_SUBSTATE_NONE

None state.

Enumerator
ANTFS_STATE_OFF

Off state.

ANTFS_STATE_INIT

Init state.

ANTFS_STATE_LINK

Link state.

ANTFS_STATE_AUTH

Authenticate state.

ANTFS_STATE_TRANS

Transport state.

Enumerator
ANTFS_TRANS_SUBSTATE_NONE

None state.

ANTFS_TRANS_SUBSTATE_VERIFY_CRC

Verify CRC state.

ANTFS_TRANS_SUBSTATE_DOWNLOADING

Downloading state.

ANTFS_TRANS_SUBSTATE_UPLOAD_WAIT_FOR_DATA

Wait for upload data request state.

ANTFS_TRANS_SUBSTATE_UPLOADING

Ready / receiving upload data state.

ANTFS_TRANS_SUBSTATE_UPLOAD_RESUME

RX failure upon receiving upload data state.

Function Documentation

void antfs_download_req_resp_prepare ( uint8_t response ,
const antfs_request_info_t *const p_request_info
)

Function for doing calculations prior downloading the data to the ANT-FS host.

Function does the necessary pre processing calculations, which are required prior downloading the data, and also transmits the download request response right away in case of the download request was rejected or there is no data to send.

Parameters
[in] response The download request response code.
[in] p_request_info ANT-FS request info structure.
void antfs_erase_req_resp_transmit ( uint8_t response )

Function for transmitting erase response to a erase request.

Parameters
[in] response The erase response code.
bool antfs_event_extract ( antfs_event_return_t *const p_event )

Function for extracting possible pending ANT-FS event.

Parameters
[out] p_event The output event structure.
Return values
true Operation success. Pending ANT-FS event available and it was copied to the output event structure.
false Operation failure. No pending ANT-FS event available.
const char* antfs_hostname_get ( void )

Function for getting host name if received.

Returns
Pointer to host name buffer if a host name was recieved, NULL otherwise.
void antfs_init ( const antfs_params_t *const p_params ,
antfs_burst_wait_handler_t burst_wait_handler
)

Function for setting initial ANT-FS configuration parameters.

Parameters
[in] p_params The initial ANT-FS configuration parameters.
[in] burst_wait_handler Burst wait handler.
uint32_t antfs_input_data_download ( uint16_t index ,
uint32_t offset ,
uint32_t num_bytes ,
const uint8_t *const p_message
)

Function for downloading requested data.

Parameters
[in] index Index of the current file downloaded.
[in] offset Offset specified by client.
[in] num_bytes Number of bytes requested to be transmitted from the buffer.
[in] p_message Data buffer to be transmitted.
Returns
Number of data bytes transmitted.
void antfs_message_process ( uint8_t * p_message )

Function for processing ANT events and data received from the ANT-FS channel.

Parameters
[in] p_message The message buffer containing the message received from the ANT-FS channel.
bool antfs_pairing_resp_transmit ( bool accept )

Function for transmitting a response to a pairing request issued by ANT-FS host.

Parameters
[in] accept The pairing response, true if pairing accepted.
Return values
true Operation success. Response to a pairing request was transmitted.
false Operation failure. Not in pairing mode or pairing not supported by the implementation.
bool antfs_upload_data_resp_transmit ( bool data_upload_success )

Function for transmitting upload data response to a upload data command by ANT-FS host.

Parameters
[in] data_upload_success The upload response code, true for success.
Return values
true Operation success. Response to upload data command was transmitted.
false Operation failure. Upload not supported by the implementation or not in correct state.
bool antfs_upload_req_resp_transmit ( uint8_t response ,
const antfs_request_info_t *const p_request_info
)

Function for transmitting upload request response to a upload request command by ANT-FS host.

Parameters
[in] response The upload response code.
[in] p_request_info ANT-FS request info structure.
Return values
true Operation success. Response to upload request command was transmitted.
false Operation failure. Upload not supported by the implementation or not in correct state or application is sending a response for a different file than requested.