Connect to gateway using VB.NET

  • I am trying to develope my own controller SW using VB.NET 2012.

    Reading data from Gateway works perfect, using Sockets.NetworkStream and public function .GetStream(), but i do not suceed sending anything.

    When i try to send to gateway, i use function .Client.Send(<bytes>) where bytes are by command text string "20;1;1;1;2;0;\n" decoded to byte with the expression System.Text.Encoding.ASCII.GetBytes( "20;1;1;1;2;0;\n")

    When i connect to gateway using putty and a raw connection everything works fine.

    Does anyone have knowledge about and howto send command to gateway?

  • You dont need send newline

  • Use streamreader and streamwrite to read and send data over the networkstream

  • Contest Winner


    I'm not 100% sure especially for Ethernet but shouldn't the string to send be:
    "20;1;1;1;2;0\n" (no trailing semicolon at the last argument).

    You can also check if the output of ASCII.GetBytes is ok. \n should get a 10 (dec). But this should work I think.

  • im make a controller im try to help you with some code


    Public Swriter As StreamWriter
    Public Client As New TcpClient
    Public ClientStream As NetworkStream

    to send data use

    ClientStream = Client.GetStream()
    Swriter = New StreamWriter(ClientStream)
    Swriter.WriteLine(deviceid & ";" & sensorchildid & ";" & msgType & ";" & ack & ";" & subType & ";" & payload)

    if you need more help tell me im try to help ^^

  • Hi,

    Thank you very mouch for your quick support!!
    Now it works perfect as expected 🙂

Log in to reply





Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.