Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

DPWS Substitute


  • Please log in to reply
5 replies to this topic

#1 MaYHeM

MaYHeM

    New Member

  • Members
  • Pip
  • 8 posts

Posted 07 November 2012 - 01:54 PM

Ultimately, I wish to have two Netduino Plus that communicate to each other with Streams over Sockets and both also communicate with a Desktop application in the same manner. What I'm struggling with is discovery. I would like the Netdiunos and the Desktop app to be able to find each other on the network without manual configuration of IP addresses at runtime. Any suggestion on how I could achieve that?

#2 Nicky

Nicky

    Advanced Member

  • Members
  • PipPipPip
  • 78 posts
  • LocationDenmark

Posted 07 November 2012 - 02:22 PM

I haven't tried it yet, but I'm planning on doing the same scenario. I think at network broadcast is the easiest way to do discovery, without DPWS.

ntools
TCP Listener (Beta) · FTP Server (Alpha)
Netduino Plus Go Module · Xml Parser
http://ntools.codeplex.com/


#3 caEstrada

caEstrada

    Advanced Member

  • Members
  • PipPipPip
  • 84 posts

Posted 07 November 2012 - 07:38 PM

MaYHeM , I wrote a simple VB.Net routine that sends a ping to NetduinoPlus in order to identify if my station in ON the network...if you need a copy of that simple code in VB, let me know... With that routine, all you have to do is include a (FOR i= ) statemente to cycle from 1 to 254 in a specific domain...

#4 caEstrada

caEstrada

    Advanced Member

  • Members
  • PipPipPip
  • 84 posts

Posted 07 November 2012 - 07:40 PM

MaYHeM , If you want Netduion doing discovery, I have a simple UDP routine where you can send a message and if you receive an echo of the message sent, you can use it like ping. I do not know how to implement a ping from Netduino, so I wrote my own version.

#5 caEstrada

caEstrada

    Advanced Member

  • Members
  • PipPipPip
  • 84 posts

Posted 07 November 2012 - 07:46 PM

MayHem, Just an idea... byte[] MAC = { 0x5C, 0x86, 0x4A, 0x00, 0x4E, 0x5B }; Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableStaticIP("192.168.1.101", "255.255.255.0", "192.168.1.254"); Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].PhysicalAddress = MAC; //Microsoft.SPOT.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces()[0].EnableDhcp(); IPAddress remoteip = IPAddress.Parse(REMOTE_IP); //IPEndPoint remoteendpoint = new IPEndPoint(System.Net.IPAddress.Any, REMOTE_PORT); IPEndPoint remoteendpoint = new IPEndPoint(remoteip, REMOTE_PORT); //Configura un socket para recibir Datagramas via Internetwork usando el protocolo UDP Socket udp = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); //Vamos a procesar los broadcasts sin importar de cual estación vengan IPEndPoint broadcastEndPoint = new IPEndPoint(System.Net.IPAddress.Any, REMOTE_PORT); //Esta es la configuración para procesar comunicaciones UDP Broadcast, probado con el WireShark udp.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true); udp.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.Broadcast, true); udp.SendTimeout = 100; //Asocia el socket para procesar broadcasts UDP de cualquier estación en la red usando el puerto indicado udp.Bind(broadcastEndPoint); if (udp.Available > 0) { //Separa en RAM tanto Bytes como sean necesarios byte[] byteReceiveBuffer = new byte[udp.Available + 20]; //Vamos a escuchar cualquier estación por el puerto definido //EndPoint remoteEndPoint = new IPEndPoint(System.Net.IPAddress.Any, REMOTE_PORT); EndPoint remoteEndPoint = new IPEndPoint(remoteip, REMOTE_PORT); //Cuantos bytes llegaron y copialos int iNumberOfBytes = udp.ReceiveFrom(byteReceiveBuffer, ref remoteEndPoint); }

#6 MaYHeM

MaYHeM

    New Member

  • Members
  • Pip
  • 8 posts

Posted 08 November 2012 - 04:56 PM

Thanks for the ideas.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.