public static void Main() { var cont = GpioController.GetDefault(); var reset = cont.OpenPin(FEZ.GpioPin.WiFiReset); var irq = cont.OpenPin(FEZ.GpioPin.WiFiInterrupt); var mode = cont.OpenPin(FEZCLR.GpioPin.PA0); var scont = SpiController.FromName(FEZ.SpiBus.WiFi); var spi = scont.GetDevice(SPWF04SxInterface.GetConnectionSettings(SpiChipSelectType.Gpio, FEZ.GpioPin.WiFiChipSelect)); mode.SetDriveMode(GpioPinDriveMode.InputPullDown); led1 = cont.OpenPin(FEZ.GpioPin.Led1); led1.SetDriveMode(GpioPinDriveMode.Output); btn1 = cont.OpenPin(FEZ.GpioPin.Btn1); btn1.SetDriveMode(GpioPinDriveMode.InputPullUp); wifi = new SPWF04SxInterface(spi, irq, reset); wifi.IndicationReceived += (s, e) => Debug.WriteLine($"WIND: {Program.WindToName(e.Indication)} {e.Message}"); wifi.ErrorReceived += (s, e) => Debug.WriteLine($"ERROR: {e.Error} {e.Message}"); wifi.TurnOn(); NetworkInterface.ActiveNetworkInterface = wifi; WaitForButton(); wifi.JoinNetwork("SSID", "password"); WaitForButton(); wifi.ClearTlsServerRootCertificate(); wifi.SetTlsServerRootCertificate(Resources.GetBytes(Resources.BinaryResources.DigiCertGlobalRootCA)); while (true) { WaitForButton(); //.NET TestSocket("www.ghielectronics.com", "/", 443, "ghielectronics.com"); //WiFi //TestHttp("www.ghielectronics.com", "/", 443, SPWF04SxConnectionSecurityType.Tls, true); //TestSocket("www.ghielectronics.com", "/", 443, SPWF04SxConnectionType.Tcp, SPWF04SxConnectionSecurityType.Tls, "ghielectronics.com"); } }
private static void Run() { WaitForButton(); //You only need to do this once, it'll get saved to the Wi-Fi internal config to be reused on reboot. wifi.JoinNetwork("SSID", "password"); WaitForButton(); wifi.ClearTlsServerRootCertificate(); //You'll need to download and use the correct root certificates for the site you want to connect to. WaitForButton(); //wifi.SetTlsServerRootCertificate(Resources.GetBytes(Resources.BinaryResources.Digicert___GHI)); //wifi.SetTlsServerRootCertificate(Resources.GetBytes(Resources.BinaryResources.DigiCert_High_Assurance___StackOverflow)); while (true) { WaitForButton(); //.NET //TestHttp("http://files.ghielectronics.com", "/"); //TestHttp("https://meta.stackexchange.com", "/", "*.stackexchange.com"); //TestSocket("www.ghielectronics.com", "/robots.txt", 80); //TestSocket("meta.stackoverflow.com", "/", 443, "*.stackexchange.com"); //WiFi //TestHttp("files.ghielectronics.com", "/", 80, SPWF04SxConnectionSecurityType.None, true); //TestHttp("www.google.com", "/?gws_rd=ssl", 80, SPWF04SxConnectionSecurityType.None, true); //TestHttp("meta.stackexchange.com", "/", 443, SPWF04SxConnectionSecurityType.Tls, true); //TestSocket("www.ghielectronics.com", "/robots.txt", 80, SPWF04SxConnectionyType.Tcp, SPWF04SxConnectionSecurityType.None); //TestSocket("www.ghielectronics.com", "/robots.txt", 443, SPWF04SxConnectionyType.Tcp, SPWF04SxConnectionSecurityType.Tls, "*.ghielectronics.com"); //TestSocket("www.google.com", "/?gws_rd=ssl", 80, SPWF04SxConnectionyType.Tcp, SPWF04SxConnectionSecurityType.None); //TestSocket("meta.stackoverflow.com", "/", 443, SPWF04SxConnectionyType.Tcp, SPWF04SxConnectionSecurityType.Tls, "*.stackexchange.com"); Debug.WriteLine(GC.GetTotalMemory(true).ToString("N0")); } }