ares_lora.LoraException
¶
ares_lora.SettingId
¶
Bases: IntEnum
Firmware settings for LoRa.
Attributes:
| Name | Type | Description |
|---|---|---|
ID |
The ID of the node. This should be unique to each node. [1, 65535]. |
|
WAIT_USB_HOST |
Flag for telling the firmware to wait for a USB connection. [0,1]. |
|
PANID |
The personal area network ID. [0, 65535]. |
|
REPETITION_CNT |
The default number of times a LoRa message is transmitted. [1, 4294967295]. |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraBandwidth
¶
Bases: IntEnum
LoRa signal bandwidth.
This enumeration defines the bandwidth of a LoRa signal.
The bandwidth determines how much spectrum is used to transmit data. Wider bandwidths enable higher data rates but typically reduce sensitivity and range.
Attributes:
| Name | Type | Description |
|---|---|---|
BW_125_KHZ |
125 kHz. |
|
BW_250_KHZ |
250 kHz. |
|
BW_500_KHZ |
500 kHz. |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraSpreadingFactor
¶
Bases: IntEnum
LoRa data rate.
This enumeration represents the data rate of a LoRa signal, expressed as a Spreading Factor (SF).
The Spreading Factor determines how many chirps are used to encode each symbol (2^SF chips per symbol). Higher values result in lower data rates but increased range and robustness.
Attributes:
| Name | Type | Description |
|---|---|---|
SF_6 |
Spreading factor 6 (fastest, shortest range). |
|
SF_7 |
Spreading factor 7. |
|
SF_8 |
Spreading factor 8. |
|
SF_9 |
Spreading factor 9. |
|
SF_10 |
Spreading factor 10. |
|
SF_11 |
Spreading factor 11. |
|
SF_12 |
Spreading factor 12 (slowest, longest range). |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraCodingRate
¶
Bases: IntEnum
LoRa coding rate.
This enumeration defines the LoRa coding rate, used for forward error correction (FEC).
The coding rate is expressed as 4/x, where a lower denominator (e.g., 4/5) means less redundancy, resulting in a higher data rate but reduced robustness. Higher redundancy (e.g., 4/8) improves error tolerance at the cost of data rate.
Attributes:
| Name | Type | Description |
|---|---|---|
CR_4_5 |
Coding rate 4/5 (4 information bits, 1 error correction bit). |
|
CR_4_6 |
Coding rate 4/6 (4 information bits, 2 error correction bits). |
|
CR_4_7 |
Coding rate 4/7 (4 information bits, 3 error correction bits). |
|
CR_4_8 |
Coding rate 4/8 (4 information bits, 4 error correction bits). |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraConfig
dataclass
¶
Configurations for the LoRa modem.
Attributes:
| Name | Type | Description |
|---|---|---|
frequency |
int
|
Frequency in Hz to use for transceiving. Default is 915 MHz. |
bandwidth |
LoraBandwidth
|
The bandwidth to use for transceiving. Default is 125 kHz. |
datarate |
LoraSpreadingFactor
|
The data-rate to use for transceiving. Default is SF_12. |
coding_rate |
LoraCodingRate
|
The coding rate to use for transceiving. Default is CR_4_5. |
preamble_length |
int
|
Length of the preamble. Default is 8. |
tx_power |
int
|
TX-power in dBm to use for transmission. Default is 10 dBm. |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraLedState
¶
Bases: IntEnum
Different states the LED can be in (except for fetch).
Attributes:
| Name | Type | Description |
|---|---|---|
OFF |
LED is turned off. |
|
ON |
LED is solid on. |
|
BLINK |
LED is blinking at 1 Hz. |
|
FADE |
LED is fading on and off. |
|
FETCH |
Fetch the current LED state from the firmware. |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraSerialConfig
dataclass
¶
Configurations for the LoRa serial driver.
Attributes:
| Name | Type | Description |
|---|---|---|
port |
str
|
The serial port to connect to. |
response_timeout |
float
|
The amount of time (in seconds) to wait for a response from the firmware. |
rx_period |
float
|
How often (in seconds) the serial driver polls the serial receive buffer. |
serial_timeout |
float
|
The serial RX timeout (in seconds). |
start_callback |
Callable[[int, int], None] | None
|
Event handler for start events. Signature: [seconds: int, nsecs: int] -> None |
heartbeat_callback |
Callable[[int, bool], None] | None
|
Event handler for heartbeat events. Signature: [source_id: int, read: bool] -> None |
claim_callback |
Callable[[int], None] | None
|
Event handler for claim master events. Signature: [source_id: int] -> None |
master |
bool
|
Designate the connected node as the master node. |
log_callback |
Callable[[int, str], None]
|
Event handler for log events. Signature: [source_id: int, msg: str] -> None |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraSerial
¶
LoRa serial driver python implementation. Works only on Linux.
Source code in serial-driver/src/ares_lora/lserial.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
ares_lora.LoraSerial.reception_count
property
¶
ares_lora.LoraSerial.transmission_count
property
¶
transmission_count: int
The number of packets transmitted over LoRa.
Returns:
| Type | Description |
|---|---|
int
|
The number of packets transmitted by the connected node. |
ares_lora.LoraSerial.__init__
¶
__init__(config: LoraSerialConfig = LoraSerialConfig())
Initializes the LoRa driver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
LoraSerialConfig
|
The configurations for the LoRa driver. |
LoraSerialConfig()
|
Raises:
| Type | Description |
|---|---|
ValueError
|
Empty port configuration. |
IOError
|
Port not found. |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraSerial.led
¶
led(led_id: int, state: LoraLedState = FETCH) -> LoraLedState | None
Set or retrieve the state of the LED.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
led_id
|
int
|
The ID/number of the LED to fetch/set the state of. |
required |
state
|
LoraLedState
|
The new state of the LED. If set to LoraLedState.FETCH, then retrieves the current state of the LED. (Default: LoraLedState.FETCH) |
FETCH
|
Returns:
| Type | Description |
|---|---|
LoraLedState | None
|
The current LED state if state is LoraLedState.FETCH. None otherwise. |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
No response from the firmware within the configured timeout. |
LoraException
|
Firmware responded with an error code. |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraSerial.lora_config
¶
lora_config(config: LoraConfig)
Configure the LoRa modem.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
LoraConfig
|
The LoRa modem configurations. |
required |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
No response from the firmware within the configured timeout. |
LoraException
|
Firmware responded with an error code. |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraSerial.send_heartbeat
¶
Send a heartbeat over LoRa.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ready
|
bool
|
Flag indicating that the system is ready to start collecting data. |
required |
strobe_count
|
int
|
The number of times to transmit the heartbeat. |
3
|
timeout
|
float
|
The timeout of the transmission. |
20.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
The strobe count is invalid. |
TimeoutError
|
No response from the firmware within the configured timeout. |
LoraException
|
Firmware responded with an error code. |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraSerial.send_log
¶
send_log(
log_msg: str,
broadcast: bool = False,
dst_id: int | None = None,
strobe_count: int = 3,
timeout: float = 15.0,
)
Send a log message over LoRa.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_msg
|
str
|
The log message to send over LoRa. |
required |
broadcast
|
bool
|
Flag indicating if the message should be broadcasted to all nodes on the network. |
False
|
dst_id
|
int | None
|
The destination for the log message. Ignored if the broadcast flag is set. |
None
|
strobe_count
|
int
|
The number of times to send the broadcast message. The number of attempts per chunk if a directed message. |
3
|
timeout
|
float
|
The timeout per a transmission. |
15.0
|
Raises:
| Type | Description |
|---|---|
ValueError
|
The strobe count is invalid. |
TimeoutError
|
No response from the firmware within the timeout. |
LoraException
|
Firmware responded with an error code. |
Notes
- If the message is chunked, then timeout is the timeout for each chunk (Not the timeout for all the chunks to be transmitted in).
- If broadcast is set to
Falseand the destination isNone, then the destination will be set to the master node. If the master node has not been claimed, then the broadcast flag will be overridden to beTrue.
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraSerial.set_logging_level
¶
set_logging_level(level: int)
Set the logging level of the LoRa driver core library.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
int
|
The new logging level of the core library. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the logging level is invalid. |
Notes
This is compatible with the logging levels found in the python logging module.
10: DEBUG20: INFO30: WARNING40: ERROR50: CRITICAL60: OFF
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraSerial.setting
¶
Set or retrieve a LoRa firmware setting.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
setting_id
|
SettingId
|
The setting to read or write to. |
required |
value
|
int | None
|
The new value of the setting. If None, reads the specified setting. |
None
|
Returns:
| Type | Description |
|---|---|
int | None
|
If writing a setting, None. If reading a setting, the value of the setting. |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
No response from the firmware within the configured timeout. |
LoraException
|
Firmware responded with an error code. |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraSerial.start
¶
start(
sec: int,
nsec: int,
timeout: float = 20.0,
broadcast: bool = True,
destination_id: int | None = None,
) -> None
Send start time over LoRa
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sec
|
int
|
The seconds part of the time to start. |
required |
nsec
|
int
|
The nanoseconds part of the time to start. |
required |
timeout
|
float
|
The timeout of the transmission. |
20.0
|
broadcast
|
bool
|
Broadcast the message to all the nodes. |
True
|
destination_id
|
int | None
|
The destination node if not broadcasting. This field is ignored if broadcasting. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
The destination ID is invalid. |
ValueError
|
The start time is invalid. |
TimeoutError
|
No response from the firmware within the timeout. |
LoraException
|
Firmware responded with an error code. |
Source code in serial-driver/src/ares_lora/lserial.py
ares_lora.LoraSerial.start_driver
¶
ares_lora.LoraSerial.stop_driver
¶
ares_lora.LoraSerial.version
¶
Retrieves all the firmware version information.
Returns:
| Type | Description |
|---|---|
tuple[tuple[int, int, int], tuple[int, int, int], tuple[int, int, int]]
|
A tuple of versions. The first tuple is the application version, the second tuple is the ncs version, and the third tuple is the kernel version. |
Raises:
| Type | Description |
|---|---|
TimeoutError
|
No response from the firmware within the configured timeout. |
LoraException
|
Firmware responded with an error code. |
Notes
A version tuple is as follows: (major, minor, patch).