Agile-IoT / agile-protocol

0 stars 1 forks source link

Zigbee protocol implementation #1

Closed jordiescudero closed 5 years ago

jordiescudero commented 7 years ago

Hello All, I'm working with zigbee protocol in order to integrate the AGILE gateway with a custom devices (prototyped over arduino hardware).

We had to make a little setup to the original zigbee protocol (developed with python3) to opererate with our components but the implementation of this protocol is incomplete.

Current development only supports:

• def Connect(self): • def Disconnect(self): • def Setup(self, args): • def Send(self, args): • def Receive(self):

but We miss:

• def Discover(self, args): • def Exec(self, op, args): • def Send(self, args): • def Receive(self): • def Subscribe(self, args):

The question is if these base protocols (ble,zigbee and lorawan) are part of the AGILE core or We need to implement a custom protocol for our pilot (Pilot-D).

Regards

dpalomares-libelium commented 7 years ago

Hi,

The original DBus API cannot be applied to all the different protocols, that's why some of the protocols implement part of the API and raises exceptions when calling not implemented functions.

Let me reply one by one:

but We miss:

  • def Discover(self, args):

Discovery for ZigBee is in a block status, as right now there is no reliable method (or we haven't been able to find one) to make it work on XBee ZigBee modules.

  • def Exec(self, op, args):

This function was intented for other types of protocols, and right now I don't really know if it is still in the API. What do you want it for? To execute commands for the module, you can use the Send() function with the "api_command": "at" parameter.

  • def Send(self, args):
  • def Receive(self):

These are already implemented.

  • def Subscribe(self, args):

Don't know if this fits in this layer or in an upper layer, maybe will be implemented in the future.

Also, if you have an AGILE Maker's Shield, take a look at these repos: https://github.com/Agile-IoT/agile-makers-shield-hardware https://github.com/Agile-IoT/agile-makers-shield-firmware https://github.com/Agile-IoT/agile-makers-shield-software

jordiescudero commented 7 years ago

Do you have an example of node-red use with the zigbee protocol? I don't know if the payload of the send command is compatible with the current implementation.

Any way is necesary to manually add the device on the protocol manager if the discovery process is not abled.

Seems that the flow discovery->connect-->command planned in AGILE is only supported with BLE.

cskiraly commented 7 years ago

@jordiescudero I think you've raised an important issue. I agree with @dpalomares-libelium, with the small note that the problem is not D-Bus specific. Independent of the interface language, it is a hard problem to define an API to which so many and such different protocols (at different abstraction/OSI leyers) can be mapped. As a consequence, we have went through different versions of the API, and there are inconsistencies between implementations. The newest proposal is documented at https://github.com/Agile-IoT/agile-api-spec/issues/15 The task ahead is to agree on the new version, and align protocol implementations to this.

Regarding Node-RED and ZigBee: we have an example that uses a ZB lamp. Note that the intended use is not to use the Protocol API directly from Node-RED (even if it can be done), but to implement the device as an AGILE device exposing the Device API and using the Protocol API. Then, use this device from Node-RED.

jordiescudero commented 7 years ago

@cskiraly If I'm not wrong the flow to recognize a device inside the node-red requires the discovery and register of the devices (I think that without node-red has the same requeriment).

The "GE Lamp" device is registered in the ProtocolManager code:

// for demo purposes
devices.add(new DeviceOverview("0A:03:11:0A:01:00", ZB_PROTOCOL_ID, "GE Lamp", "AVAILABLE"));

And if We want to use the exposed D-Bus api throught REST api is necessary to add more devices on the ProtocolManager code.

Is that the correct way? PotocolManager is part of the agile-core and I'm worried about needs to be modified by our pilot implementation.