nRF51 SDK - S210 SoftDevice
|
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... | |
union | ushort_union_t |
uint16_t type presentation as an union. More... | |
union | ulong_union_t |
uint32_t type presentation as an union. More... | |
Functions | |
void | antfs_init (const antfs_params_t *const p_params) |
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. | |
uint16_t | crc_crc16_update (uint16_t current_crc, const volatile void *p_data, uint32_t size) |
Function for calculating CRC-16 in blocks. More... | |
void | leddriver_init (void) |
Function for configuring all the GPIOs needed by the driver. | |
void | leddriver_led_turn_on (leddriver_led_id_t led_id) |
Function for turning on a single LED. More... | |
void | leddriver_led_turn_off (leddriver_led_id_t led_id) |
Function for turning off a single LED. More... | |
void | leddriver_led_toggle (leddriver_led_id_t led_id) |
Function for toggling a single LED. More... | |
bool | mem_file_write (uint16_t index, uint32_t offset, const void *p_data, uint32_t size) |
Function for writing data to file system. More... | |
void | mem_file_read (uint16_t index, uint32_t offset, void *p_data, uint32_t size) |
Function for reading data from file system. More... | |
bool | mem_file_erase (uint16_t index) |
Function for erasing file from file system. More... | |
bool | mem_file_info_get (uint16_t index, antfs_dir_struct_t *p_file_info) |
Function for retrieving file information from directory. More... | |
void | softdevice_assert_callback (uint32_t pc, uint16_t line_num, const uint8_t *p_file_name) |
Function for handling SoftDevice asserts, does not return. More... | |
void | app_error_handler (uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name) |
Function for handling an error. More... | |
void | SD_EVT_IRQHandler (void) |
Function for handling protocol stack IRQ. More... | |
void | button_event_handler (uint8_t pin_no, uint8_t button_action) |
Function for handling button events. More... | |
int | main (void) |
Function for application main entry, does not return. More... | |
The ANT-FS client device simulator.
#define ANT_EVENT_MSG_BUFFER_MIN_SIZE 32u |
Minimum size of ANT event message buffer.
#define ANTFS_AUTH_STRING_MAX 255u |
Maximum size of authentication strings (passkey/friendly name).
#define ANTFS_BEACON_PERIOD_STATUS BEACON_PERIOD_4_HZ |
ANT-FS Beacon Message Period.
#define ANTFS_BURST_BLOCK_SIZE 20u |
Size of each block of burst data that the client attempts to send when it processes a data request event.
#define ANTFS_CHANNEL 0 |
ANT Channel Number.
#define ANTFS_CHANNEL_TYPE CHANNEL_TYPE_MASTER |
ANT-FS Client Channel Type.
#define ANTFS_CLIENT_DEV_TYPE 416u |
Beacon device type.
#define ANTFS_CLIENT_MANUF_ID 2u |
Beacon manufacturer ID.
#define ANTFS_CLIENT_NAME { "Ref Design" } |
Client's friendly name.
#define ANTFS_CLIENT_PASSKEY {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10} |
Client passkey.
#define ANTFS_CLIENT_SERIAL_NUMBER 0xABCDEF12u |
Serial number of client device.
#define ANTFS_CUSTOM_TRANSMIT_POWER 0u |
ANT Custom Transmit Power (0dBm).
#define ANTFS_DEFAULT_BEACON (ANTFS_BEACON_PERIOD_STATUS | ANTFS_UPLOAD_BIT | ANTFS_PAIRING_BIT | DATA_AVAILABLE_FLAG_MASK) |
Define the default beacon setting.
#define ANTFS_DEVICE_TYPE 1u |
ANT-FS Device 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_COMMAND_TIMEOUT 10u |
Command timeout (time the client will wait without receiving any commands before switching to the link layer, in seconds).
#define ANTFS_LINK_FREQ 50u |
RF Frequency (+2400MHz).
#define ANTFS_MAX_FILE_SIZE 0xFFFFFFFFu |
Maximum file size, as specified by directory structure.
#define ANTFS_NETWORK_NUMBER 0 |
ANT-FS Network Number.
#define ANTFS_PAIRING_BIT 0x00u |
Build pairing disabled default beacon setting.
#define ANTFS_PAIRING_TIMEOUT 120u |
Pairing timeout (time the UI will wait for a response to the pairing request before switching to the link layer, in seconds).
#define ANTFS_PASSKEY_SIZE 16u |
Passkey size.
#define ANTFS_REMOTE_FRIENDLY_NAME_MAX 16u |
Maximum size of client's friendly name.
#define ANTFS_TRANS_TYPE 5u |
ANT-FS Transmission Type.
#define ANTFS_TRANSMIT_POWER 3u |
ANT Transmit Power (0dBm).
#define ANTFS_UPLOAD_BIT 0x00u |
Build upload disabled default beacon setting.
#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 APP_GPIOTE_MAX_USERS 1u |
Maximum number of users of the GPIOTE handler.
#define APP_TIMER_MAX_TIMERS 2u |
Maximum number of simultaneously created timers.
#define APP_TIMER_OP_QUEUE_SIZE 4u |
Size of timer operation queues.
#define APP_TIMER_PRESCALER 0 |
Value of the RTC1 PRESCALER register.
#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 BUTTON_DETECTION_DELAY APP_TIMER_TICKS(50u, APP_TIMER_PRESCALER) |
Delay from a GPIOTE event until a button is reported as pushed (in number of timer ticks).
#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 MAX_ULONG 0xFFFFFFFFu |
The Max value for the type.
#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 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.
enum antfs_event_t |
enum antfs_state_t |
enum leddriver_led_id_t |
enum pairing_state_t |
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.
[in] | response | The download request response code. |
[in] | p_request_info | ANT-FS request info structure. |
< ANT-FS download request command ID.
void antfs_erase_req_resp_transmit | ( | uint8_t | response | ) |
Function for transmitting erase response to a erase request.
[in] | response | The erase response code. |
< ANT-FS erase request command ID.
< The burst packet size.
< The ANT-FS command ID.
< ANT-FS erase response command ID.
bool antfs_event_extract | ( | antfs_event_return_t *const | p_event | ) |
Function for extracting possible pending ANT-FS event.
[out] | p_event | The output event structure. |
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. |
< ANT-FS event queue size.
const char* antfs_hostname_get | ( | void | ) |
Function for getting host name if received.
void antfs_init | ( | const antfs_params_t *const | p_params | ) |
Function for setting initial ANT-FS configuration parameters.
[in] | p_params | The initial ANT-FS configuration parameters. |
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.
[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. |
< The burst packet size.
< The burst packet size.
< The burst packet size.
< The burst packet size.
void antfs_message_process | ( | uint8_t * | p_message | ) |
Function for processing ANT events and data received from the ANT-FS channel.
[in] | p_message | The message buffer containing the message received from the ANT-FS channel. |
< ANT message buffer index channel number offset.
< ANT message buffer index ID offset.
< ANT message buffer index response code offset.
< ANT message buffer index ID offset.
< The control offset within ANT-FS message.
< The data offset within ANT-FS message.
< The control offset within ANT-FS message.
< The data offset within ANT-FS message.
< The control offset within ANT-FS message.
< The data offset within ANT-FS message.
< The control offset within ANT-FS message.
< The data offset within ANT-FS message.
< ANT message buffer index response code offset.
< Used to identify that no ANT-FS command is in progress.
< Used to identify that no ANT-FS command is in progress.
< Used to identify that no ANT-FS command is in progress.
< ANT message buffer index response code offset.
bool antfs_pairing_resp_transmit | ( | bool | accept | ) |
Function for transmitting a response to a pairing request issued by ANT-FS host.
[in] | accept | The pairing response, true if pairing accepted. |
true | Operation success. Response to a pairing request was transmitted. |
false | Operation failure. Not in pairing mode or pairing not supported by the implementation. |
< ANT-FS authenticate command ID.
< Command response type accept.
< Command response type reject.
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.
[in] | data_upload_success | The upload response code, true for success. |
true | Operation success. Response to upload data command was transmitted. |
false | Operation failure. Upload not supported by the implementation or not in correct state. |
< The burst packet size.
< The ANT-FS command ID.
< ANT-FS upload data response command ID.
< ANT-FS upload request command ID.
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.
[in] | response | The upload response code. |
[in] | p_request_info | ANT-FS request info structure. |
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. |
< ANT-FS upload request command ID.
< The burst packet size.
< The ANT-FS command ID.
< ANT-FS upload request response command ID.
< ANT-FS upload request command ID.
void app_error_handler | ( | uint32_t | error_code, |
uint32_t | line_num, | ||
const uint8_t * | p_file_name | ||
) |
Function for handling an error.
Function for error handling, which is called when an error has occurred.
[in] | error_code | Error code supplied to the handler. |
[in] | line_num | Line number where the error occurred. |
[in] | p_file_name | Pointer to the file name. |
void button_event_handler | ( | uint8_t | pin_no, |
uint8_t | button_action | ||
) |
Function for handling button events.
Provides the user input regarding pairing request to the ANT-FS module.
[in] | pin_no | The pin number of the button pressed. |
uint16_t crc_crc16_update | ( | uint16_t | current_crc, |
const volatile void * | p_data, | ||
uint32_t | size | ||
) |
Function for calculating CRC-16 in blocks.
Feed each consecutive data block into this function, along with the current value of current_crc as returned by the previous call of this function. The first call of this function should pass the initial value (usually 0) of the crc in current_crc.
[in] | current_crc | The current calculated CRC-16 value. |
[in] | p_data | The input data block for computation. |
[in] | size | The size of the input data block in bytes. |
void leddriver_led_toggle | ( | leddriver_led_id_t | led_id | ) |
Function for toggling a single LED.
[in] | led_id | ID of the led to be toggled. |
void leddriver_led_turn_off | ( | leddriver_led_id_t | led_id | ) |
Function for turning off a single LED.
[in] | led_id | ID of the led to be turned off. |
void leddriver_led_turn_on | ( | leddriver_led_id_t | led_id | ) |
Function for turning on a single LED.
[in] | led_id | ID of the led to be turned on. |
int main | ( | void | ) |
Function for application main entry, does not return.
< Maximum number of simultaneously created timers.
< Size of timer operation queues.
< Maximum number of users of the GPIOTE handler.
< Delay from a GPIOTE event until a button is reported as pushed (in number of timer ticks).
< Serial number of client device.
< Beacon device type.
< Beacon manufacturer ID.
< Minimum size of ANT event message buffer.
bool mem_file_erase | ( | uint16_t | index | ) |
Function for erasing file from file system.
[in] | index | The file index. |
true | Operation success. |
true | Operation failure. |
< Example directory size.
< Defined invalid index value.
bool mem_file_info_get | ( | uint16_t | index, |
antfs_dir_struct_t * | p_file_info | ||
) |
Function for retrieving file information from directory.
[in] | index | The file index, which information to retrieve. |
[out] | p_file_info | The container where information is read. |
true | Operation success. |
true | Operation failure. |
< Example directory size.
< Example directory size.
void mem_file_read | ( | uint16_t | index, |
uint32_t | offset, | ||
void * | p_data, | ||
uint32_t | size | ||
) |
Function for reading data from file system.
[in] | index | The file index, 0 for directory. |
[in] | offset | The read data offset. |
[out] | p_data | The buffer where data is read. |
[in] | size | The number of bytes to read. |
bool mem_file_write | ( | uint16_t | index, |
uint32_t | offset, | ||
const void * | p_data, | ||
uint32_t | size | ||
) |
Function for writing data to file system.
[in] | index | The file index. |
[in] | offset | The write data offset. |
[in] | p_data | The data to be written. |
[in] | size | The number of bytes to be written. |
true | Operation success. |
true | Operation failure. |
< Example directory size.
< Defined invalid index value.
void SD_EVT_IRQHandler | ( | void | ) |
Function for handling protocol stack IRQ.
Interrupt is generated by the ANT stack upon sending event to the application.
void softdevice_assert_callback | ( | uint32_t | pc, |
uint16_t | line_num, | ||
const uint8_t * | p_file_name | ||
) |
Function for handling SoftDevice asserts, does not return.
Traces out the user supplied parameters and busy loops.
[in] | pc | Value of the program counter. |
[in] | line_num | Line number where the assert occurred. |
[in] | p_file_name | Pointer to the file name. |