(c) Copyright 2012 Synapse Wireless, Inc.

SpyUploader.py - A SpyUploader class, plus a simple example of usage.

=== 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.

SNAP Connect 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 the SpyUploader module as a standalone demo ===
    
python SpyUploader.py

Note that the file as-written uploads a hard-coded file to a hard-coded SNAP Node.

You might want to edit the line containing the beginUpload() function call.

    uploader.beginUpload("\x00\x86\xED", "shortBlinkRF100_2.4.9.spy")

=== Incorporating this functionality into your own SNAP Connect Application ===

To do this, you should use the following (high level) process:
    
A) import SpyUploader into your application (so that you can use it!)

import SpyUploader

B) Create an instance of the SpyUploader object

uploader = SpyUploader()

B) Tell the SpyUploader which SNAP Connect instance to use

uploader.assign_SnapCom(xxx)

If step B makes no sense to you, you need to backtrack to an easier example.
Refer (for example) to simpleSnapRouter.py, or one of the other code walk-thrus
from the SANP Connect Python Package Manual.

C) Tell the SpyUploader which callback handler to invoke at the end of the upload process

uploader.assign_Callback(yyy)        

D) Initiate the actual script upload

uploader.beginUpload(nodeAddress, filename)

The finishedSpyUpgrade() method you provided (in step C) will be invoked 
once the result of the transfer attempt is known.

This high-level overview has glossed over some steps.

For more details, refer to the profusely commented source file SpyUpload.py
