Dear developers,
today the OpenSpime library PyOpenSpime v0.2 has been released! This version 0.2 does not fully support the OpenSpime protocol v0.9 yet, however it fully implements the Data Reporting OpenSpime core extension.
The main differences between the previous v0.1 release are:
To get you started, especially the new developers, please find here below a tutorial which basically is an updated version of Davide ‘Folletto’ Casali’s original tutorial for the previous release.
This video shows the necessary steps to try out in a few minutes a full data reporting cycle on your machine, using the PyOpenSpime library. For your convenience, the steps done in the video are also reported below, in the ‘Easy Steps for a full tryout’ section.
If you’re reading this, you most probably already know what a spime is: a technologically enabled device that interacts both with the physical and the digital environment, aware of its location and with an history about itself. The OpenSpime network is the first open infrastructure designed to bring spimes to life. For a technical introduction on OpenSpime please refer to this video. You may also prefer to read the exhaustive documentation that is available on the OpenSpime.org website.
The PyOpenSpime library is written in Python, therefore it should be easy for you to get it working thanks to Python’s cleanness and the simple design of the library.
To work with PyOpenSpime you need four things:
Download and install Python 2.5 if needed. Recent versions of Mac OSX and linux may skip this step.
The PyOpenSpime 0.2 library is distributed via Google Code with a GPL 3.0 license, just unzip the downloaded package. Inside it you’ll find:
Download and install the M2Crypto library. This library isn’t included in the package since it requires a platform-specific compiled runtimes, and also because it’s subject to the U.S. Export Administration Regulations. On the official website, however, there are some pre-compiled binaries for Windows and Mac which might match your development machine. You might take a shortcut for the Mac OS X 10.5 (i386) downloadable .egg file: just download it, rename it to zip and uncompress it. Take the M2Crypto/ folder and copy it inside the lib/ folder of the PyOpenSpime package.
Now let’s get your OSIDs on the OpenSpime Developer Netowork.
As stated before, you’ll need your unique OSIDs, so this steps requires a registration on the OpenSpime Developer Network SpimeGate. It’s simpler than you think, since the creation of the unique OSID is linked to the registration to the Developer Network: yes, this site.
If you are already a registered developer you may skip steps 1-6.
An OSpkg, aka an OpenSpime package, is a simple folder structure that contains the identity of an entity on the OpenSpime network. On your My Developer page, you’ll see that two have already been created for you. Download both OSpkg, the one for your Spime, and the one for your ScopeNode.
Here are the steps done in the video here above. First, unzip both OSpkg in the tut/ directory of PyOpenSpime. You will have now two additional directories which look like:
dev-spime-x@developer.openspime.com/spime dev-scopenode-x@developer.openspime.com/scope
Now open the file scopenode_basic.py in the tut/ directory and edit the line:
# SNID SNID = 'dev-scopenode-x@developer.openspime.com/scope'
so that it reflects the name of your ScopeNode ID:
# SNID SNID = 'dev-scopenode-2@developer.openspime.com/scope'
Doing this, we have set the ScopeNode to connect with your ScopeNode ID. Now open the file spime_basic.py and edit the line:
# SpimeID SpimeID = 'dev-spime-x@developer.openspime.com/spime'
so that it reflects the name of your SpimeID:
# SpimeID SpimeID = 'dev-spime-2@developer.openspime.com/spime'
Doing this, we have set the Spime to connect with your Spime ID. Then, edit the line
# SNID [i.e. the ScopeNode receiving data from this spime] SNID = ‘dev-scopenode-x@developer.openspime.com/scope’
so that it reflects the name of your ScopeNode ID:
# SNID [i.e. the ScopeNode receiving data from this spime] SNID = ‘dev-scopenode-2@developer.openspime.com/scope’
Doing this, we have set your Spime to send data to your ScopeNode.
Take a closer look at the following code in spime_basic.py:
# add xml data node dr_reqobj.add_entry(u"""<entry> <date>2008-10-09T10:02:22+01:00</date> <exposure>outdoor</exposure> <lat>45.475841199050905</lat> <lon>9.172725677490234</lon> <ele unit='m'>120.0</ele> <ppm>176.4</ppm> </entry>""") # send request req_id = self.send_request(dr_reqobj, SNID, encrypt = True, sign = True)
We have added an hardcoded entry in XML format, and this entry will be sent to your ScopeNode encrypted and signed.
Now:
To perform this operation, two public RSA keys will automatically be exchanged:
You may find these keys in the newly created cache/ folder.
Your first easy tryout is now done! Let’s get deeper. What’s an OSpkg?
The OpenSpime Package, or OSpkg, is a simple folder structure that contains the identity of an entity on the OpenSpime network.
While your source code might do any kind of work and might be written in any kind of language, the OSpkg is a simple structure that holds the identity informations of a specific spime.
In XMPP, the backbone of OpenSpime, each client is identified by a full JID (OSID on the OpenSpime Network), which is something that looks like this:
name@server/resource
The OSpkg has the same structure, but it’s mapped to a folder:
name@server/
resource/
This allows a good separation of the OSID entity information from the source code.
Inside each resource folder there’s a conf.xml file, describing the spime properties and an optional keys/ folder containing its private and public keys to allow encoded communication and digital signature.
The two zip files which can be downloaded from the My Developer page are two valid OSpkg that you can use for your development, which connect to the OpenSpime Developer Network SpimeGate.
Happy spiming! :)
Discussion
No comments for “PyOpenSpime 0.2 launched!”
Post a comment
You must be logged in to post a comment.