HT32SX Monarch Scan
Monarch Scan application for HT32SX
monarch_api.h
Go to the documentation of this file.
1 
32 /********************************************************
33  * External API dependencies to link with this library.
34  *
35  * Error codes of the MCU MONARCH API functions are described below.
36  * The Manufacturer can add more error code taking care of the limits defined.
37  *
38  ********************************************************/
39 
51 #include "sigfox_types.h"
52 #include "sigfox_monarch_api.h"
53 /* ---------------------------------------------------------------- */
54 /* Bytes reserved for MCU API ERROR CODES : From 0x10 to 0x2F */
55 /* ---------------------------------------------------------------- */
56 
57 /* ---------------------------------------------------------------- */
58 /* Bytes reserved for RF API ERROR CODES : From 0x30 to 0x3F */
59 /* ---------------------------------------------------------------- */
60 
61 /* ---------------------------------------------------------------- */
62 /* Bytes reserved for SE API ERROR CODES : From 0x40 to 0x5F */
63 /* ---------------------------------------------------------------- */
64 
65 /* ---------------------------------------------------------------- */
66 /* Bytes reserved for REPEATER API ERROR CODES : From 0x60 to 0x7F */
67 /* ---------------------------------------------------------------- */
68 
69 /* ---------------------------------------------------------------- */
70 /* Bytes reserved for MONARCH API ERROR CODES : From 0x80 to 0x8F */
71 /* ---------------------------------------------------------------- */
72 #define MONARCH_ERR_API_MALLOC (sfx_u8)(0x80)
73 #define MONARCH_ERR_API_FREE (sfx_u8)(0x81)
74 #define MONARCH_ERR_API_TIMER_START (sfx_u8)(0x82)
75 #define MONARCH_ERR_API_TIMER_STOP (sfx_u8)(0x83)
76 #define MONARCH_ERR_API_CONFIGURE_SEARCH_PATTERN (sfx_u8)(0x84)
77 #define MONARCH_ERR_API_STOP_SEARCH_PATTERN (sfx_u8)(0x85)
78 #define MONARCH_ERR_API_GET_VERSION (sfx_u8)(0x86)
82 /*!******************************************************************
83  * \fn sfx_u8 MONARCH_API_malloc(sfx_u16 size, sfx_u8 **returned_pointer)
84  * \brief Allocate memory for MONARCH library usage (Memory usage = size (Bytes))
85  * This function is only called once at RC Scan.
86  *
87  * IMPORTANT NOTE:
88  * --------------
89  * The address reported need to be aligned with architecture of the microprocessor used.
90  * For a Microprocessor of:
91  * - 8 bits => any address is allowed
92  * - 16 bits => only address multiple of 2 are allowed
93  * - 32 bits => only address multiple of 4 are allowed
94  *
95  * \param[in] sfx_u16 size size of buffer to allocate in bytes
96  * \param[out] sfx_u8 **returned_pointer pointer to buffer (can be static)
97  *
98  * \retval SFX_ERR_NONE: No error
99  * \retval MONARCH_ERR_API_MALLOC Malloc error
100  *******************************************************************/
101 sfx_u8 MONARCH_API_malloc(sfx_u16 size, sfx_u8 **returned_pointer);
102 
103 /*!******************************************************************
104  * \fn sfx_u8 MONARCH_API_free(sfx_u8 *ptr)
105  * \brief Free memory allocated to library with the MONARCH_API_malloc
106  *
107  * \param[in] sfx_u8 *ptr pointer to buffer
108  * \param[out] none
109  *
110  * \retval SFX_ERR_NONE: No error
111  * \retval MONARCH_ERR_API_FREE: Free error
112  *******************************************************************/
113 sfx_u8 MONARCH_API_free(sfx_u8 *ptr);
114 
115 /*!******************************************************************
116  * \fn sfx_u8 MONARCH_API_timer_start (sfx_u16 timer_value, sfx_timer_unit_enum_t unit, sfx_error_t (* sigfox_callback_timeout_handler ) ( void ) )
117  * \brief This function starts a timer based on timer_value and the units. When the timer expires
118  * the manufacturer has to call the timer callback function (sigfox_callback_timeout_handler)
119  *
120  * \param[in] sfx_u16 timer_value Scan duration value ( with the unit parameter information )
121  * \param[in] sfx_timer_unit_enum_t unit Unit to be considered for the scan time computation
122  * \param[in] timeout_callback_handler This is the function that needs to be called when the timer expires
123  * ( either when RC Found or when Timeout )
124  *
125  * \retval SFX_ERR_NONE: No error
126  * \retval MONARCH_ERR_API_TIMER_START: Timer Start error
127  *******************************************************************/
128 sfx_u8 MONARCH_API_timer_start (sfx_u16 timer_value, sfx_timer_unit_enum_t unit, sfx_error_t (* timeout_callback_handler ) ( void ) );
129 
130 /*!******************************************************************
131  * \fn sfx_u8 MONARCH_API_timer_stop (void)
132  * \brief This function stops the timer
133  *
134  * \retval SFX_ERR_NONE: No error
135  * \retval MONARCH_ERR_API_TIMER_STOP: Stop Timer error
136  *******************************************************************/
137 sfx_u8 MONARCH_API_timer_stop (void);
138 
139 /*!******************************************************************
140  * \fn sfx_u8 MONARCH_API_configure_search_pattern ( sfx_monarch_pattern_search_t list_freq_pattern[], sfx_u8 size, sfx_monarch_listening_mode_t mode, sfx_error_t (* monarch_pattern_freq_result_callback_handler ) (sfx_u32 freq, sfx_pattern_enum_t pattern, sfx_s16 rssi));
141  *
142  * \brief This function is used to configure a search pattern action from on the MCU/RF side.
143  * The list of frequencies to scan and associated pattern is given as parameter.
144  * When a pattern is found or the timeout ( set with MONARCH_API_timer_start ) occurs,
145  * the callback function has to be called.
146  *
147  * There are 2 modes that can be used : LISTENING_SWEEP and LISTENING_WINDOW modes.
148  * They are detailed in the sfx_monarch_listening_mode_t description
149  *
150  * \param[in] sfx_monarch_pattern_search_t list_freq_pattern[] Tab of the frequencies / patterns to check
151  * \param[in] sfx_u8 size Size of the list (list_freq_pattern)
152  * \param[in] sfx_monarch_listening_mode_t mode Mode of the scan
153  * \param[in] monarch_pattern_freq_result_callback_handler Callback function when a pattern is found or when the timer expires
154  * with the following parameters :
155  * \param[in] sfx_u32 freq Report the Frequency on which the pattern has been found
156  * \param[in] sfx_pattern_enum_t pattern Pattern which has been found
157  * \param[in] sfx_s16 rssi RSSI level of the found pattern
158  *
159  *
160  * \retval SFX_ERR_NONE: No error
161  * \retval MONARCH_ERR_API_CONFIGURE_SEARCH_PATTERN: Search pattern error
162  *******************************************************************/
164  sfx_u8 size,
166  sfx_error_t (* monarch_pattern_freq_result_callback_handler ) (sfx_u32 freq, sfx_pattern_enum_t pattern, sfx_s16 rssi) );
167 
168 /*!******************************************************************
169  * \fn sfx_u8 MONARCH_API_stop_search_pattern (void)
170  * \brief This function stops the scan
171  *
172  * \retval SFX_ERR_NONE: No error
173  * \retval MONARCH_ERR_API_STOP_SEARCH_PATTERN: Stop seach pattern error
174  *******************************************************************/
176 
177 /*!******************************************************************
178  * \fn sfx_u8 MONARCH_API_get_version(sfx_u8 **version, sfx_u8 *size)
179  * \brief This function returns current MONARCH API version
180  *
181  * \param[out] sfx_u8 **version Pointer to Byte array (ASCII format) containing library version
182  * \param[out] sfx_u8 *size Size of the byte array pointed by *version
183  *
184  * \retval SFX_ERR_NONE: No error
185  * \retval MONARCH_ERR_API_GET_VERSION: Get Version error
186  *******************************************************************/
187 sfx_u8 MONARCH_API_get_version(sfx_u8 **version, sfx_u8 *size);
188 
MONARCH_API_timer_stop
sfx_u8 MONARCH_API_timer_stop(void)
This function stops the timer.
Definition: rf_api.c:2009
sfx_monarch_pattern_search_t
Definition: sigfox_monarch_api.h:89
MONARCH_API_stop_search_pattern
sfx_u8 MONARCH_API_stop_search_pattern(void)
This function stops the scan.
Definition: rf_api.c:2016
sigfox_monarch_api.h
Sigfox user functions.
sfx_pattern_enum_t
sfx_pattern_enum_t
Definition: sigfox_monarch_api.h:71
MONARCH_API_malloc
sfx_u8 MONARCH_API_malloc(sfx_u16 size, sfx_u8 **returned_pointer)
Allocate memory for MONARCH library usage (Memory usage = size (Bytes)) This function is only called ...
Definition: rf_api.c:2003
MONARCH_API_get_version
sfx_u8 MONARCH_API_get_version(sfx_u8 **version, sfx_u8 *size)
This function returns current MONARCH API version.
Definition: rf_api.c:2018
sfx_monarch_listening_mode_t
sfx_monarch_listening_mode_t
Definition: sigfox_monarch_api.h:99
MONARCH_API_free
sfx_u8 MONARCH_API_free(sfx_u8 *ptr)
Free memory allocated to library with the MONARCH_API_malloc.
Definition: rf_api.c:2005
sfx_timer_unit_enum_t
sfx_timer_unit_enum_t
Definition: sigfox_monarch_api.h:39
MONARCH_API_configure_search_pattern
sfx_u8 MONARCH_API_configure_search_pattern(sfx_monarch_pattern_search_t list_freq_pattern[], sfx_u8 size, sfx_monarch_listening_mode_t mode, sfx_error_t(*monarch_pattern_freq_result_callback_handler)(sfx_u32 freq, sfx_pattern_enum_t pattern, sfx_s16 rssi))
This function is used to configure a search pattern action from on the MCU/RF side....
Definition: rf_api.c:2011
sigfox_types.h
Sigfox types definition.
MONARCH_API_timer_start
sfx_u8 MONARCH_API_timer_start(sfx_u16 timer_value, sfx_timer_unit_enum_t unit, sfx_error_t(*timeout_callback_handler)(void))
This function starts a timer based on timer_value and the units. When the timer expires the manufactu...
Definition: rf_api.c:2007