Ejemplo n.º 1
0
        /// <summary>
        /// setup della connessione
        /// </summary>
        public void initConnection()
        {
            eth.UseThisNetworkInterface();
            eth.NetworkSettings.EnableDhcp();

            ///homegateway CICCIO
            eth.NetworkSettings.EnableStaticIP("192.168.0.222", "255.255.255.0", "192.168.0.1");
            ///homegateway FABRI
            //eth.NetworkSettings.EnableStaticIP("192.168.1.222", "255.255.255.0", "192.168.1.254");

            //ListNetworkInterfaces();

            eth.NetworkUp   += ethernet_NetworkUp;
            eth.NetworkDown += ethernet_NetwokDown;
        }
Ejemplo n.º 2
0
        public static void Init(EthernetJ11D _ethernetJ11D)
        {
            // Load ip from settings
            String gadgeteerIp = SettingsManager.Get(SettingsManager.LockIp);

            ethernetJ11D = _ethernetJ11D;
            ethernetJ11D.UseThisNetworkInterface();
            ethernetJ11D.UseStaticIP(gadgeteerIp, "255.255.255.0", "192.168.100.1");
            ethernetJ11D.NetworkUp   += NetworkUp;
            ethernetJ11D.NetworkDown += NetworkDown;

            // Data is not yet loaded, data source is unknown
            ChangeDataSource(DataSourceUnknown);

            // Load users from cache
            if (CacheManager.Load(userList, CacheManager.UsersCacheFile))
            {
                DebugOnly.Print(userList.Count + " users loaded from cache!");

                // Data source is now cache
                ChangeDataSource(DataSourceCache);
            }
            else
            {
                // Empty data cache is assumed as an error!
                if (DataSourceChanged != null)
                {
                    DataSourceChanged(DataSourceError);
                }

                // Clear user list
                userList.Clear();
            }

            // Load logs from cache if any
            if (CacheManager.Load(logList, CacheManager.LogsCacheFile))
            {
                DebugOnly.Print(logList.Count + " logs loaded from cache!");
            }
            else
            {
                // Clear log list
                logList.Clear();
            }

            initialized = true;
        }
Ejemplo n.º 3
0
 public Ethernet(EthernetJ11D ethernetJ11D)
 {
     this.ethernetJ11D = ethernetJ11D;
     try
     {
         //ethernetJ11D.NetworkSettings.PhysicalAddress=new byte[]{0x00,0x21,0x03,0x80,0x8B,0x6B};
         if (!ethernetJ11D.NetworkInterface.Opened)
         {
             ethernetJ11D.NetworkInterface.Open();
         }
         PrintNetworkState();
         ethernetJ11D.UseThisNetworkInterface();
         ethernetJ11D.NetworkSettings.EnableDhcp();
         ethernetJ11D.NetworkSettings.EnableDynamicDns();
         //ethernetJ11D.UseDHCP();
         //ethernetJ11D.UseStaticIP("192.168.3.99", "255.255.255.0", "192.168.3.235");
         while (ethernetJ11D.NetworkInterface.IPAddress.Equals("0.0.0.0"))
         {
             Debug.Print("Waiting for Network!");
             Thread.Sleep(1000);
         }
         Debug.Print("Connected IP:" + ethernetJ11D.NetworkInterface.IPAddress);
         PrintNetworkState();
         lock (this)
         {
             mqtt = new Mqtt();
             waitHandle.Set();
         }
         Microsoft.SPOT.Net.NetworkInformation.NetworkChange.NetworkAvailabilityChanged += (s, e) => ethernetJ11D_CableChange(s, e);
         ethernetJ11D.NetworkDown += ethernetJ11D_NetworkDown;
         ethernetJ11D.NetworkUp   += ethernetJ11D_NetworkUp;
     }
     catch (Exception e) {
         Debug.Print(e.StackTrace);
     }
 }