iot-lab / iot-lab-mqtt

Provide access to IoT-LAB experiments as MQTT agents
Other
2 stars 8 forks source link

[WIP] Initial support for A8-m3 nodes #10

Open rfuentess opened 7 years ago

rfuentess commented 7 years ago

I'm starting to add support for using MQTT with A8-m3 nodes.

The first commit is adding support only for uploading firmwares as I want your opinion with the lines modified in def update(). I consider this option to be valid as there are other nodes supported not tested with MQTT (samr21, WSN430 ).

Also, the options available for A8 are sometimes different than those of the M3. By example the m3 (node-cli) does not support erasing the node while the A8 can do it. Therefore, I was thinking on two possible options for adding it to MQTT:

1) Adding a new option to the node agent (erase a8 <num>) for erasing that is only supported by the A8. 2) Modifying update so if update a8 <num> (without firmware) is given, assume that we are deleting instead of trying loading the idle firmware.

rfuentess commented 7 years ago

I have a dilemma. My next objective is to give support to the Serial agent for the A8-m3 nodes for having access to the serial interface.

This is almost done thanks to the efforts done for serial_agregator. It's only required to execute the /etc/init.d/serial_redirection in the m3-node for the serial agent having access to the terminal. Yet, I can devise different alternatives for doing this:

  1. Executing serial_redirection when the node agent receives a poweron A8 <id> command.
  2. Executing serial_redirection when the serial agent receives the linestart A8 <> command
  3. By means of the process agent, maybe a hardcoded command.

I personally find better the first approach, but I can understand why to implement the second one. And for now I'm using the third one on my experiments.

In any of the previous case, the execution of serial_redirection should be integrated into the ssh-cli-tools and then imported into here. Or, by means of its run-cmd argument

rfuentess commented 6 years ago

Finally, I got chance of working this PR again.

I still need to add the new class for supporting poweron and poweroff. Also, there is update-idle which in theory is used when update is not given a path. However, because the default firmware for M3 is not compatible for A8-M3, I'm not sure of giving support for it.

Note that, "ssh .iot-lab.info" might not work when ran on ".iot-lab.info" (need to have the public key in known_hosts), which causes this line to fail.

I'm copy/paste this comment here as this remains true until the tools developed in iotlabsshcli are integrated into the official REST API.

rfuentess commented 6 years ago

There is now a partial support for "turning" on and off the nodes.

To be honest, we are simulating the behavior by means of openocd. This is particularly evident with poweroff because the node restart before being halted.

rfuentess commented 6 years ago

I could benefit from @cladmi's insight for the radiosniffer and the A8 nodes.

For loading firmware, turning off/on or resetting M3 nodes we require access to m3-XX.YYY.iot-lab.info while for A8 we require access to node-a8-XX.YYY.iot-lab.info except for loading profiles to the nodes where is used the first syntax for both.

My main issues comes when the MQTT radiosniffer got the subscription for 'rawstart a8 XX ZZ . I can confirm that the profile is being loaded with success to the node. Yet, the MQTT client got the following error:

Connection failed: [Errno 115] Operation now in progress

And after this, the radiosniffer cannot operate anymore as will generate the same error for M3 and A8 nodes.

cladmi commented 6 years ago

For the sniffer you should use a8-XX.YYY.iot-lab.info for the profile and also to connect to the sniffer. Don't know if this is the problem or not.

Hostnames with m3 and a8 are for everything related to the web API and the gateway, the sniffer is forwarded by the gateway.

When you want to connect to the A8 open node you should use node-a8 as its another host with another IP. Like when you do ssh, or if you have forwarded the serial port.

I do not know what opena8-ssh-cli requires , 'a8', or 'node-a8', @aabadie would know.


A trick however, for M3 and all embedded nodes nodes, node-m3 is the same IP as m3. So for the serial port you could also use node-m3 if it makes it coherent and simplifies things.

rfuentess commented 6 years ago

For the sniffer you should use a8-XX.YYY.iot-lab.info for the profile and also to connect to the sniffer. Don't know if this is the problem or not. Hostnames with m3 and a8 are for everything related to the web API and the gateway, the sniffer is forwarded by the gateway.

At the end, it was a problem at the moment of creating the socket. The approach I used in the commit 6a2557f was throwing said error ([Errno 115] Operation now in progress) at the moment the socket.connect() was invoked. The commit ff9fdcf is avoiding the conflict.

A trick however, for M3 and all embedded nodes nodes, node-m3 is the same IP as m3. So for the serial port you could also use node-m3 if it makes it coherent and simplifies things.

Are we sure about this? I tried that at the beginning in my front-end and I got the following translations for the M3-6:a8-6.saclay.iot-lab.info (172.16.44.6), node-a8-6.saclay.iot-lab.info (10.0.44.6)

rfuentess commented 6 years ago

So far so good, there is support for serial, radiosniffer and node. Yet, the command equivalent for 'upload-idle' (no firmware is given by the client) is not well supported by opena8-ssh-cli, so I'm discarding it with the proper error message.

This of course brings me to the current topic: Travis with tox is not happy with my changes. I'm still not well versed with Tox, so please correct me if I'm wrong with the following assumptions:

  1. Travis is rejecting the testing because of the issue #9 .
  2. The presence of the syntax node-a8-xx and a8-xx is giving issues for testing infos_from_node()
  3. profile-idle for node-a8 is giving issues to Travis
cladmi commented 6 years ago

Are we sure about this? I tried that at the beginning in my front-end and I got the following translations for the M3-6:a8-6.saclay.iot-lab.info (172.16.44.6), node-a8-6.saclay.iot-lab.info (10.0.44.6)

Its only for M3/samr21, not for a8 nodes ;)

rfuentess commented 6 years ago

I'm having a conflict with the checking for A8 nodes, which Travis don't like at all.

def infos_from_node(node):
    """Infos from node hostname.

    >>> (infos_from_node('m3-1.grenoble.iot-lab.info') ==
    ...  ('m3', '1', 'grenoble'))
    True

    >>> (infos_from_node('node-a8-1.grenoble.iot-lab.info') ==
    ...  ('node-a8', '1', 'grenoble'))
    True
    """

Due that the sniffer requires a8-XX while the other commands requires node-a8-xx, and the user is using the former syntax (e.g. poweron a8 11) I'm having the problem that when infos_from_node is called, the agent don't knows which results are being retrieving.

I'm suggesting to switch the test check to the following:

    >>> (infos_from_node('m3-1.grenoble.iot-lab.info') ==
    ...  ('m3', '1', 'grenoble'))
    True

    >>> (infos_from_node('node-a8-1.grenoble.iot-lab.info') ==
    ...  ('a8', '1', 'grenoble'))
    True

    >>> (infos_from_node('a8-1.grenoble.iot-lab.info') ==
    ...  ('a8', '1', 'grenoble'))
    True

With this, the tests {py27,py35}-paho12-tests are happy, and in theory the tests using paholattest should be ok once fixed the problem commented in #12.