-
Notifications
You must be signed in to change notification settings - Fork 2
5. API Reference
void setup() {
uNode.setup();
// Your stuff
...
}
void loop() {
uNode.step();
// Your stuff
...
}
uNode.setup()
as the very first command of your sketch setup() function. Failing to do so could lead into unexpected behaviour!
uNode.step()
as part of your main program loop. Failing to do so could lead into higher power usage or unexpected behaviour!
uNode.sendLoRa(char * data, size_t size, fnLoRaCallback whenDone = nullptr)
uNode.sendLoRa(T data, fnLoRaCallback whenDone = nullptr)
uNode.sendLoRa(T* data, fnLoRaCallback whenDone = nullptr)
// whenDone callback signature:
void whenDone(int status, uint8_t *response_data, uint8_t response_len) {
}
Sends the data pointed by the data
buffer using the LoRa radio. This is going to use the modulation details, as defined in the library configuration block. Refer to 4. Configuration Reference for more details.
Note that this schedules your data to be submitted. It might take a few seconds until your data are actually on air. You can optionally specify a function that will be called when the transmission is completed.
uNode.pinMode(uint8_t pin, uint8_t mode)
uNode.digitalWrite(uint8_t pin, uint8_t value)
uNode.digitalRead(uint8_t pin)
This set of functions works exactly like the built-in Arduino functions, but they can be seamlessly used with built-in (Pin D0
, D1
) and expanded pins (D2
to D9
).
For example, if you have installed the MCP23S08 GPIO expansion chip, you can use:
if (uNode.digitalRead(D8) == HIGH) {
...
}
uNode.standby(STANDBY_MODE_t mode = STANDBY_ALL)
The standby
functions puts all or some of the board peripherals to sleep. This could either mean disabling the peripheral or cutting the power to them entirely.
The mode variable can be one or an OR combination of:
-
STANDBY_GPIO
: Powers off the MCP23S08 expansion chip -
STANDBY_WIFI
: Powers off the WiFi Radio -
STANDBY_LORA
: Powers of the LoRa Radio -
STANDBY_ALL
: Puts all the above peripherals to sleep
For example:
uNode.standby(STANDBY_WIFI | STANDBY_LORA)
uNode.deepSleep(const uint16_t seconds)
Stops everything and puts the device to deep sleep for some designated period of time.
In this mode all the peripherals are disabled and the CPU is stopped. Only the RTC clock is operating, consuming overall approximately 7μA.
uNode.blink(uint16_t on_ms = 500, uint16_t off_ms = 0, uint8_t cycles = 1)
Blinks the built-in LED (connected on D0, active LOW) with a configurable pattern:
-
on_ms
: Specifies the duration (in milliseconds) where the led is ON -
off_ms
: Specifies the duration (in milliseconds) where the led is OFF (= on_ms if missing) -
cycles
: How many on/off cycles to repeat
✨ Closed-Source Feature
uNode.geolocate(uint16_t flags = GLOC_DEFAULT)
This function returns a pointer to a 50-byte long buffer that contains various information useful to geolocate this node. This buffer does not contain the current location of the node, but rather describe it’s environment in a way that a third-party can identify it’s location.
Currently, it is using the WiFi radio to scan for nearby access points and collects their channel number and signal strength.
The flags
can be:
-
GLOC_DEFAULT
: Uses default configuration -
GLOC_LOW_POWER
: Prefers lower power consumption at const of accuracy
For example, you can send the node position over LoRa like so (we are assuming that you are using a service that can decode the geolocation message on the receiving side):
uNode.sendLoRa(uNode.geolocate());
✨ Closed-Source Feature
int uNode.wifiFindFreeChannel()
This function scans the WiFi channels, looking for one with the smallest number of stations on it. If the WiFi radio is not on, it will be switched on by this function and restored to it’s previous state after the scan.