python / micropython library for the Astronode S
This library is a direct port to micropython of Astrocast's official Arduino library: https://github.com/Astrocast/astronode-arduino-library
- ESP32
- ESP8266
- Ubuntu
- Windows
The implementation of Astronode's Serial Commands Definition.
The main class that handles the module commands:
Constructor of the class
- Parameters:
module_tx
: the UART TX Pin number/name (in micropython). Else in Python,None
module_rx
: the UART RX Pin number/name (in micropython). Else in Python,None
module_serial_port_name
:None
(in micropython). Else in Python the name of the UART (ex. in Linux/dev/ttyUSB0
, in WindowsCOM3
)
Class for module configuration storage.
product_id
hardware_rev
firmware_maj_ver
firmware_min_ver
firmware_rev
with_pl_ack
with_geoloc
with_ephemeris
with_deep_sleep_en
with_msg_ack_pin_en
with_msg_reset_pin_en
Class for storing Performance Counters
sat_search_phase_cnt
sat_detect_operation_cnt
signal_demod_phase_cnt
signal_demod_attempt_cnt
signal_demod_success_cnt
ack_demod_attempt_cnt
ack_demod_success_cnt
queued_msg_cnt
dequeued_unack_msg_cnt
ack_msg_cnt
sent_fragment_cnt
ack_fragment_cnt
cmd_demod_attempt_cnt
cmd_demod_success_cnt
Class for storing Module State
msg_in_queue
ack_msg_in_queue
last_rst
uptime
Class for storing Environment Details
last_mac_result
last_sat_search_peak_rssi
time_since_last_sat_search
Class for storing Last Contact Details
time_start_last_contact
time_end_last_contact
peak_rssi_last_contact
time_peak_rssi_last_contact
Class for storing Downling Command Info
create_date
data
Check connectivity with the module.
- Returns:
- (boolean) the connection status with the module.
Send command, validate response code and get response data
- Parameters:
reg_req
: (int) the code of the request command as defined in Astrocast's documentationreg_ans
: (int) the code of the expected response command as defined in Astrocast's documentationparams
: (string / bytearray) the parameters of the request command. Strings can be accepted, otherwise it is advised to provide bytearrays (ex. b'testing')
- Returns tuple (status, data):
status
: (int) the status code of the operation. Possible values are defined as macros atastronode.ANS_STATUS_*
. A successful call always returnsastronode.ANS_STATUS_DATA_RECEIVED
. Can be translated into human readable form by calling ASTRONODE.get_error_code_string(status)data
: (bytearray) the data in bytes returned by the module. They require further processing to be usable.
Get a human readable description for the return status of the commands
- Parameters:
code
: the status code to be translated
- Returns:
text
: (string) the description of the code
Enable debug printing
Disable debug printing
configuration_write
(with_pl_ack
, with_geoloc
, with_ephemeris
, with_deep_sleep
, with_ack_event_pin_mask
, with_reset_event_pin_mask
)`
Setup the behavior of the module (link: CFG_WR Request):
- Parameters:
with_pl_ack
: Enable Satellite Acknowledgement Notificationwith_geoloc
: Add Geolocation data to message (see:ASTRONODE.geolocation_write
)with_ephemeris
: Enable Ephemeriswith_deep_sleep
: Enable Deep Sleep Modewith_ack_event_pin_mask
: Enable Payload Ack Event Pin Maskwith_reset_event_pin_mask
: Enable Reset Notification Event Pin Mask
- Returns tuple (status, None):
status
: (int) the status code of the operation
Read the device configuration (link: CFG_RR)
- Returns tuple (status, config):
status
: (int) the status code of the operationconfig
: ASTRONODE.ASTRONODE_CONFIG object
Save the current configuration (link: CFG_SR)
- Returns tuple (status, None):
status
: (int) the status code of the operation
When using WiFi Dev Kit, set WiFi credentials and Astrocast Portal Access Token (link: WIF_WR)
- Returns tuple (status, None):
status
: (int) the status code of the operation
Set Satellite Search Configuration (link: SSC_WR)
- Parameters:
search_period
: Search Period Enumeration defined as macro astronode.SAT_SEARCH_*force_search
: Enable search without message queued
- Returns tuple (status, None):
status
: (int) the status code of the operation
Set device geolocation info to be send if ASTRONODE.ASTRONODE_CONFIG.with_geoloc
is enabled (link: GEO_WR)
- Parameters:
lat
: (float) Latitude valuelon
: (float) Longitude value
- Returns tuple (status, None):
status
: (int) the status code of the operation
Factory reset module (link: CFG_FR)
- Returns tuple (status, None):
status
: (int) the status code of the operation
Read Module GUID (link: MGI_RR)
- Returns tuple (status, guid):
status
: (int) the status code of the operationguid
: (string) Module's GUID
Read Module Serial Number (link: MSN_RR)
- Returns tuple (status, sn):
status
: (int) the status code of the operationsn
: (string) modules's Serial Number
Read Module Product Number (link: MPN_RR)
- Returns tuple (status, pn):
status
: (int) the status code of the operationpn
: (string) modules's Product Number
Read Modules RTC (link: RTC_RR)
- Returns tuple (status, time):
status
: (int) the status code of the operationtime
: (int) rtc time in epoch
Read Next Contact Opportunity (link: NCO_RR)
- Returns tuple (status, time):
status
: (int) the status code of the operationtime
: (int) time in seconds until the start of the next pass opportunity
Read Performance Counters (link: PER_RR)
- Returns tuple (status, per_data):
status
: (int) the status code of the operationper_data
: ASTRONODE.ASTRONODE_PER_STRUCT object
Save the current context to NVM (link: CTX_SR)
- Returns tuple (status, None):
status
: (int) the status code of the operation
Reset the performance counters to zero (link: PER_CR)
- Returns tuple (status, None):
status
: (int) the status code of the operation
Get information about the message queue and the last reset reason (link: MST_RR)
- Returns tuple (status, module_state):
status
: (int) the status code of the operationmodule_state
: ASTRONODE.ASTRONODE_MST_STRUCT object
Get environment details (link: END_RR)
- Returns tuple (status, env_details):
status
: (int) the status code of the operationenv_details
: ASTRONODE.ASTRONODE_END_STRUCT object
Get environment details (link: LCD_RR)
- Returns tuple (status, lcd_details):
status
: (int) the status code of the operationlcd_details
: ASTRONODE.ASTRONODE_LCD_STRUCT object
Place a payload in the module queue. (link: PLD_ER)
- Parameters:
data
: (bytearray) the payload in bytes to be transmitted (max: 160 bytes).id
: (2 bytes) ID of the message. If omitted, an auto-generated ID will be used.
- Returns tuple (status, id):
status
: (int) the status code of the operationid
: (2 bytes) the ID of the message
Remove the oldest payload from the module queue. (link: PLD_DR)
- Returns tuple (status, id):
status
: (int) the status code of the operationid
: (2 bytes) the ID of the message
Clean pending payload queue. (link: PLD_FR)
- Returns tuple (status, None):
status
: (int) the status code of the operation
Read downlink command. (link: CMD_RR)
- Returns tuple (status, dl_data):
status
: (int) the status code of the operationdl_data
: instance of ASTRONODE.ASTRONODE_DOWNLINK_COMMAND_STRUCT
Remove the downlink command that was previously read. (link: CMD_CR)
- Returns tuple (status, None):
status
: (int) the status code of the operation
Read the event register. (link: EVT_RR)
- Returns tuple (status, event_type):
status
: (int) the status code of the operationevent_type
: (int) enumeration code of event. Possible values are defined as macros atastronode.EVENT_MSG_*
Read Satellite ACK when a call to ASTRONODEevent_read() returns astronode.EVENT_MSG_ACK
. (link: SAK_RR)
- Returns tuple (status, id):
status
: (int) the status code of the operationid
: (2 bytes) the ID of the message
Clear previously read Satellite ACK through read_satellite_ack()
. (link: SAK_CR)
- Returns tuple (status, None):
status
: (int) the status code of the operation
clear_reset_event()
: clear the Module Reset bit in the Event Register (link RES_CR)
- Returns tuple (status, None):
status
: (int) the status code of the operation