Periodically scan Thread Nodes IP in my Border Router using Linux + KW as HCD with serial TAP

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Periodically scan Thread Nodes IP in my Border Router using Linux + KW as HCD with serial TAP

Jump to solution
1,963 Views
diegocomin
Contributor IV

Hi all,

I followed this tutorial Thread Border Router using Linux + KW as Host Controlled Device with Serial TAP for DHCPv6-PD  to create a complete Border Router with my Raspberry PI + Host Controlled Device with Serial TAP. 

From my Raspberry PI when I open the Thread Shell (sudo ./bin/Thread_Shell /dev/ttyACM0 threadtap0 25) I am able to ping the Thread nodes. At this point I made a python script to communicate with them using CoAP protocol with the python library CoAPthon, the problem is that I want to make an automatic python script so I need to periodically scan the nodes (command "getnodesip" from the Thread_Shell) to get the nodes ip and know how many nodes are currently available. 

How can I get the global Ips of the nodes without closing the Thread_Shell? I know that manually I can put in the Thread Shell "getnodesip" and the nodes ip appears but my goal is to make it automatic from my python script. 

I watched in the hsdk-python folder (hsdk-python/src/com/nxp/wireless_connectivity/test) a script that get the address of the nodes (getaddr.py). The problem is that if I have the Thread_Shell open the getaddr.py script does not work, this is what appears:

pastedImage_2.png

However, when I close the Thread_Shell I am able to obtain the addresses of the nodes:

pastedImage_4.png

The thing is, is there any way to obtain periodically the Ip nodes of my network from a python script without closing the Thread_Shell that maintains the Ip connection to execute CoAP actions?

Regards,

Diego Comín

Labels (4)
0 Kudos
1 Solution
1,674 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello, 

That was the only way I could think of achieving it, you can try doing what you are suggesting, but we do not have anything available and that implementation will be up to you to try, but I can't guarantee that will work due to the necessary elements and process for the network to work. 

Regards, 

Estephania 

View solution in original post

7 Replies
1,673 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello, 

The reason why you might be experiencing your problem it's most likely to be because both need the port to work, so you can't open both at the same time, nonetheless, you could try adding the functionality of the script to the shell one so you can use the shell instead of the python script. 

Regards, 
Estephania

0 Kudos
1,674 Views
diegocomin
Contributor IV

Hello Estephania,

The thing is that from my customized python script (the goal of my python script is to make a MQTT-CoAP proxy) I need to obtain I do not know how the thread nodes ips periodically. Because to maitain a CoAP connection between the Raspberry PI and the Thread nodes I need to maintain the Thread Shell, how can I obtain the nodes IPs of the thread network with my python script. I can not add the funcionallity of my python script into the script of the shell because it is a separated thing that need to be autonomous and not depend to the command typed manually in a Shell.

Regards,

Diego Comin

0 Kudos
1,674 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello, 

Sorry but I'm not sure that I understand your problem, why are you not adding that command in your script?  there should not be a lot of issues while adding it , you will only need to check which it's the correct command to send by checking the THCI guide in the SDK. 

Regard,s 

Estephania

0 Kudos
1,674 Views
diegocomin
Contributor IV

Hello Estephania,

My problem is that if to run properly my python script (CoAP-MQTT proxy functionality) I need to have in another terminal the Thread_Shell program to have the IP TAP connection between my Raspberry Pi and the Host Controlled Device. 

If I add the getnodesip THCI command in my python script and the Thread_Shell is opened, the /dev/ttyACM0 port is being used and I do not get the IPs of the nodes, I receive nothing as I posted. So the solution is to close the Thread_Shell terminal (closing the IP connection between RP and HCD) before execute the THCI command and re-opening after calling the THCI command and I do not want to close this IP connection. I need to scan the nodes while maitaining the IP connection that is performed by the Thread_Shell program. I do not know is now is clear my issue.

Regards,

Diego Comin

0 Kudos
1,674 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello, 

By any chance, have you tried using the Thread_KW_Tun instead of the shell? You can try doing that and disable the DEBUG so the port won't be open but when the initialization frames are sent. 

Could you please try that ? 

Regards, 

Estephania

0 Kudos
1,674 Views
diegocomin
Contributor IV

Hello Estephania,

I tried your solution but it still does not work. It seems that the tunnel aplication (Thread_KW_Tun) uses the /dev/ttyACM0 and I can not send THCI commands in python. Is there any way to make a simple tunnel application in python (like Thread_Shell o Thread_KW_Tun) compatible with the use THCI commands in python to create a network, scan nodes, join a network, etc?

Regards,

Diego Comín

0 Kudos
1,675 Views
estephania_mart
NXP TechSupport
NXP TechSupport

Hello, 

That was the only way I could think of achieving it, you can try doing what you are suggesting, but we do not have anything available and that implementation will be up to you to try, but I can't guarantee that will work due to the necessary elements and process for the network to work. 

Regards, 

Estephania