Ethernet on Hydra with ENC28

Whith the latest version of the official SDK from GHI is still required a custom firmware with the Ethernet support for this board?

If yes, where i can download the famous “Ethernet firmware” and what are the best practices to enable Ethernet communication for this board?

Thanks

@ AlbeNET - Older firmware (4.2) is located in the installation path:

C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.2 SDK\Firmwares\FEZ Hydra\Ethernet

In 4.3 it has been unified into one.

@ andre.m - I am not sure now. I am pretty sure I’ve seen the post where it was stated.
On the other hand Benny the plant is storing his vitals data in Azure through Hydra.

You are right. I misread an older post.

Updated my earlier reply.

k so there is JUST ONE FIRMWARE. Right? and if i use the one from the 2015 R1 SKD it includes the Ethernet stuff…

But i tried to use this code:



Microsoft.SPOT.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged += networkChange

netif = new EthernetENC28J60(SPI.SPI_module.SPI1, Cpu.Pin.GPIO_Pin1, Cpu.Pin.GPIO_Pin2, Cpu.Pin.GPIO_Pin3);
netif.Open();
netif.EnableStaticIP("192.168.1.180","255.255.255.0", "192.168.1.254");
netif.EnableStaticDns(new string[]{"192.168.1.254","8.8.8.8"} );




But the event handler network change never fired and i cannot even ping the board.

Is that correct what i’m doing?

@ andre.m - It’s connected on socket 3.

That configuration is valid for Cerberus?

Definitely wrong pins. Use static class from GHI.Pins assembly: FEZHydra.Socket3.Pin3, etc. Or the gpio number directly. Here is one for Hydra Socket3


		public static class Socket3
		{
			/// <summary>Pin definition.</summary>
			public const Cpu.Pin Pin3 = (Cpu.Pin)40;

			/// <summary>Pin definition.</summary>
			public const Cpu.Pin Pin4 = (Cpu.Pin)41;

			/// <summary>Pin definition.</summary>
			public const Cpu.Pin Pin5 = (Cpu.Pin)44;

			/// <summary>Pin definition.</summary>
			public const Cpu.Pin Pin6 = (Cpu.Pin)45;

			/// <summary>Pin definition.</summary>
			public const Cpu.Pin Pin7 = (Cpu.Pin)26;

			/// <summary>Pin definition.</summary>
			public const Cpu.Pin Pin8 = (Cpu.Pin)25;

			/// <summary>Pin definition.</summary>
			public const Cpu.Pin Pin9 = (Cpu.Pin)27;

			/// <summary>SPI definition.</summary>
			public const SPI.SPI_module SpiModule = SPI.SPI_module.SPI1;
		}

And now? who i can trust? :wink:

eheh i will try this hints anyway! Thanks guys! Really appreciated.

When i’ll be able to make it works i’ll probably create a code share.

I’m trying to use the Maker Channell of IFTTT (https://ifttt.com/maker) to rise some Events from my board.

@ andre.m - it seems just partially… not the cpu pin number.

Anyway andre.m thank you for your extraordinary diligence in countering what I write.

You complained that I brought more 'similar questions in the post several times but your behavior is not much better.

I like to be frank, if I make a silly question is perhaps because there is no clear answer.

If this strikes you I’m so sorry.You can not read my every post and not give me more 'help.

I, however, will try to consolidate all this information that you gave me in a post accessible even to people like me who has tried to look at various posts without finding a definitive solution to operate the Hydra Ethernet with the last firmware 4.3

@ andre.m - Excellent! i’ll try to use the static definition in FEZHydra.Socket3

Then i assume that for Cerberos i can use the same approach with its own static definition. Now just wondering if there is any specific spi port to be used or any is fine

@ andre.m - I mean the socket. sorry misconfusion.

I mean the Cerberus has 2 socket S as well. I didn’t yet dig if they are connected to the same SPI port as well or not… i’ll double check that!

ok now i’m going to try this:

   var ethernet = new GHI.Networking.EthernetENC28J60(
                GHI.Pins.FEZHydra.Socket3.SpiModule,
                GHI.Pins.FEZHydra.Socket3.Pin6,
                GHI.Pins.FEZHydra.Socket3.Pin3,
                GHI.Pins.FEZHydra.Socket3.Pin4
            );

EXCELLENT!!

it worked

Now i got an exception on this code:

        /// <summary>
        /// Trigger IFTTT event
        /// </summary>
        /// <param name="eventName"></param>
        /// <param name="value1"></param>
        /// <param name="value2"></param>
        /// <param name="value3"></param>
        /// <returns></returns>
        public static string TriggerIFTTTEvent(string eventName, string secret, string value1 = null, string value2 = null, string value3 = null)
        {
            //create the right URL basing on the Trigger Name
            string requestUrl =  "https://maker.ifttt.com/trigger/" + eventName + "/with/key/"+ secret;

            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUrl);

            string postData = string.Empty;

            if (value1 != null || value2 != null || value3 != null)
            {
                postData += "{";

                if (value1 != null)
                {
                    postData += @ """value1"":""" + value1 + "\"";
                }

                if (value2 != null)
                {
                    if (value1 != null)
                    {
                        postData += ",";
                    }
                    postData += @ """value2"":""" + value2 + "\"";
                }

                if (value3 != null)
                {
                    if (value1 != null || value2 != null)
                    {
                        postData += ",";
                    }
                    postData += @ """value3"":""" + value3 + "\"";
                }

                postData += "}";
            }

            byte[] data = Encoding.UTF8.GetBytes(postData);

            //Set parameters of web request for HTTP POST
            request.Method = "POST";
            request.ContentType = "application/json";
            request.ContentLength = data.Length;
            request.KeepAlive = false;

            if (data.Length > 0)
            {
                Stream postDataStream = request.GetRequestStream();
                postDataStream.Write(data, 0, data.Length);
                postDataStream.Close();
            }

            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            
            return response.StatusDescription;
        }

when i try to execute this line:





 [quote]#### Exception System.Net.WebException - 0x00000000 (5) ####
    #### Message: 
    #### System.Net.HttpWebRequest::GetResponse [IP: 00d3] ####[/quote]

WebException should have Status and Response fields. What do you have there?

With this code i solved…

 public static void TriggerIFTTTEvent(string eventName, string secret, string value1 = null, string value2 = null, string value3 = null)
        {
            //create the right URL basing on the Trigger Name
            string requestUrl = "https://maker.ifttt.com/trigger/" + eventName + "/with/key/" + secret;
                        
            string postData = string.Empty;

            if (value1 != null || value2 != null || value3 != null)
            {
                postData += "{";

                if (value1 != null)
                {
                    postData += @ """value1"":""" + value1 + "\"";
                }

                if (value2 != null)
                {
                    if (value1 != null)
                    {
                        postData += ",";
                    }
                    postData += @ """value2"":""" + value2 + "\"";
                }

                if (value3 != null)
                {
                    if (value1 != null || value2 != null)
                    {
                        postData += ",";
                    }
                    postData += @ """value3"":""" + value3 + "\"";
                }

                postData += "}";
            }
                        
            Gadgeteer.Networking.HttpRequest request = null;
            Gadgeteer.Networking.POSTContent content = null;

            if (postData != null)
            {
                // Create POST content
                content = Gadgeteer.Networking.POSTContent.CreateTextBasedContent(postData);

                // Create the request
                request = Gadgeteer.Networking.HttpHelper.CreateHttpPostRequest(
                    requestUrl // the URL to post to
                    , content // the form values
                    , "application/json" // the mime type for an HTTP form
                );
            }
            else
            {
                request = Gadgeteer.Networking.HttpHelper.CreateHttpGetRequest(requestUrl);
            }
           
            request.ResponseReceived += request_ResponseReceived;

            //// Post the form
            request.SendRequest();
        }

        static void request_ResponseReceived(Gadgeteer.Networking.HttpRequest sender, Gadgeteer.Networking.HttpResponse response)
        {
            Debug.Print(response.StatusCode);
        }

@ andre.m - i didn’t get the full exception just that!