Sigfox
Sigfox is a Low Power Wide Area Network protocol that enables remote devices to connect using ultra-narrow band, UNB technology. The protocol is bi-directional, messages can both be sent up to and down from the Sigfox servers.
This class provides a driver for the Sigfox network processor in the Sigfox enabled Pycom devices.
Quick Usage Example
Please ensure that there is an antenna connected to your device before sending/receiving Sigfox messages as in proper use (e.g. without an antenna), may damage the device.
Constructors
class network.Sigfox(id=0, ...)
Create and configure a Sigfox object. See init for params of configuration. Examples:
Methods
sigfox.init(mode=Sigfox.SIGFOX, rcz=Sigfox.RCZ1, * , frequency=None)
Set the Sigfox radio configuration.
The arguments are:
mode
can be eitherSigfox.SIGFOX
orSigfox.FSK
.Sigfox.SIGFOX
uses the Sigfox modulation and protocol whileSigfox.FSK
allows to create point to point communication between 2 Devices using FSK modulation. Note:Sigfox.FSK
mode is not supported on LoPy 4 and FiPy.rcz
takes the following values:Sigfox.RCZ1
,Sigfox.RCZ2
,Sigfox.RCZ3
,Sigfox.RCZ4
. Thercz
argument is only required if the mode isSigfox.SIGFOX
.frequency
sets the frequency value inFSK
mode. Can take values between 863 and 928 MHz.
sigfox.mac()
Returns a byte object with the 8-Byte MAC address of the Sigfox radio.
sigfox.id()
Returns a byte object with the 4-Byte bytes object with the Sigfox ID.
sigfox.rssi()
Returns a signed integer with indicating the signal strength value of the last received packet.
sigfox.pac()
Returns a byte object with the 8-Byte bytes object with the Sigfox PAC.
sigfox.frequencies()
Returns a tuple of the form: (uplink_frequency_hz, downlink_frequency_hz)
sigfox.public_key([public])
Sets or gets the public key flag. When called passing a True
value the Sigfox public key will be used to encrypt the packets. Calling it without arguments returns the state of the flag.
Constants
Sigfox radio mode:
sigfox.SIGFOX
,sigfox.FSK
.SIGFOX
to specify usage of the Sigfox Public Network.FSK
to specify device to device communication.
Sigfox zones:
sigfox.RCZ1
,sigfox.RCZ2
,sigfox.RCZ3
,sigfox.RCZ4
RCZ1
to specify Europe, Oman & South Africa.RCZ2
for the USA, Mexico & Brazil.RCZ3
for Japan.RCZ4
for Australia, New Zealand, Singapore, Taiwan, Hong Kong, Colombia & Argentina.
Working with Sigfox Sockets
Sigfox sockets are created in the following way:
And they must be created after initialising the Sigfox network card.
Sigfox sockets support the following standard methods from the socket
module:
socket.close()
Use it to close an existing socket.
socket.send(bytes)
In Sigfox mode the maximum data size is 12 bytes. In FSK the maximum is 64.
socket.recv(bufsize)
This method can be used to receive a Sigfox downlink or FSK message.
socket.setsockopt(level, optname, value)
Set the value of the given socket option. The needed symbolic constants are defined in the socket module (SO_*
etc.). In the case of Sigfox the values are always an integer. Examples:
Sending a Sigfox packet with a single bit is achieved by sending an empty string, i.e.:
If the socket is set to blocking, your code will be wait until the socket completes sending/receiving.
Sigfox Downlink
A Sigfox capable Pycom devices (SiPy) can both send and receive data from the Sigfox network. To receive data, a message must first be sent up to Sigfox, requesting a downlink message. This can be done by passing a True
argument into the setsockopt()
method.
An example of the downlink procedure can be seen below:
Sigfox FSK (Device to Device)
To communicate between two Sigfox capable devices, it may be used in FSK mode. Two devices are required to be set to the same frequency, both using FSK.
Device 1:
Device 2:
Remember to use the correct frequency for your region (868 MHz for Europe, 912 MHz for USA, etc.)
Last updated