It's a python class that you should be able to use in whatever project you want, In my setup the python program is running on a PC that has a base moteino connected via usb but this should also work on a RasberryPi
My goal was essentially to move the decision making of the network into python because there I have access to more data and can therefore make better decisions. It will also make it a lot easier to add functionality to the network at a later stage.
For example: Device A reports X and therefore device B should do Y unless Device C reports Z.
All communication goes through the python script so Device A just tells python about X instead of telling B directly to do Y and then B checking on C.
One nice thing about this is that the BaseMoteino has no idea what it is sending so there is no need to program the BaseMoteino if you add a device to your network.
In the example I gave I called:
mynetwork.send({'Send2': 'TestDevice', 'Command': 123, 'Something': 456})
Out there should be a moteino node called TestDevice waiting to recieve a struct declared by:
typedef struct{
unsigned int Command;
unsigned int Something;
} Payload;
the python module knows this because I told it that out there is a device called TestDevice with ID=0 that sends and receives that kind of struct, I did this with:
mynetwork.add_device(name='TestDevice', _id=0, structsring="int Command;int Something;")
When I called mynetwork.send(...) python prints to the Serial port: '007b00c801' which means: send to device with ID='00' the info '7b00c801'.
the BaseMoteino interprets from hex into bytes and sends it, The TestDevice recieves this info, assumes it contains the struct it expects and casts the info into the struct. It can then extract from the struct like normally.
Regarding how python accepts data from the network I assume each user will overwrite the recieve function like I did but to have some functionality you'd probably want something like:
def recieve(self, diction):
if diction['Sender'] == 'TestDevice':
if diction['Command'] == 100:
print "TestDevice just reported about whatever command 100 means"
print "It also told us that something is: " + str(diction['Something'])
so diction will contain all the info recieved from the network.