Code Monkey home page Code Monkey logo

renard-phy's Introduction

renard-phy - Sigfox Protocol Physical Layer

renard-phy is an open source physical layer implementation of the Sigfox protocol's uplink and downlink written in Python for use with software defined radios (SDRs). It supports demodulating received Sigfox uplinks and downlinks recorded as WAV files (e.g. with gqrx and any SDR hardware that supports Sigfox's frequency range). Modulating uplink and downlink frames is supported for the HackRF One SDR.

renard-phy is built on top of renard, the CLI interface to the open source Sigfox protocol library librenard.

renard-phy has only been tested in regulatory zone "RCZ1" (Europe / ETSI).

Install / Dependencies

  • renard-phy requires renard as a git submodule, so make sure to clone this repository recursively:
git clone --recursive https://github.com/Jeija/renard-phy
cd renard
make
cd ..
  • Install renard-phy's dependencies: NumPy, SciPy, Scapy and matplotlib. If you wish to transmit frames with the HackRF One, make sure to install the HackRF drivers so that /usr/bin/hackrf_transfer exists.

Usage

Sample Recordings

If you want to try out renard-phy, but don't have recordings of Sigfox uplinks / downlinks, you can download sample WAV files.

Demodulation

Uplink

  • Demodulate, do not decode:
$ cd renard-phy
$ ./uplink/demodulate.py uplink_4byte_zeros.wav
Estimating Frequency using 4096-length FFT
Signal Frequency: 2707.03 Hz
Mixing to Baseband with Costas Loop...
Low-pass Filtering...
Normalizing...
Finding Preamble(s)...
Found 3 Preambles!
[Frame 0]: Determining Frame Type...
[Frame 0]: Frame Type is 0x35f, Packet Length 12 bits
[Frame 0]: Content: 35f0088db334d000000000089b9c3e7
[Frame 0]: Decoding with renard:
[Frame 1]: Determining Frame Type...
[Frame 1]: Frame Type is 0x598, Packet Length 12 bits
[Frame 1]: Content: 59800ee806638c000000000ef0b52ed
[Frame 1]: Decoding with renard:
[Frame 2]: Determining Frame Type...
[Frame 2]: Frame Type is 0x5a3, Packet Length 12 bits
[Frame 2]: Content: 5a300aaedff9e4000000000abd7b31e
[Frame 2]: Decoding with renard:
  • Demodulate and plot baseband signal, mark preambles:
$ ./uplink/demodulate.py uplink_4byte_zeros.wav --plot

  • Demodulate and decode frame contents with renard (you can also do this manually by copy-pasting the frame content output):
$ ./uplink/demodulate.py uplink_4byte_zeros.wav --decode

Downlink

  • Demodulate, do not decode:
$ ./downlink/demodulate.py downlink_0000000000000000.wav
  • Demodulate and plot baseband signal, mark preamble:
$ ./downlink/demodulate.py downlink_0000000000000000.wav --plot

  • Demodulate and brute-force-decode (other decoding options are available by manually copy-pasting the frame output for use with renard):
$ ./downlink/demodulate.py downlink_0000000000000000.wav --decode

Modulation and Transmission with HackRF One

The content (payload / device ID / SN / ...) of the transmitted frames is generated by renard. Command line arguments to the modulate_hackrf.py scripts are passed to renard, so see renard's documentation for a more extensive overview of possible command line options.

Uplink

  • Transmit uplink with payload 0xabad1dea. Mind that all command line options to ./uplink/modulate_hackrf.py are simply forwarded to renard ulencode and renard's raw frame output is then converted to raw signals for transmission with the HackRF One.
$ ./uplink/modulate_hackrf.py -p abad1dea -s 1a0 -i 004d33db -k 479e4480fd7596d45b0122fd282db3cf
  • You can also transmit uplinks with arbitrary frame contents using ./uplink/modulate_hackrf_hex.py by providing the binary frame content as hexadecimal string:
$ ./uplink/modulate_hackrf_hex.py aaaaa35f0001db334d00deadbeef68a60055
  • You can even transmit multiple uplinks at different frequencies at the same time (frequency multiplexing) by providing all their hexadecimal frame contents to ./uplink/modulate_hackrf_hex_multiplex.py. The script will output a command that can be used to transmit the generated HackRF One sample file:
$ ./uplink/modulate_hackrf_hex_multiplex.py aaaaa35f0001db334d00deadbeef68a60055 aaaaa35f0002db334d00abad1dea7c74c0e0

Downlink

  • Transmit downlink with payload 0xdeadbeef02468ace. The first parameter to ./downlink/modulate_hackrf.py is the frequency of the uplink that requested the downlink in Hz. This value is used to calculate the appropriate downlink frequency that the frame is transmitted at. All further command line options are simply forwareded to renard dlencode.
$ ./downlink/modulate_hackrf.py 868100000 -p deadbeef02468ace -i 004d33db -k 479e4480fd7596d45b0122fd282db3cf -s 1a1

renard-phy's People

Contributors

jaoh avatar jeija avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

renard-phy's Issues

Question on making own recordings

Hello Florian,

thanks for sharing the code you wrote. This is an interesting project to learn more about the internals of the Sigfox protocol!

I have a basic question regarding the recording of input data from my own Sigfox device. When I look at the sample recordings you have in this project, then all 3 frames of the messages are modulated on the same 'baseband' frequency in the WAV file. With this I mean that if I look at the spectral content of the samples, then the 3 subsequence frames 'beep' on the same frequency.

I wonder: how do you record this with GQRX given that the 3 successive frames of an actual Sigfox device are transmitted on a different carrier frequency? If you do the demodulation already in GQRX then you end up with 3 different frequencies in the WAV file, and moreover the recordings are not so clean due to the fact that the demodulation is not 100% locked onto the actual carrier frequency.

With the recordings I take using an AirSpy, the renard-phy software detects the correct frequency of the first radio frame but it fails to demodulate it correctly although the signal looks good in the wav file.

Is there any tip/trick you can share to obtain a recording with GQRX that is clean enough to feed into the software? I think I'm missing something obvious...

Thanks,
Lieven.

Negative frequency?

I'm getting this when trying to demodulate an uplink recording:

Estimating Frequency using 262144-length FFT
Signal Frequency: -196704.10 Hz
Mixing to Baseband with Costas Loop...
Low-pass Filtering...
Normalizing...
Finding Preamble(s)...

Any idea why I'm getting a negative frequency?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.