SCPI interface to SX1272 and SX1276

Dependencies:   SX127x lib_gps lib_mma8451q lib_mpl3115a2 lib_sx9500 libscpi mbed

Description

This program implements a SCPI command parser. When connected via the debug virtual comm port, you can command the radio and peripherals to perform specific tasks or to set specific parameters. The serial port defaults to 9600bps N-8-1.

Example

The following exampling causes the NA Mote to transmit a continuous LoRa signal.

Example SCPI Commands

*IDN?
RA:MOD LORA
RA:FREQ 903
RA:PAS PA_BOOST
RA:OCP 170
RA:BGR 7
RA:POW 15
RA:LORA:TXContinuous ON
RA:FI "test"

Commands

SCPI is case-insensitive. Commands can be entered lower case.

  • RAdio
    • :FIfo "text" write to fifo, and transmit packet
    • :FIfo? read from fifo (last received packet)
    • :REGister { address }, {value} write radio register (SCPI takes #H for hex prefix)
    • :REGister? { address } read radio register (SCPI takes #H for hex prefix)
    • :MODulation { FSK | OOK | LORa } set modem type
    • :MODulation? get modem type
    • :OPmode { SLE | STB | FST | TX | FSR | RXC | RXS | CAD } set mode
    • :OPmode? get mode
    • :DIOMap { 0 - 5 }, { 0 - 3 } set DIO pin function {pin number}, {map value}
    • :DIOMap? { 0 - 5 } get DIO pin function {pin number}
    • :DIO? { 0 - 5 } read DIO pin level
    • :RSSI? read received signal strength (if in RXC mode)
    • :PASelect { RFO | PA_BOOST } set RF output pin
    • :PASelect? get RF output pin selected
    • :OCP {mA} set over current protection
    • :OCP? read current limit
    • :POWer {0 to 15} set OutputPower
    • :POWer? get OutputPower
    • :BGR { 0 - 7 } set PA ref current
    • :BGR? get PA ref current
    • :FREQuency {MHz} set FRF
    • :FREQuency? get FRF
    • :LNABoost { OFF | ON } set LNA boost
    • :LNABoost? get LNA boost
    • :LORa
      • :BW {KHz} set lora bandwidth
      • :BW? get lora bandwidth (in KHz)
      • :SF {7 to 12} set spreading factor
      • :SF? get spreading factor
      • :TXContinuous { OFF | ON } set continuous TX (end transmit by turning off)
      • :TXContinuous? get continuous TX
      • :PRELen {n-symbols} set preamble length
      • :PRELen? get preamble length
      • :CR {0-4} set coding rate
      • :CR? get coding rate
      • :LDRO { OFF | ON } set LowDataRateOptimize bit
      • :LDRO? get LowDataRateOptimize bit
      • :CRC { OFF | ON} enable CRC in transmitted packet
      • :CRC? read CRC enabled state
      • :INVRx { OFF | ON } enable receiver spectral invert
      • :INVRx? get receiver inversion state
      • :INVTx { OFF | ON } enable transmitter spectral invert
      • :INVTx? get transmitter inversion state
      • :FEI? get frequency error of last received packet
      • :PKTSnr? get S/N (dB) of last received packet
    • :FSK
      • :DATAMode { CONT | PKT } select continuous/packet mode
      • :DATAMode? get packet mode / continuous
      • :FDev {Hz} set TX frequency deviation
      • :FDev? get TX frequency deviation
      • :BITRate {bps} set bit rate
      • :BITRate? get bit rate
      • :BT { 1.0 | 0.5 | 0.3 | 0.0 } set transmit shaping
      • :BT? get transmit shaping
      • :PRELen {n} set preamble size
      • :PRELen? get preamble size
      • :RXBW {Hz} set receive bandwidth
      • :RXBW? set receive bandwidth
      • :AFCBW {Hz} set receive bandwidth (during preamble)
      • :AFCBW? set receive bandwidth (during preamble)
      • :DCFree { OFF | MAN | WHIT } set DC-free encoding
      • :DCFree? get DC-free encoding
      • :RXTrigger { OFF | RSSI | PRE | BOTH } set RX trigger mode
      • :RXTrigger? get RX trigger selection

radio events

Radio events are reported into the Questionable Data Status Event Register, which is summarized in Bit 3 (QSB) of Status Byte Register.

enabling event and reading event

RA:MOD?
"LORa"
RA:OP?
"RXC"
STAT:QUES:ENAB 512
*STB?
8
STAT:QUES:EVEN?
512
RA:FI?
"4747474747474747"
*STB?
0

Bit 9 of QUEStionable event register indicates DIO0 event occurred upon radio packet reception.

NA Mote-72 specific commands

  • PD2 { OFF | ON } set power amplifier voltage state
  • PD2? get power amplifier voltage state
  • VBAT? read battery voltage
  • GPS
    • :EN { OFF | ON } enable GPS
    • :EN? get GPS enabled state
    • :NUMCoords {n} set count of coordinates received (use to clear count)
    • :NUMCoords? get count of coordinates received
    • :LOngitude {n} set longitude
    • :LOngitude? get longitude
    • :LAtitude {n} set latitude
    • :LAtitude? get latitude
  • MMA MMA8451Q
    • :ID? read ID register (WHO_AM_I == 0x1a)
  • MPL MPL3115A2
    • :ID? read ID register (WHO_AM_I == 0xc4)
  • SX9500
    • :RST reset SX9500
    • :REGister {addr}, {value} write SX9500 register
    • :REGister? {addr} read SX9500 register
Committer:
Wayne Roberts
Date:
Tue May 29 12:45:54 2018 -0700
Revision:
12:60990328c884
Parent:
9:73e03383fd21
update to latest libraries

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ubhat 9:73e03383fd21 1 /*
ubhat 9:73e03383fd21 2 / _____) _ | |
ubhat 9:73e03383fd21 3 ( (____ _____ ____ _| |_ _____ ____| |__
ubhat 9:73e03383fd21 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
ubhat 9:73e03383fd21 5 _____) ) ____| | | || |_| ____( (___| | | |
ubhat 9:73e03383fd21 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
ubhat 9:73e03383fd21 7 (C)2013 Semtech
ubhat 9:73e03383fd21 8
ubhat 9:73e03383fd21 9 Description: Timer objects and scheduling management
ubhat 9:73e03383fd21 10
ubhat 9:73e03383fd21 11 License: Revised BSD License, see LICENSE.TXT file include in the project
ubhat 9:73e03383fd21 12
ubhat 9:73e03383fd21 13 Maintainer: Miguel Luis and Gregory Cristian
ubhat 9:73e03383fd21 14 */
ubhat 9:73e03383fd21 15 #ifndef __TIMER_H__
ubhat 9:73e03383fd21 16 #define __TIMER_H__
ubhat 9:73e03383fd21 17
ubhat 9:73e03383fd21 18 #include "mbed.h"
ubhat 9:73e03383fd21 19
ubhat 9:73e03383fd21 20 /*!
ubhat 9:73e03383fd21 21 * \brief Timer object description
ubhat 9:73e03383fd21 22 */
ubhat 9:73e03383fd21 23 typedef struct TimerEvent_s
ubhat 9:73e03383fd21 24 {
ubhat 9:73e03383fd21 25 uint32_t value;
ubhat 9:73e03383fd21 26 void ( *Callback )( void );
ubhat 9:73e03383fd21 27 Ticker Timer;
ubhat 9:73e03383fd21 28 }TimerEvent_t;
ubhat 9:73e03383fd21 29
ubhat 9:73e03383fd21 30 /*!
ubhat 9:73e03383fd21 31 * \brief Timer time variable definition
ubhat 9:73e03383fd21 32 */
ubhat 9:73e03383fd21 33 #ifndef TimerTime_t
ubhat 9:73e03383fd21 34 typedef uint32_t TimerTime_t;
ubhat 9:73e03383fd21 35 #endif
ubhat 9:73e03383fd21 36
ubhat 9:73e03383fd21 37 /*!
ubhat 9:73e03383fd21 38 * \brief Inializes the timer used to get current time.
ubhat 9:73e03383fd21 39 *
ubhat 9:73e03383fd21 40 * \remark Current time corresponds to the time since system startup
ubhat 9:73e03383fd21 41 */
ubhat 9:73e03383fd21 42 void TimerTimeCounterInit( void );
ubhat 9:73e03383fd21 43
ubhat 9:73e03383fd21 44 /*!
ubhat 9:73e03383fd21 45 * \brief Initializes the timer object
ubhat 9:73e03383fd21 46 *
ubhat 9:73e03383fd21 47 * \remark TimerSetValue function must be called before starting the timer.
ubhat 9:73e03383fd21 48 * this function initializes timestamp and reload value at 0.
ubhat 9:73e03383fd21 49 *
ubhat 9:73e03383fd21 50 * \param [IN] obj Structure containing the timer object parameters
ubhat 9:73e03383fd21 51 * \param [IN] callback Function callback called at the end of the timeout
ubhat 9:73e03383fd21 52 */
ubhat 9:73e03383fd21 53 void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) );
ubhat 9:73e03383fd21 54
ubhat 9:73e03383fd21 55 /*!
ubhat 9:73e03383fd21 56 * \brief Starts and adds the timer object to the list of timer events
ubhat 9:73e03383fd21 57 *
ubhat 9:73e03383fd21 58 * \param [IN] obj Structure containing the timer object parameters
ubhat 9:73e03383fd21 59 */
ubhat 9:73e03383fd21 60 void TimerStart( TimerEvent_t *obj );
ubhat 9:73e03383fd21 61
ubhat 9:73e03383fd21 62 /*!
ubhat 9:73e03383fd21 63 * \brief Stops and removes the timer object from the list of timer events
ubhat 9:73e03383fd21 64 *
ubhat 9:73e03383fd21 65 * \param [IN] obj Structure containing the timer object parameters
ubhat 9:73e03383fd21 66 */
ubhat 9:73e03383fd21 67 void TimerStop( TimerEvent_t *obj );
ubhat 9:73e03383fd21 68
ubhat 9:73e03383fd21 69 /*!
ubhat 9:73e03383fd21 70 * \brief Resets the timer object
ubhat 9:73e03383fd21 71 *
ubhat 9:73e03383fd21 72 * \param [IN] obj Structure containing the timer object parameters
ubhat 9:73e03383fd21 73 */
ubhat 9:73e03383fd21 74 void TimerReset( TimerEvent_t *obj );
ubhat 9:73e03383fd21 75
ubhat 9:73e03383fd21 76 /*!
ubhat 9:73e03383fd21 77 * \brief Set timer new timeout value
ubhat 9:73e03383fd21 78 *
ubhat 9:73e03383fd21 79 * \param [IN] obj Structure containing the timer object parameters
ubhat 9:73e03383fd21 80 * \param [IN] value New timer timeout value
ubhat 9:73e03383fd21 81 */
ubhat 9:73e03383fd21 82 void TimerSetValue( TimerEvent_t *obj, uint32_t value );
ubhat 9:73e03383fd21 83
ubhat 9:73e03383fd21 84 /*!
ubhat 9:73e03383fd21 85 * \brief Read the current time
ubhat 9:73e03383fd21 86 *
ubhat 9:73e03383fd21 87 * \retval time returns current time
ubhat 9:73e03383fd21 88 */
ubhat 9:73e03383fd21 89 TimerTime_t TimerGetCurrentTime( void );
ubhat 9:73e03383fd21 90
ubhat 9:73e03383fd21 91
ubhat 9:73e03383fd21 92 #endif // __TIMER_H__