I’ve got an X2 and I want my python code to gather some information when it boots and send it to my remote server.
Is there a good way to access:
MAC Address
Firmware Version of the Connectport (Boot and Post)
XBEE Extended Address for the Connectport
PAN ID
IP address/submask/gateway
DHCP setting
I’d prefer not to go to os.system or subprocess to get this info from the command line tools.
Yes there is a easy way to gather that information. The module you’re looking for is called ‘digicli’, which is basically access to the command line interface via python. You can read more about it here: http://www.digi.com/wiki/developer/index.php/Digicli
The typical usage for gather information is doing the following:
Define what information you want
Find the CLI command that will display that information
Create a regular expression to distill the information
Call digicli with the command, parsing the results with regular expression.
On a sidenote, currently on Digi’s NDS products, os.system and the subprocess module are not supported, so this the only means to execute command line arguments to the device currently. An alternative to this is to use the RCI facilities in the device, which is basically XML formatted command and responses. This is typically more complicated than what a user needs, but if you want to be cross platform on Digi’s devices, the way to do it.
If you have the X2 with plastic case (so 8MB RAM), then be warned that it has limited memory - so be cautious and do things in small chucks.
You cannot run CGI directly on the X, however there is a ‘catch-all’ method which passes all unknown URI to Python, which allows you to create a ‘text string’ response which the X2 returns as the HTTP response. See this page: http://www.digi.com/wiki/developer/index.php/Module:digiweb
Note that your callback script cannot exit, so you cannot ‘load’ a callback in a stand-alone script. The tool managing your CGI needs to remaining running for the callback to function.