Constants and Enumerations

This section lists and describes the numerous constants defined by the SNAPconnect library.

Note

The constants defined here are in the snap Python module. For readability, we have removed the module prefix, but you will need to prefix them with snap. in your code. For example:

save_nv_param( snap.NV_AES128_ENABLE_ID, snap.ENCRYPTION_TYPE_NONE )

set_hook(snap.hooks.HOOK_TRACEROUTE, trace_route_handler)

Encryption

Constant Description
ENCRYPTION_TYPE_NONE Used to turn off encryption.
ENCRYPTION_TYPE_AES128 Used to enable AES-128 encryption.
ENCRYPTION_TYPE_BASIC Used to enable basic SNAP encryption.

Serial port operations

You will use the following constants as the serial_type parameter to the close_serial(), open_serial(), hooks.HOOK_SERIAL_OPEN, and hooks.HOOK_SERIAL_CLOSE handler functions.

Constant Description
SERIAL_TYPE_SNAPSTICK100 The SN132 SNAPstick, sometimes referred to as a “paddle board”, or the SN163 demonstration board, sometimes referred to as a “bridge board”. These are easily recognized, since they have no case (cover), and you can swap out the SNAP Engine on it for a different model. These have to be plugged into a USB port.
SERIAL_TYPE_SNAPSTICK200 The SS200 SNAPstick has a plastic case and does not accept plug-in SNAP Engines. It is completely self-contained and has to be plugged into a USB port.
SERIAL_TYPE_RS232 “True” COM port, or a USB-serial cable.

Rpc_source_interface()

Constant Description
INTF_TYPE_UNKNOWN You should never see this
INTF_TYPE_802154 For future use, as SNAPconnect currently relies on a “bridge” node to provide the radio
INTF_TYPE_SERIAL RPC call came in over RS-232
INTF_TYPE_SILABS_USB RPC call came in over a Silicon Labs USB interface chip (i.e., an SN132 or SN163)
INTF_TYPE_ETH RPC call came in over TCP/IP
INTF_TYPE_SNAPSTICK RPC call came in from an SS200 SNAPstick

SPY Uploading

Constant Description
SNAPPY_PROGRESS_ERASE Previous script has been erased
SNAPPY_PROGRESS_UPLOAD “Chunk” of script accepted
SNAPPY_PROGRESS_COMPLETE Upload completed successfully
SNAPPY_PROGRESS_ERROR Upload failed
SNAPPY_PROGRESS_TIMEOUT Node failed to respond
SNAPPY_PROGRESS_WRITE_ERROR FLASH write failure
SNAPPY_PROGRESS_WRITE_REFUSED Power too low to attempt
SNAPPY_PROGRESS_UNSUPPORTED Node does not support script upload. For example, it is a SNAPconnect instance rather than an embedded node.

Firmware upgrades

Constant Description
OTA_PROGRESS_COMPLETE Upgrade completed successfully
OTA_PROGRESS_ERROR Upgrade failed
OTA_PROGRESS_CANCELED Upgrade canceled
OTA_PROGRESS_TIMEOUT Node failed to respond
OTA_PROGRESS_WRITE_ERROR FLASH write failure
OTA_PROGRESS_WRITE_REFUSED Power too low to attempt
OTA_PROGRESS_UNSUPPORTED Node does not support over the air firmware upgrade

Logging

Python logging supports fine-grained control of level (verbosity).

The levels that can be applied are DEBUG, INFO, WARNING, ERROR, and FATAL, where DEBUG is the most verbose, and FATAL is the least.

To change the log level globally, you would do something like:

log = logging.getLogger()
log.setLevel(logging.DEBUG)

To change the level on a per-module basis, you use the name of the module: apy, SerialWrapper, snap, or snaplib. For example:

snaplib_log = logging.getLogger('snaplib')
snaplib_log.setLevel(logging.ERROR)

Even finer-grained control is possible, but you have to know the name (label) of the loggers you want to control. That is the purpose of this next list.

  • SerialWrapper
    • SerialWrapper.pySerialSocket
  • snap
    • snap.AutoSaver
    • snap.Deferred
    • snap.PacketSink
    • snap.dispatchers
    • snap.listeners
    • snap.mesh
    • snap.SNAPtcpConnection
    • snap.SNAPtcpServer
  • snaplib
    • snaplib.ComUtils
    • snaplib.EventCallbacks
    • snaplib.PacketQueue
    • snaplib.PacketSerialProtocol
    • snaplib.PySerialDriver
    • snaplib.RpcCodec
    • snaplib.TraceRouteCodec
    • snaplib.ScriptsManager
    • snaplib.SerialConnectionManager
    • snaplib.SnappyUploader

For example:

snaplib_log = logging.getLogger('snaplib.RpcCodec')
snaplib_log.setLevel(logging.INFO)