Exemple #1
0
 /// <summary>
 /// Load settings from file and store it's data in the CoreState instance
 /// </summary>
 public static void LoadSettings()
 {
     if (!CheckSettingsData())
     {
         CoreState.SettingsInstance = new Settings();
     }
     else
     {
         JsonSerializer serializer = new JsonSerializer();
         using (StreamReader sr = new StreamReader(string.Format("{0}/{1}/{2}", AppContext.BaseDirectory, SettingsPath, SettingsFileName)))
             using (JsonReader reader = new JsonTextReader(sr))
             {
                 Settings settings = serializer.Deserialize <Settings>(reader);
                 CoreState.SettingsInstance = settings;
                 if (SerialIO.GetPortNames().Contains(settings.COMPort) && !settings.useWifi)
                 {
                     SerialManager.ManagerInstance.Start();
                 }
                 if (settings.useWifi)
                 {
                     WifiManager.ManagerInstance.Start();
                 }
             }
     }
 }
Exemple #2
0
        public override void OnGet(HttpListenerRequest request, HttpListenerResponse response)
        {
            JObject obj = new JObject()
            {
                { "result", true },
                { "ports", new JArray(SerialIO.GetPortNames().ToArray()) },
                { "wifi", CoreState.SettingsInstance.useWifi }
            };

            ResponseFactory.GenerateResponse(response, obj.ToString());
        }