@@ -541,3 +541,114 @@ def auxSerial(card, mode=None, duration=None, rate=None, limit=None, max=None, m
541541 if minutes :
542542 req ["minutes" ] = minutes
543543 return card .Transaction (req )
544+
545+
546+ @validate_card_object
547+ def dfu (card , name = None , on = None , off = None , seconds = None , stop = None , start = None , mode = None ):
548+ """Configure a Notecard for Notecard Outboard Firmware Update.
549+
550+ Args:
551+ card (Notecard): The current Notecard object.
552+ name (string): One of the supported classes of host MCU. Supported MCU classes are
553+ 'esp32', 'stm32', 'stm32-bi', 'mcuboot', '-'.
554+ on (bool): Set to True to enable Notecard Outboard Firmware Update.
555+ off (bool): Set to True to disable Notecard Outboard Firmware Update from occurring.
556+ seconds (int): When used with 'off':True, disable Notecard Outboard Firmware Update
557+ operations for the specified number of seconds.
558+ stop (bool): Set to True to disable the host RESET that is normally performed on the
559+ host MCU when the Notecard starts up.
560+ start (bool): Set to True to enable the host RESET.
561+ mode (string): Optional mode for alternative DFU configuration.
562+
563+ Returns:
564+ dict: The result of the Notecard request containing:
565+ "name": Current MCU class configured for DFU
566+ """
567+ req = {"req" : "card.dfu" }
568+ if name :
569+ req ["name" ] = name
570+ if on is not None :
571+ req ["on" ] = on
572+ if off is not None :
573+ req ["off" ] = off
574+ if seconds :
575+ req ["seconds" ] = seconds
576+ if stop is not None :
577+ req ["stop" ] = stop
578+ if start is not None :
579+ req ["start" ] = start
580+ if mode :
581+ req ["mode" ] = mode
582+ return card .Transaction (req )
583+
584+
585+ @validate_card_object
586+ def illumination (card ):
587+ """Retrieve an illumination reading from an OPT3001 ambient light sensor connected to Notecard's I2C bus.
588+
589+ Args:
590+ card (Notecard): The current Notecard object.
591+
592+ Returns:
593+ dict: The result of the Notecard request containing:
594+ "value": An illumination reading (in lux) from the attached OPT3001 sensor.
595+
596+ Note:
597+ If no OPT3001 sensor is detected, this request returns an "illumination sensor is not available" error.
598+ """
599+ req = {"req" : "card.illumination" }
600+ return card .Transaction (req )
601+
602+
603+ @validate_card_object
604+ def io (card , i2c = None , mode = None ):
605+ """Override the Notecard's I2C address and change behaviors of the onboard LED and USB port.
606+
607+ Args:
608+ card (Notecard): The current Notecard object.
609+ i2c (int): The alternate address to use for I2C communication. Pass -1 to reset to the default address.
610+ mode (string): Mode to change LED or USB behavior. Options include:
611+ "-usb" - Disable the Notecard's USB port. Re-enable with "usb" or "+usb"
612+ "+busy" - LED will be on when Notecard is awake, off when asleep
613+ "-busy" - Reset "+busy" to default (LED blinks only during flash operations)
614+ "i2c-master-disable" - Disable Notecard acting as an I2C master
615+ "i2c-master-enable" - Re-enable I2C master functionality
616+
617+ Returns:
618+ dict: The result of the Notecard request.
619+ """
620+ req = {"req" : "card.io" }
621+ if i2c is not None :
622+ req ["i2c" ] = i2c
623+ if mode :
624+ req ["mode" ] = mode
625+ return card .Transaction (req )
626+
627+
628+ @validate_card_object
629+ def led (card , mode = None , on = None , off = None ):
630+ """Control connected LEDs or manage a single connected NeoPixel.
631+
632+ Args:
633+ card (Notecard): The current Notecard object.
634+ mode (string): Used to specify the color of the LED or NeoPixel to control.
635+ For LEDs: 'red', 'green', 'yellow'
636+ For NeoPixels: 'red', 'green', 'blue', 'yellow', 'cyan', 'magenta', 'orange', 'white', 'gray'
637+ on (bool): Set to True to turn the specified LED or NeoPixel on.
638+ off (bool): Set to True to turn the specified LED or NeoPixel off.
639+
640+ Returns:
641+ dict: The result of the Notecard request.
642+
643+ Note:
644+ Requires the card.aux API to be configured in 'led' or 'neo' mode first.
645+ Not supported by Notecard LoRa for regular LEDs.
646+ """
647+ req = {"req" : "card.led" }
648+ if mode :
649+ req ["mode" ] = mode
650+ if on is not None :
651+ req ["on" ] = on
652+ if off is not None :
653+ req ["off" ] = off
654+ return card .Transaction (req )
0 commit comments