HT32SX Monarch Scan
Monarch Scan application for HT32SX
rf_api.h
Go to the documentation of this file.
1 
31 /********************************************************
32  * External API dependencies to link with this library.
33  *
34  * Error codes of the RF API functions are described below.
35  * The Manufacturer can add more error code taking care of the limits defined.
36  *
37  ********************************************************/
38 
50 #include "sigfox_types.h"
51 #include "sigfox_api.h"
52 /* ---------------------------------------------------------------- */
53 /* Bytes reserved for MCU API ERROR CODES : From 0x10 to 0x2F */
54 /* ---------------------------------------------------------------- */
55 
56 /* ---------------------------------------------------------------- */
57 /* Bytes reserved for RF API ERROR CODES : From 0x30 to 0x3F */
58 /* ---------------------------------------------------------------- */
59 #define RF_ERR_API_INIT (sfx_u8)(0x30)
60 #define RF_ERR_API_SEND (sfx_u8)(0x31)
61 #define RF_ERR_API_CHANGE_FREQ (sfx_u8)(0x32)
62 #define RF_ERR_API_STOP (sfx_u8)(0x33)
63 #define RF_ERR_API_WAIT_FRAME (sfx_u8)(0x34)
64 #define RF_ERR_API_WAIT_CLEAR_CHANNEL (sfx_u8)(0x35)
65 #define RF_ERR_API_START_CONTINUOUS_TRANSMISSION (sfx_u8)(0x36)
66 #define RF_ERR_API_STOP_CONTINUOUS_TRANSMISSION (sfx_u8)(0x37)
67 #define RF_ERR_API_GET_VERSION (sfx_u8)(0x38)
68 /* ---------------------------------------------------------------- */
69 /* Bytes reserved for SE API ERROR CODES : From 0x40 to 0x5F */
70 /* ---------------------------------------------------------------- */
71 
72 /* ---------------------------------------------------------------- */
73 /* Bytes reserved for REPEATER API ERROR CODES : From 0x60 to 0x7F */
74 /* ---------------------------------------------------------------- */
75 
76 /* ---------------------------------------------------------------- */
77 /* Bytes reserved for MONARCH API ERROR CODES : From 0x80 to 0x8F */
78 /* ---------------------------------------------------------------- */
79 
83 /*!******************************************************************
84  * \fn sfx_u8 RF_API_init(sfx_rf_mode_t rf_mode)
85  * \brief Init and configure Radio link in RX/TX
86  *
87  * [RX Configuration]
88  * To receive Sigfox Frame on your device, program the following:
89  * - Preamble : 0xAAAAAAAAA
90  * - Sync Word : 0xB227
91  * - Packet of the Sigfox frame is 15 bytes length.
92  *
93  * \param[in] sfx_rf_mode_t rf_mode Init Radio link in Tx or RX
94  * \param[out] none
95  *
96  * \retval SFX_ERR_NONE: No error
97  * \retval RF_ERR_API_INIT: Init Radio link error
98  *******************************************************************/
99 sfx_u8 RF_API_init(sfx_rf_mode_t rf_mode);
100 
101 /*!******************************************************************
102  * \fn sfx_u8 RF_API_stop(void)
103  * \brief Close Radio link
104  *
105  * \param[in] none
106  * \param[out] none
107  *
108  * \retval SFX_ERR_NONE: No error
109  * \retval RF_ERR_API_STOP: Close Radio link error
110  *******************************************************************/
111 sfx_u8 RF_API_stop(void);
112 
113 /*!******************************************************************
114  * \fn sfx_u8 RF_API_send(sfx_u8 *stream, sfx_modulation_type_t type, sfx_u8 size)
115  * \brief BPSK Modulation of data stream
116  * (from synchro bit field to CRC)
117  *
118  * NOTE : during this function, the voltage_tx needs to be retrieved and stored in
119  * a variable to be returned into the MCU_API_get_voltage_and_temperature or
120  * MCU_API_get_voltage functions.
121  *
122  * \param[in] sfx_u8 *stream Complete stream to modulate
123  * \param[in]sfx_modulation_type_t Type of the modulation ( enum with baudrate and modulation information)
124  * \param[in] sfx_u8 size Length of stream
125  * \param[out] none
126  *
127  * \retval SFX_ERR_NONE: No error
128  * \retval RF_ERR_API_SEND: Send data stream error
129  *******************************************************************/
130 sfx_u8 RF_API_send(sfx_u8 *stream, sfx_modulation_type_t type, sfx_u8 size);
131 
132 /*!******************************************************************
133  * \fn sfx_u8 RF_API_start_continuous_transmission (sfx_modulation_type_t type)
134  * \brief Generate a signal with modulation type. All the configuration ( Init of the RF and Frequency have already been executed
135  * when this function is called.
136  *
137  * \param[in] sfx_modulation_type_t Type of the modulation ( enum with baudrate and modulation information is contained in sigfox_api.h)
138  *
139  * \retval SFX_ERR_NONE: No error
140  * \retval RF_ERR_API_START_CONTINUOUS_TRANSMISSION: Continuous Transmission Start error
141  *******************************************************************/
143 
144 /*!******************************************************************
145  * \fn sfx_u8 RF_API_stop_continuous_transmission (void)
146  * \brief Stop the current continuous transmisssion
147  *
148  * \retval SFX_ERR_NONE: No error
149  * \retval RF_ERR_API_STOP_CONTINUOUS_TRANSMISSION: Continuous Transmission Stop error
150  *******************************************************************/
152 
153 /*!******************************************************************
154  * \fn sfx_u8 RF_API_change_frequency(sfx_u32 frequency)
155  * \brief Change synthesizer carrier frequency
156  *
157  * \param[in] sfx_u32 frequency Frequency in Hz to program in the radio chipset
158  * \param[out] none
159  *
160  * \retval SFX_ERR_NONE: No error
161  * \retval RF_ERR_API_CHANGE_FREQ: Change frequency error
162  *******************************************************************/
163 sfx_u8 RF_API_change_frequency(sfx_u32 frequency);
164 
165 /*!******************************************************************
166  * \fn sfx_u8 RF_API_wait_frame(sfx_u8 *frame, sfx_s16 *rssi, sfx_rx_state_enum_t * state)
167  * \brief Get all GFSK frames received in Rx buffer, structure of
168  * frame is : Synchro bit + Synchro frame + 15 Bytes.<BR> This function must
169  * be blocking state since data is received or timer of 25 s has elapsed.
170  *
171  * - If received buffer, function returns SFX_ERR_NONE then the
172  * library will try to decode frame. If the frame is not correct, the
173  * library will recall RF_API_wait_frame.
174  *
175  * - If 25 seconds timer has elapsed, function returns into the state the timeout enum code.
176  * and then library will stop receive frame phase.
177  *
178  * \param[in] none
179  * \param[out] sfx_s8 *frame Receive buffer
180  * \param[out] sfx_s16 *rssi Chipset RSSI
181  * Warning: This is the 'raw' RSSI value. Do not add 100 as made
182  * in Library versions 1.x.x
183  * Resolution: 1 LSB = 1 dBm
184  *
185  * \param[out] sfx_rx_state_enum_t state Indicate the final state of the reception. Value can be DL_TIMEOUT or DL_PASSED
186  * if a frame has been received, as defined in sigfox_api.h file.
187  *
188  * \retval SFX_ERR_NONE: No error
189  *******************************************************************/
190 sfx_u8 RF_API_wait_frame(sfx_u8 *frame, sfx_s16 *rssi, sfx_rx_state_enum_t * state);
191 
192 /*!******************************************************************
193  * \fn sfx_u8 RF_API_wait_for_clear_channel (sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_state_enum_t * state);
194  * \brief This function is used in ARIB standard for the Listen Before Talk
195  * feature. It listens on a specific frequency band initialized through the RF_API_init(), during a sliding window set
196  * in the MCU_API_timer_start_carrier_sense().
197  * If the channel is clear during the minimum carrier sense
198  * value (cs_min), under the limit of the cs_threshold,
199  * the functions returns with SFX_ERR_NONE (transmission
200  * allowed). Otherwise it continues to listen to the channel till the expiration of the
201  * carrier sense maximum window and then updates the state ( with timeout enum ).
202  *
203  * \param[in] sfx_u8 cs_min Minimum Carrier Sense time in ms.
204  * \param[in] sfx_s8 cs_threshold Power threshold limit to declare the channel clear.
205  * i.e : cs_threshold value -80dBm in Japan / -65dBm in Korea
206  * \param[out] sfx_rx_state_enum_t state Indicate the final state of the carrier sense. Value can be DL_TIMEOUT or PASSED
207  * as per defined in sigfox_api.h file.
208  *
209  * \retval SFX_ERR_NONE: No error
210  *******************************************************************/
211 sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_state_enum_t * state);
212 
213 /*!******************************************************************
214  * \fn sfx_u8 RF_API_get_version(sfx_u8 **version, sfx_u8 *size)
215  * \brief Returns current RF API version
216  *
217  * \param[out] sfx_u8 **version Pointer to Byte array (ASCII format) containing library version
218  * \param[out] sfx_u8 *size Size of the byte array pointed by *version
219  *
220  * \retval SFX_ERR_NONE: No error
221  * \retval RF_ERR_API_GET_VERSION: Get Version error
222  *******************************************************************/
223 sfx_u8 RF_API_get_version(sfx_u8 **version, sfx_u8 *size);
RF_API_stop
sfx_u8 RF_API_stop(void)
Close Radio link.
Definition: rf_api.c:1220
RF_API_change_frequency
sfx_u8 RF_API_change_frequency(sfx_u32 frequency)
Change synthesizer carrier frequency.
Definition: rf_api.c:1402
sigfox_api.h
Sigfox user functions.
sfx_modulation_type_t
sfx_modulation_type_t
Definition: sigfox_api.h:378
RF_API_wait_frame
sfx_u8 RF_API_wait_frame(sfx_u8 *frame, sfx_s16 *rssi, sfx_rx_state_enum_t *state)
Get all GFSK frames received in Rx buffer, structure of frame is : Synchro bit + Synchro frame + 15 B...
Definition: rf_api.c:1486
RF_API_send
sfx_u8 RF_API_send(sfx_u8 *stream, sfx_modulation_type_t type, sfx_u8 size)
BPSK Modulation of data stream (from synchro bit field to CRC)
Definition: rf_api.c:1262
RF_API_init
sfx_u8 RF_API_init(sfx_rf_mode_t rf_mode)
Init and configure Radio link in RX/TX.
Definition: rf_api.c:1078
sfx_rf_mode_t
sfx_rf_mode_t
Definition: sigfox_api.h:404
RF_API_start_continuous_transmission
sfx_u8 RF_API_start_continuous_transmission(sfx_modulation_type_t type)
Generate a signal with modulation type. All the configuration ( Init of the RF and Frequency have alr...
Definition: rf_api.c:1305
sigfox_types.h
Sigfox types definition.
RF_API_wait_for_clear_channel
sfx_u8 RF_API_wait_for_clear_channel(sfx_u8 cs_min, sfx_s8 cs_threshold, sfx_rx_state_enum_t *state)
This function is used in ARIB standard for the Listen Before Talk feature. It listens on a specific f...
Definition: rf_api.c:1612
RF_API_get_version
sfx_u8 RF_API_get_version(sfx_u8 **version, sfx_u8 *size)
Returns current RF API version.
Definition: rf_api.c:1739
RF_API_stop_continuous_transmission
sfx_u8 RF_API_stop_continuous_transmission(void)
Stop the current continuous transmisssion.
Definition: rf_api.c:1376