Skip to content

Upload a compiled SNAPpy "SPY" file to a node using SNAPconnect

License

Notifications You must be signed in to change notification settings

synapse-wireless/snapconnect-spy-upload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SNAPconnect Example - SNAPconnect SPY File Uploader

This example application allows you to upload a compiled SNAPpy "SPY" file to a node using SNAPconnect.

Background

Many networks use Portal to commission nodes, upload new SNAPpy scripts into them, etc.

Portal can upload either source (.py) or binary (.spy) files into embedded SNAP Nodes. Portal can also export ".py" files into ".spy" files.

SNAPconnect applications can also upload SPY files into SNAP Nodes, but doing so requires a handful of function calls. The SpyUploader class encapsulates some of the details, plus adds a high-level retry mechanism (it will attempt the entire script upload process up to three times).

Running This Example

In order to run this example, you will need to make sure that SNAPconnect is installed on your system:

pip install --extra-index-url https://update.synapse-wireless.com/pypi snapconnect

You will also need to make a few modifications to SpyUploader.py to configure your bridge address, serial type, and serial port. Some of the values that you can change include:

BRIDGE_NODE = "\x4B\x42\x34"
SERIAL_TYPE = snap.SERIAL_TYPE_RS232
SERIAL_PORT = 0 # COM1

Once you have configured the example, simply run:

$ python SpyUploader.py
2016-04-06 15:52:05 DEBUG: Querying for remote addr
2016-04-06 15:52:05 DEBUG: send: 0001.callback('7XombsadNuFWVJEP', 'getInfo', 3)
2016-04-06 15:52:05 DEBUG: Directing multi-cast to RS-232 Interface: 30
...
2016-04-06 15:52:08 DEBUG: send: 610dec.callback('su_recvd_reboot', 'reboot')
2016-04-06 15:52:08 DEBUG: rpc: 610dec.su_recvd_reboot(None,)
RF Script Upload: Successfully uploaded the script
errCode=3

Using SpyUploader in Your Own Application

You can use SpyUploader in your own SNAPconnect application by importing and setting up a SpyUploader instance:

  1. Import SpyUploader into your application:

    import SpyUploader
  2. Create an instance of the SpyUploader object:

    uploader = SpyUploader()
  3. Tell the SpyUploader which SNAPconnect instance to use:

    uploader.assign_SnapCom(xxx)
  4. Tell the SpyUploader which callback function to invoke at the end of the upload process:

    uploader.assign_Callback(yyy)
  5. Initiate the actual script upload:

    uploader.beginUpload(nodeAddress, filename)

License

Copyright © 2016 Synapse Wireless, licensed under the Apache License v2.0.

About

Upload a compiled SNAPpy "SPY" file to a node using SNAPconnect

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages