mcinnes01's Content - Netduino Forums - Page 4
   
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.

mcinnes01's Content

There have been 82 items by mcinnes01 (Search limited from 29-April 23)


By content type

See this member's


Sort by                Order  

#57688 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 22 April 2014 - 04:41 PM in Project Showcase

Hi Hanz,

 

I am trying to create an interface between mIP and M2Mqtt, as I understand I need to replace the MqttNetworkChannel with my own implementation that inherits IMqttNetworkChannel and reference my implementation in the MqttClient class. Also I need to replace the dnsLookup in the client class.

 

The IMqttNetworkChannel looks like this:

/// <summary>
    /// Interface for channel under MQTT library
    /// </summary>
    public interface IMqttNetworkChannel
    {
        /// <summary>
        /// Data available on channel
        /// </summary>
        bool DataAvailable { get; }

        /// <summary>
        /// Receive data from the network channel
        /// </summary>
        /// <param name="buffer">Data buffer for receiving data</param>
        /// <returns>Number of bytes received</returns>
        int Receive(byte[] buffer);

        /// <summary>
        /// Send data on the network channel to the broker
        /// </summary>
        /// <param name="buffer">Data buffer to send</param>
        /// <returns>Number of byte sent</returns>
        int Send(byte[] buffer);

        /// <summary>
        /// Close the network channel
        /// </summary>
        void Close();

        /// <summary>
        /// Connect to remote server
        /// </summary>
        void Connect();
    }

Would I be correct in saying that the connect and close methods would come from mIP's Networking class?

 

And Send and Receive from the HttpRequest and HttpResponse classes?

 

I remember reading in the mIP class that it tries to stay away from sockets to make things simpler, would I be right in saying that the mqtt library is using sockets?

 

If so would there be some particular methods I should use instead of the Http ones?

 

Also would you say that Start() in mIP is Connect in M2Mqtt? Stop() relates to Close() ?

 

I have no idea in terms of DataAvailable?

 

Any help would be much appreciated :)

 

Andy




#58370 I Think I Found a bug in SPI

Posted by mcinnes01 on 23 May 2014 - 09:15 PM in Netduino 2 (and Netduino 1)

Hi Chris,

 

Is this a hint towards a beta 4.3 for netduino 1?

 

Cheers,

 

Andy




#58371 Ethernet Module Update

Posted by mcinnes01 on 23 May 2014 - 09:34 PM in Netduino Go

Sigh, why don't you just get a cheap ass ENC28J60 module off ebay for < £3 and use the mIP library?

 

At least this is something that WILL get ethernet to the GO without doubt.

 

Module: http://www.ebay.co.u...=item20d966b102

 

mIP: http://mip.codeplex.com/

 

I'm currently trying to get mIP working with M2Mqtt so I can get GO working with Mqtt, it would be cool to have a few other people helping explore this route :)




#58416 Ethernet Module Update

Posted by mcinnes01 on 27 May 2014 - 08:54 AM in Netduino Go

Well that's up to you :) I know its frustrating waiting ages and comms could definitely been handled differently by secret labs, but this is the situation which I'm sure is fairly common when developing new transport protocols especially with netmf ever evolving and having to work around the bugs that are inherited with it.

The suggestion of mip + an enc28j60 is a good cheap alternative or at least stop gap. It is from what I understand the same chip on the ethernet board we are all waiting on. Plus it uses spi, so you only really lose 1 pin for chip select if you use other spi modules and the multi spi library, so not much of a sacrifice. I got it working sharing spi with a gpio expander so I actually gained pins as opposed to lost pins. Also in terms of plug and play, bar a resistor and not having a 10 pin connector or shield format, its not far off. At least this way you can move on with your code and project in the mean time, then when the ethernet module lands, fingers crossed this year, you can simply switch out the mip code for the native network code.

Hth

Andy



#58871 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 23 June 2014 - 10:09 PM in Project Showcase

Hi Hanz,

 

Just wondered if you could give me a few pointers...

 

I am trying to determine what the equivalent mIP method of the following would be:

public int Send(byte[] buffer)
        {
            return this.socket.Send(buffer, 0, buffer.Length, SocketFlags.None);
        } 

And

        public int Receive(byte[] buffer)
        {
            // read all data needed (until the buffer is full)
            int idx = 0;
            while (idx < buffer.Length)
            {
                idx += this.socket.Receive(buffer, idx, buffer.Length - idx, SocketFlags.None);
            }
            return buffer.Length;
        } 

 this.socket.Send is derived from the System.Net.Sockets method:

public int Send(byte[] buffer, int offset, int size, SocketFlags socketFlags);

and this.socket.Receive is from:

public int Receive(byte[] buffer, int offset, int size, SocketFlags socketFlags);

From what I can tell nothing seems to expose a send or receive method that returns a int, my only conclusion would be that this response is returned until the buffer is empty. I guess this would need some adaptation or extension of the mIP methods?

 

 

And finally the only other method I can't work out the mIP equivalent of is as follows, however it may require some extension if its possible:

public bool DataAvailable
{
   get
   {
      return (this.socket.Available > 0);
   }
}

Again drawing from System.Net.Sockets:

public int Available { get; }
 Your guidance would be greatly appreciated :)
 
Many thanks
 
Andy



#58881 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 24 June 2014 - 08:59 PM in Project Showcase

Hi Hanz,

 

Just a quick update, I have confirmation from Paolo who wrote the M2Mqtt library that the network library in his project uses sockets over tcp. There is a TCP class in the mIP library but I wondered if you or anyone else has any ideas or examples of how to implement TCP sockets with mIP. There are great examples of http and UDP but any pointer as to TCP would be greatly appreciated.

 

I guess in regards to my previous post the questions still remain in terms of extending mIP to provide similar structure to System.Net.Sockets in terms of returning int for send, receive and data available?

 

Thanks as ever,

 

Andy




#59477 MIP tcp/ip stack running on Netduino mini !!

Posted by mcinnes01 on 30 July 2014 - 10:08 PM in Project Showcase

Hi Valkyrie

 

Sorry its took so long for me to get back and thanks for the TCP example!

 

The problem I am having is that the M2Mqtt library uses System.Net.Sockets and as I have a very limited understanding of how TCP works I am struggling to identify the parts of mIP I need to use to replace the TCP class (MqttNetworkChannel) in the M2Mqtt project and how to go about implementing them.

 

In your example you clearly show a way of creating a socket, but I don't understand how you achieved this or how it can be extended to cover the scenarios required in the Mqtt TCP class.

 

For example System.Net.Sockets provides:

 

.Send()

.Recieve()

.Available()

.Connect()

.Close()

 

Which are used in the MqttNetworkChannel or TCP class.

 

It also seems that the Send, Receive and Available methods return an int value of the number of bytes sent, left in the buffer or available to be received.

 

What I would like to know is, is there any way I can achieve this with mIP?

 

I would very much like to implement your mIP library with mqtt and appreciate any help you can provide :)

 

Thanks again for your help and I hope with your assistance I can give people using any type of netduino or other boards the ability to use pub sub messaging.

 

Andy





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.