Skip to content

Commit bbb11fe

Browse files
Update Notecard API from upstream schema changes (e00be73557326da7806228bbc283143bc3644570)
1 parent b7c33a1 commit bbb11fe

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

notecard/card.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def locationMode(card, delete=None, lat=None, lon=None, max=None, minutes=None,
352352
lat (float): When in periodic or continuous mode, providing this value enables geofencing. The value you provide for this argument should be the latitude of the center of the geofence, in degrees. When in fixed mode, the value you provide for this argument should be the latitude location of the device itself, in degrees.
353353
lon (float): When in periodic or continuous mode, providing this value enables geofencing. The value you provide for this argument should be the longitude of the center of the geofence, in degrees. When in fixed mode, the value you provide for this argument should be the longitude location of the device itself, in degrees.
354354
max (int): Meters from a geofence center. Used to enable geofence location tracking.
355-
minutes (int): When geofence is enabled, the number of minutes the device should be outside the geofence before the Notecard location is tracked.
355+
minutes (int): When geofence is enabled, the debounce period in minutes for transitions across the geofence boundary. The Notecard reports a transition the first time a GPS fix lands on the opposite side of the boundary from the previous one, then ignores further transitions for this many minutes.
356356
mode (str): Sets the location mode.
357357
seconds (int): When in `periodic` mode, location will be sampled at this interval, if the Notecard detects motion. If seconds is < 300, during periods of sustained movement the Notecard will leave its onboard GPS/GNSS on continuously to avoid powering the module on and off repeatedly.
358358
threshold (int): When in `periodic` mode, the number of motion events (registered by the built-in accelerometer) required to trigger GPS to turn on.
@@ -399,7 +399,7 @@ def location(card):
399399

400400
@validate_card_object
401401
def locationTrack(card, file=None, heartbeat=None, hours=None, payload=None, start=None, stop=None, sync=None):
402-
"""Store location data in a Notefile at the `periodic` interval, or using a specified `heartbeat`. This request is only available when the `card.location.mode` request has been set to `periodic`—e.g. `{"req":"card.location.mode","mode":"periodic","seconds":300}`. If you want to track and transmit data simultaneously consider using an external GPS/GNSS module with the Notecard. If you connect a BME280 sensor on the I2C bus, Notecard will include a temperature, humidity, and pressure reading with each captured Note. If you connect an ENS210 sensor on the I2C bus, Notecard will include a temperature and pressure reading with each captured Note. Learn more in _track.qo.
402+
"""Store location data in a Notefile at the `periodic` interval, or using a specified `heartbeat`. This request is only available when the `card.location.mode` request has been set to `periodic`—e.g. `{"req":"card.location.mode","mode":"periodic","seconds":300}`. If you want to track and transmit data simultaneously consider using an external GPS/GNSS module with the Notecard. If you connect a BME280 sensor on the I2C bus, Notecard will include a temperature, humidity, and pressure reading with each captured Note. If you connect an ENS210 sensor on the I2C bus, Notecard will include a temperature and humidity reading with each captured Note. Learn more in _track.qo.
403403
404404
Args:
405405
card (Notecard): The current Notecard object.
@@ -586,18 +586,21 @@ def random(card, count=None, mode=None):
586586

587587

588588
@validate_card_object
589-
def power(card, minutes=None, reset=None):
589+
def power(card, hours=None, minutes=None, reset=None):
590590
"""Use `card.power` API is used to configure a connected Mojo device or to manually request power consumption readings in firmware.
591591
592592
Args:
593593
card (Notecard): The current Notecard object.
594-
minutes (int): How often, in minutes, Notecard should log power consumption in a `_log.qo` Note. The default value is `720` (12 hours).
594+
hours (int): How often, in hours, Notecard should log power consumption in a `_log.qo` Note. Provided as a convenience alternative to `minutes`. If both `hours` and `minutes` are provided, the resulting cadence is the sum of the two.
595+
minutes (int): How often, in minutes, Notecard should log power consumption in a `_log.qo` Note. The default value is `720` (12 hours). May be combined with `hours`, in which case the two values are added together.
595596
reset (bool): Set to `true` to reset the power consumption counters back to 0.
596597
597598
Returns:
598599
dict: The result of the Notecard request.
599600
"""
600601
req = {"req": "card.power"}
602+
if hours is not None:
603+
req["hours"] = hours
601604
if minutes is not None:
602605
req["minutes"] = minutes
603606
if reset is not None:
@@ -681,7 +684,7 @@ def status(card):
681684

682685
@validate_card_object
683686
def temp(card, minutes=None, status=None, stop=None, sync=None):
684-
"""Get the current temperature from the Notecard's onboard calibrated temperature sensor. When using a Notecard Cellular or Notecard Cell+WiFi, if you connect a BME280 sensor on the I2C bus the Notecard will add `temperature`, `pressure`, and `humidity` fields to the response. If you connect an ENS210 sensor on the I2C bus the Notecard will add `temperature` and `pressure` fields to the response.
687+
"""Get the current temperature from the Notecard's onboard calibrated temperature sensor.
685688
686689
Args:
687690
card (Notecard): The current Notecard object.
@@ -737,14 +740,15 @@ def trace(card, mode=None):
737740

738741

739742
@validate_card_object
740-
def transport(card, allow=None, method=None, seconds=None, umin=None):
743+
def transport(card, allow=None, method=None, seconds=None, set=None, umin=None):
741744
"""Specify the connectivity protocol to prioritize on the Notecard Cell+WiFi, or when using NTN mode with Starnote and a compatible Notecard.
742745
743746
Args:
744747
card (Notecard): The current Notecard object.
745-
allow (bool): Set to `true` to allow adding Notes to non-compact Notefiles while connected over a non-terrestrial network. See Define NTN vs non-NTN Templates.
748+
allow (bool): Set to `true` to allow adding Notes to templated Notefiles that have no `port` while connected over a non-terrestrial network. See Define NTN vs non-NTN Templates.
746749
method (str): The connectivity method to enable on the Notecard.
747750
seconds (int): The amount of time (in seconds) a Notecard will spend on any fallback transport before retrying the first transport specified in the `method`. The default is `3600` or 60 minutes.
751+
set (bool): Set to `true` to apply the `allow` argument without also changing the transport `method`.
748752
umin (bool): Set to `true` to force a longer network transport timeout when using Wideband Notecards.
749753
750754
Returns:
@@ -757,6 +761,8 @@ def transport(card, allow=None, method=None, seconds=None, umin=None):
757761
req["method"] = method
758762
if seconds is not None:
759763
req["seconds"] = seconds
764+
if set is not None:
765+
req["set"] = set
760766
if umin is not None:
761767
req["umin"] = umin
762768
return card.Transaction(req)
@@ -855,7 +861,7 @@ def version(card):
855861

856862

857863
@validate_card_object
858-
def voltage(card, alert=None, calibration=None, hours=None, mode=None, name=None, off=None, offset=None, on=None, set=None, sync=None, usb=None, vmax=None, vmin=None):
864+
def voltage(card, alert=None, calibration=None, hours=None, mode=None, name=None, now=None, off=None, offset=None, on=None, set=None, sync=None, usb=None, vmax=None, vmin=None):
859865
"""Provide the current VMODEM_P voltage level on the Notecard, and provides information about historical voltage trends. When used with the mode argument, configures voltage thresholds based on how the device is powered.
860866
861867
Args:
@@ -865,14 +871,15 @@ def voltage(card, alert=None, calibration=None, hours=None, mode=None, name=None
865871
hours (int): The number of hours to analyze, up to 720 (30 days).
866872
mode (str): Used to set voltage thresholds based on how the Notecard will be powered, and which can be used to configure voltage-variable Notecard behavior. Each value is shorthand that assigns a battery voltage reading to a given device state like `high`, `normal`, `low`, and `dead`. In addition to the named presets below, a custom semicolon-separated shorthand string may be provided using any combination of the `usb`, `high`, `normal`, `low`, and `dead` states (e.g. `"usb:4.6;high:4.2;normal:3.6;low:0"`). NOTE: Setting voltage thresholds is not supported on the Notecard XP.
867873
name (str): Specifies an environment variable to override application default timing values.
874+
now (bool): By default, the returned `value` is an average of the voltage readings taken over the previous 15 minutes, which smooths out momentary fluctuations. Set to `true` to return the instantaneous voltage reading instead.
868875
off (bool): Disable historic voltage trend calculations.
869876
offset (int): Number of hours to move into the past before starting analysis.
870877
on (bool): Enable historic voltage trend calculations.
871878
set (bool): Used along with `calibration`, set to `true` to specify a new calibration value.
872879
sync (bool): When enabled and the `usb` argument is set to `true`, the Notecard will perform a sync when USB power is connected or disconnected.
873880
usb (bool): When enabled, the Notecard will monitor for changes to USB power state.
874-
vmax (float): Ignore voltage readings above this level when performing calculations.
875-
vmin (float): Ignore voltage readings below this level when performing calculations.
881+
vmax (float): Ignore voltage readings above this level when performing calculations. Defaults to the maximum voltage the Notecard's components are rated for.
882+
vmin (float): Ignore voltage readings below this level when performing calculations. Defaults to the minimum voltage the Notecard's components are rated for.
876883
877884
Returns:
878885
dict: The result of the Notecard request.
@@ -888,6 +895,8 @@ def voltage(card, alert=None, calibration=None, hours=None, mode=None, name=None
888895
req["mode"] = mode
889896
if name:
890897
req["name"] = name
898+
if now is not None:
899+
req["now"] = now
891900
if off is not None:
892901
req["off"] = off
893902
if offset is not None:

notecard/hub.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def set(card, align=None, details=None, duration=None, host=None, inbound=None,
5555
5656
Args:
5757
card (Notecard): The current Notecard object.
58-
align (bool): Use `true` to align syncs on a regular time-periodic cycle.
58+
align (bool): Use `true` to align syncs on a regular time-periodic cycle. The cycle is anchored to the Notecard's boot time, not to a wall-clock time.
5959
details (str): When using Notecard LoRa you can use this argument to provide information about an alternative LoRaWAN server or service you would like the Notecard to use. The argument you provide must be a JSON object with three keys, "deveui", "appeui", and "appkey", all of which are hexadecimal strings with no leading 0x. For example: `{"deveui":"0080E11500088B37","appeui":"6E6F746563617264","appkey":"00088B37"}` The LoRaWAN details you send to a Notecard become part of its permanent configuration, and survive factory resets. You can reset a Notecard's LoRaWAN details to its default values by providing a `"-"` for the details argument.
6060
duration (int): When in `continuous` mode, the amount of time, in minutes, of each session (the minimum allowed value is `15`). When this time elapses, the Notecard gracefully ends the current session and starts a new one in order to sync session-specific data to Notehub.
6161
host (str): The URL of the Notehub service. Use `"-"` to reset to the default value.

0 commit comments

Comments
 (0)