HT32SX Generic Push Button
Generic Push Button application for HT32SX
rf_api.h File Reference

Sigfox manufacturer functions. More...

Go to the source code of this file.

Macros

#define RF_ERR_API_INIT   (sfx_u8)(0x30)
 
#define RF_ERR_API_SEND   (sfx_u8)(0x31)
 
#define RF_ERR_API_CHANGE_FREQ   (sfx_u8)(0x32)
 
#define RF_ERR_API_STOP   (sfx_u8)(0x33)
 
#define RF_ERR_API_WAIT_FRAME   (sfx_u8)(0x34)
 
#define RF_ERR_API_WAIT_CLEAR_CHANNEL   (sfx_u8)(0x35)
 
#define RF_ERR_API_START_CONTINUOUS_TRANSMISSION   (sfx_u8)(0x36)
 
#define RF_ERR_API_STOP_CONTINUOUS_TRANSMISSION   (sfx_u8)(0x37)
 
#define RF_ERR_API_GET_VERSION   (sfx_u8)(0x38)
 

Functions

sfx_u8 RF_API_init (sfx_rf_mode_t rf_mode)
 Init and configure Radio link in RX/TX. More...
 
sfx_u8 RF_API_stop (void)
 Close Radio link. More...
 
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) More...
 
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 already been executed when this function is called. More...
 
sfx_u8 RF_API_stop_continuous_transmission (void)
 Stop the current continuous transmisssion. More...
 
sfx_u8 RF_API_change_frequency (sfx_u32 frequency)
 Change synthesizer carrier frequency. More...
 
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 Bytes.
This function must be blocking state since data is received or timer of 25 s has elapsed. More...
 
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 frequency band initialized through the RF_API_init(), during a sliding window set in the MCU_API_timer_start_carrier_sense(). If the channel is clear during the minimum carrier sense value (cs_min), under the limit of the cs_threshold, the functions returns with SFX_ERR_NONE (transmission allowed). Otherwise it continues to listen to the channel till the expiration of the carrier sense maximum window and then updates the state ( with timeout enum ). More...
 
sfx_u8 RF_API_get_version (sfx_u8 **version, sfx_u8 *size)
 Returns current RF API version. More...
 

Detailed Description

Sigfox manufacturer functions.

\if SIGFOX PATTERN


/ ___/ | | / ___| | ___| / _ \ \ \ / /
| |___ | | | | | |__ | | | | \ \/ /
___ \ | | | | _ | __| | | | | } {
___| | | | | |_| | | | | |_| | / /\ \ /_____/ |_| _____/ |_| _____/ /_/ _\


!!!! DO NOT MODIFY THIS FILE !!!!


 \endif

Author
Version
Date

This file defines the manufacturer's RF functions to be implemented for library usage.

Function Documentation

◆ RF_API_change_frequency()

sfx_u8 RF_API_change_frequency ( sfx_u32  frequency)

Change synthesizer carrier frequency.


Parameters
[in]sfx_u32frequency Frequency in Hz to program in the radio chipset
[out]none
Return values
SFX_ERR_NONENo error
RF_ERR_API_CHANGE_FREQChange frequency error

◆ RF_API_get_version()

sfx_u8 RF_API_get_version ( sfx_u8 **  version,
sfx_u8 *  size 
)

Returns current RF API version.


Parameters
[out]sfx_u8**version Pointer to Byte array (ASCII format) containing library version
[out]sfx_u8*size Size of the byte array pointed by *version
Return values
SFX_ERR_NONENo error
RF_ERR_API_GET_VERSIONGet Version error

◆ RF_API_init()

sfx_u8 RF_API_init ( sfx_rf_mode_t  rf_mode)

Init and configure Radio link in RX/TX.


[RX Configuration] To receive Sigfox Frame on your device, program the following:

  • Preamble : 0xAAAAAAAAA
  • Sync Word : 0xB227
  • Packet of the Sigfox frame is 15 bytes length.
Parameters
[in]sfx_rf_mode_trf_mode Init Radio link in Tx or RX
[out]none
Return values
SFX_ERR_NONENo error
RF_ERR_API_INITInit Radio link error

[RX Configuration] To receive Sigfox Frame on your device, program the following:

  • Preamble : 0xAAAAAAAAA
  • Sync Word : 0xB227
  • Packet of the Sigfox frame is 15 bytes length.
Parameters
[in]sfx_rf_mode_trf_mode Init Radio link in Tx or RX
[out]none
Return values
SFX_ERRNONENo error
RF_ERR_API_INITInit Radio link error

◆ 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)


NOTE : during this function, the voltage_tx needs to be retrieved and stored in a variable to be returned into the MCU_API_get_voltage_and_temperature or MCU_API_get_voltage functions.

Parameters
[in]sfx_u8*stream Complete stream to modulate
[in]

◆ 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 already been executed when this function is called.


Parameters
[in]sfx_modulation_type_tType of the modulation ( enum with baudrate and modulation information is contained in sigfox_api.h)
Return values
SFX_ERR_NONENo error
RF_ERR_API_START_CONTINUOUS_TRANSMISSIONContinuous Transmission Start error

◆ RF_API_stop()

sfx_u8 RF_API_stop ( void  )

Close Radio link.


Parameters
[in]none
[out]none
Return values
SFX_ERR_NONENo error
RF_ERR_API_STOPClose Radio link error

◆ RF_API_stop_continuous_transmission()

sfx_u8 RF_API_stop_continuous_transmission ( void  )

Stop the current continuous transmisssion.


Return values
SFX_ERR_NONENo error
RF_ERR_API_STOP_CONTINUOUS_TRANSMISSIONContinuous Transmission Stop error

◆ 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 frequency band initialized through the RF_API_init(), during a sliding window set in the MCU_API_timer_start_carrier_sense(). If the channel is clear during the minimum carrier sense value (cs_min), under the limit of the cs_threshold, the functions returns with SFX_ERR_NONE (transmission allowed). Otherwise it continues to listen to the channel till the expiration of the carrier sense maximum window and then updates the state ( with timeout enum ).


Parameters
[in]sfx_u8cs_min Minimum Carrier Sense time in ms.
[in]sfx_s8cs_threshold Power threshold limit to declare the channel clear. i.e : cs_threshold value -80dBm in Japan / -65dBm in Korea
[out]sfx_rx_state_enum_tstate Indicate the final state of the carrier sense. Value can be DL_TIMEOUT or PASSED as per defined in sigfox_api.h file.
Return values
SFX_ERR_NONENo error

◆ 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 Bytes.
This function must be blocking state since data is received or timer of 25 s has elapsed.


  • If received buffer, function returns SFX_ERR_NONE then the library will try to decode frame. If the frame is not correct, the library will recall RF_API_wait_frame.
  • If 25 seconds timer has elapsed, function returns into the state the timeout enum code. and then library will stop receive frame phase.
Parameters
[in]none
[out]sfx_s8*frame Receive buffer
[out]sfx_s16*rssi Chipset RSSI Warning: This is the 'raw' RSSI value. Do not add 100 as made in Library versions 1.x.x Resolution: 1 LSB = 1 dBm
[out]sfx_rx_state_enum_tstate Indicate the final state of the reception. Value can be DL_TIMEOUT or DL_PASSED if a frame has been received, as defined in sigfox_api.h file.
Return values
SFX_ERR_NONENo error

  • If received buffer, function returns SFX_ERR_MANUF_NONE then the library will try to decode frame. If the frame is not correct, the library will recall RF_API_wait_frame .
  • If 25 seconds timer has elapsed, function returns SFX_ERR_MANUF_WAIT_FRAME_TIMEOUT then library will stop receive frame phase.
Parameters
[in]none
[out]sfx_s8*frame Receive buffer
[out]sfx_s16*rssi Chipset RSSI Warning: This is the 'raw' RSSI value. Do not add 100 as made in Library versions 1.x.x Resolution: 1 LSB = 1 dBm
[out]sfx_rx_state_enum_tstate Indicate the final state of the reception. Value can be TIMEOUT or PASSED if a frame has been received, as per defined in sigfox_api.h file.
Return values
SFX_ERR_NONENo error
RF_ERR_API_WAIT_FRAME_TIMEOUTWait frame error