API for packet radio and other RF transceiver device drivers
Object filename description:
wireless.mode.model.spin
mode is one of: transceiver
, transmitter
, receiver
, bluetooth
, bluetooth-le
model indicates the manufacturer's model number of the device
These are methods that are common to all wireless drivers
Method | Description | Param | Returns |
---|---|---|---|
startx() |
Start driver using explicitly defined settings | Notes 1-3 | cog id+1 |
stop() |
Stop the driver | n/a | n/a |
defaults() |
Set sensor factory default settings | n/a | n/a |
Notes:
-
For SPI-connected devices:
startx(CS_PIN, SCK_PIN, MOSI_PIN, MISO_PIN): status
- For some devices, a
MODEL_SPI_BC
variant exists, which directs the driver to use a bytecode-based engine that while much slower, doesn't use another cog. - Replace
MODEL
with the sensor model #. Example:CC1101_SPI_BC
- 4-wire SPI is used by default. If supported by the device,
3-wire SPI can be chosen by setting
MOSI_PIN
andMISO_PIN
to the same I/O pin. Thestartx()
method will check for this and set the device's 3-wire SPI mode register.
-
Some drivers may have a
RST_PIN
parameter, for specifying an optional reset pin (device-dependent). The pin is only validated in thereset()
method, and is ignored if set outside the allowable range. -
startx()
returns the launched cog number+1 of com engine used on success. -
startx()
returnsFALSE
(0) if the driver fails to start, for these possible reasons:- No more cogs available
- One or more specified I/O pins are outside allowed range
- Bus frequency is outside allowed range
- If supported by the device,
dev_id()
didn't return the expected value
-
defaults()
may simply callreset()
, if sensible, as opposed to calling several other driver methods, in order to reduce memory usage. -
Most (but not all) drivers also provide the following methods:
Method | Description | Param | Returns |
---|---|---|---|
dev_id() |
Read model-unique identification register | n/a | model/dev ID |
reset() |
Perform a hard or soft-reset of the device | n/a | n/a |
-
Drivers may have one or more
preset_()
methods, that establish a pre-set combination of bitrates, modulation, TX/RX role, etc. -
stop()
performs the following tasks:- Stop any extra cogs that were started (if applicable)
- Clear all global variable space used to 0
Method | Description |
---|---|
carrier_freq() |
Set carrier frequency |
data_rate() |
Set RF data rate |
payld_len() |
Set length of static payload/max dyn. payload |
payld_rdy() |
Flag indicating received payload is ready |
payld_sent() |
Flag indicating payload sent |
rx_payld() |
Receive payload stored in FIFO |
tx_payld() |
Queue payload to be transmitted |
tx_pwr() |
Set transmit RF power |
Set carrier frequency
- Parameters:
f
: new carrier/center frequency in Hertz
- Returns:
- current frequency in Hertz if
f
is outside the accepted range
- current frequency in Hertz if
NOTE: Due to variable size limitations, transceivers that operate in higher frequency
ranges may use a kilohertz parameter (e.g., 2_400_000kHz
instead of 2_400_000_000Hz
)
Set RF data rate
- Parameters:
r
: new on-air data rate in bits per second
- Returns:
- current data rate if
r
is outside the accepted range
- current data rate if
Set length of static payload, or set max dynamic payload
- Parameters:
l
: new length of payload
- Returns:
- currently set payload length if
l
is outside the accepted range
- currently set payload length if
Flag indicating received payload is ready
- Parameters: none
- Returns:
- boolean flag indicating a payload was received
Flag indicating payload sent
- Parameters: none
- Returns:
- boolean flag indicating a payload was sent
Receive payload stored in FIFO
- Parameters:
nr_bytes
: number of bytes to readptr_buff
: pointer to buffer to copy payload data to
- Returns:
- none
Queue payload to be transmitted
- Parameters:
nr_bytes
: number of bytes to transmitptr_buff
: pointer to buffer to copy payload data from
- Returns:
- none
Set transmit RF power
- Parameters:
p
: new transmit power level in dBm
- Returns:
- currently set transmit power if
p
is outside the accepted range
- currently set transmit power if
Notes:
-
Methods return the current setting when they're given a parameter that is out of range (see driver-basic-structure.md.
-
Other methods availability are device-dependent.
Method | Description |
---|---|
advert_interval() |
Set advertising interval |
advert_type() |
Set advertising type |
auth_mode() |
Set authentication mode |
putchar() |
Send a single character |
conn_notify_ena() |
Enable (dis)connection notifications |
fifo_rx_bytes() |
Number of characters in receive buffer |
data_rate() |
Set serial/on-air data rate |
last_connected_dev() |
Last connected device's address |
node_addr() |
Read device's node address |
node_name() |
Set BLE module name |
pin_code() |
Set PIN code |
reset() |
Soft-reset device |
resolve_names() |
Resolve MAC addresses to names |
role() |
Set device role |
rx_check() |
Check for received character (non-blocking) |
scan_time() |
Set length of scan |
gets_max() |
Read received string, up to max len |
sys_led_mode() |
Set output mode of module's LED |
tx_pwr() |
Set transmit RF power |
unpair() |
Remove pairing/bonding information |
version() |
Get firmware version |
work_mode() |
Set device working mode |
Get advertising interval
- Parameters: none
- Returns: time in milliseconds
Set advertising interval
- Parameters:
i
: time in milliseconds
- Returns: none
Get advertising type
- Parameters: none
- Returns: type
Set advertising type
- Parameters:
t
: advertising type
- Returns: none
Get authentication mode
- Parameters: none
- Returns: currently set authentication mode
Set authentication mode
- Parameters:
m
: mode
- Returns: none
Send a single character
- Parameters:
ch
: ASCII character to send
- Returns: none
- Aliases:
char()
Receive a single character
- Parameters: none
- Returns:
- ASCII character received
- Aliases:
charin()
Enable (dis)connection notifications
- Parameters:
state
: boolean state
- Returns: none
Get current state of (dis)connection notifications
- Parameters: none
- Returns:
- current state of setting
Number of characters in receive buffer
- Parameters: none
- Returns:
- number of bytes available in buffer
Get current serial/on-air data rate
- Parameters: none
- Returns:
- current data rate in bits per second
Set serial/on-air data rate
- Parameters:
rate
: new data rate in bits per second
- Returns: none
Last connected device's address
- Parameters: none
- Returns:
- pointer to string containing MAC address of remote device
Read device's node address
- Parameters: none
- Returns:
- pointer to string containing MAC address of local device
Get BLE module current name
- Parameters: none
- Returns:
- pointer to string containing name of module
Set BLE module name
- Parameters:
ptr_name
: pointer to string containing new name of module
- Returns: none
Get current PIN code
- Parameters: none
- Returns:
- current PIN code
Set PIN code
- Parameters:
pin
: new PIN code
- Returns: none
Soft-reset device
- Parameters: none
- Returns: none
Resolve MAC addresses to names
- Parameters:
state
: boolean value to enable resolving MAC addresses to names during scans
- Returns: none
Resolve MAC addresses to names
- Parameters: none
- Returns:
- flag indicating MAC to name resolution is enabled
Get device current role
- Parameters: none
- Returns:
- device's currently set role
Set device role
- Parameters:
r
: new device role
- Returns: none
Check for received character (non-blocking)
- Parameters: none
- Returns:
- ASCII value of character, or -1 if none received
Get length of scan
- Parameters: none
- Returns:
- currently set length of scan in seconds
Set length of scan
- Parameters:
s
: length of scan in seconds
- Returns: none
Read received string, up to max len
- Parameters:
ptr_str
: pointer to buffer to copy received string tomax_len
: maximum number of bytes to receive
- Returns: none
Get current mode of module's LED
- Parameters: none
- Returns:
- currently set LED mode
Set output mode of module's LED
- Parameters:
m
: new LED output mode
- Returns: none
Get transmit RF power
- Parameters: none
- Returns:
- currently set transmit power in dBm
Set transmit RF power
- Parameters:
p
: transmit power in dBm
- Returns: none
Remove pairing/bonding information
- Parameters: none
- Returns: none
Get firmware version
- Parameters: none
- Returns:
- integer representation of module firmware version
Get device current working mode
- Parameters: none
- Returns:
- module's current working mode
Set device working mode
- Parameters:
m
: new working mode
- Returns: none
Notes:
- This section preliminary (currently only one driver exists)