Esempio n. 1
0
        public List<HomeOS.Hub.Common.Device> GetDevices()
        {
            List<Device> retList = new List<Device>();
            //Getting all list of COMPORTs available on the system.
            List<COMPortFinder> comportList = COMPortFinder.GetCOMPortsInfo();
            foreach (COMPortFinder comPortInfo in comportList)
            {
                //Checking if COMPORT is our desired COMPORT or not.
                if (comPortInfo.Description.Contains(MBED))
                {
                    string deviceUniqueName = String.Format("{0} - {1}", MBED, comPortInfo.Name);
                    string deviceFriendlyName = comPortInfo.Description;
                    /*
                     * The device object which is filled with necessary information like
                     * which driver should be invoked when this particular device is added to the platform.
                     */
                    Device device = new Device(deviceFriendlyName, deviceUniqueName, "", DateTime.Now, "HomeOS.Hub.Drivers.MbedDriver", false);

                    /*
                    * intialize the parameters for this device, 
                    * these paramenters will be passed to the driver when driver is invoked.
                    */
                    device.Details.DriverParams = new List<string>() { deviceUniqueName };

                    retList.Add(device);
                }
            }
            // list of devices will be returned to HomeOS platform/dashboard.
            return retList;
        }
Esempio n. 2
0
        private static Device GetDevice(Camera camera)
        {
            string cameraName = camera.ToString();

            var device = new Device("Webcam - " + cameraName, cameraName, cameraName, DateTime.Now, "DriverWebCam", false);
            return device;
        }
Esempio n. 3
0
        public List<Device> GetDevices()
        {
            Device device = new Device("dummydevice", "dummydevice", "", DateTime.Now, "HomeOS.Hub.Drivers.Dummy", false);

            //intialize the parameters for this device
            device.Details.DriverParams = new List<string>() { device.UniqueName };

            return new List<Device>() { device };
        }
 /// <summary>
 /// Returns a list of Device consisting of all Bluetooth Devices in range.
 /// </summary>
 /// <returns>
 /// So far the parameters passed to the Bluetooth Driver are:
 /// 1. Device Unique Name
 /// 2. Device Address (MAC)
 /// 3. Device Class (Bluetooth Class Type)
 /// 4. Device Type (Engduino / AndroidPhone only at the moment)
 /// </returns>
 public List<Device> GetDevices() {
     List<Device> ret = new List<Device>();
     List<BluetoothDevice> devices = Bluetooth.getAllDevices();
     foreach (BluetoothDevice blueoothDevice in devices) {
         List<String> driverParams = new List<String>();
         String uniqueName = "Bluetooth | " + blueoothDevice.DeviceType + " | " + blueoothDevice.DeviceName + " | " + blueoothDevice.DeviceAddress;
         Device device = new Device(uniqueName, uniqueName, "", DateTime.Now, "HomeOS.Hub.Drivers.BluetoothDriver", false);
         driverParams.Add(device.UniqueName);
         driverParams.Add(blueoothDevice.DeviceAddress);
         driverParams.Add(blueoothDevice.DeviceClass);
         driverParams.Add(blueoothDevice.DeviceType);
         //intialize the parameters for this device
         device.Details.DriverParams = driverParams;
         ret.Add(device);
     }
     return ret;
 }
Esempio n. 5
0
        public List<Device> GetDevices()
        {
            List<Device> retList = new List<Device>();

            foreach (Camera camera in CameraService.AvailableCameras)
            {
                string deviceName = camera.ToString();

                Device device = new Device(deviceName, deviceName, "", DateTime.Now, "HomeOS.Hub.Drivers.WebCam", false);

                //intialize the parameters for this device
                device.Details.DriverParams = new List<string>() { device.UniqueName};

                retList.Add(device);
            }

            return retList;
        }
Esempio n. 6
0
        public void Init(string baseUrl, string baseDir, ScoutViewOfPlatform platform, VLogger logger)
        {
            this.baseUrl = baseUrl;
            this.platform = platform;
            this.logger = logger;

            scoutService = new OwmScoutService(baseUrl + "/webapp", this, platform, logger);

            appServer = new WebFileServer(baseDir, baseUrl, logger);

            //initialize the device we'll use
            device = new Device("OpenWeatherMap", UniqueDeviceId(), "", DateTime.Now, "HomeOS.Hub.Drivers.OpenWeatherMap");

            // the parameters are: uniqueName, appid, lattitude, longitude
            device.Details.DriverParams = new List<string>() { device.UniqueName, DefaultAppId, "", "" };

            logger.Log("DummyScout initialized");
        }
Esempio n. 7
0
        public List<Device> GetDevices()
        {
            List<Device> retList = new List<Device>();

            foreach (var potentialSensor in KinectSensor.KinectSensors)
            {
                if (potentialSensor.Status == KinectStatus.Connected)
                {
                    string deviceName = potentialSensor.ToString();
                    Device device = new Device(deviceName, deviceName, "", DateTime.Now, "HomeOS.Hub.Drivers.Kinect", false);
                    //intialize the parameters for this device
                    device.Details.DriverParams = new List<string>() { device.UniqueName };

                    retList.Add(device);
                }
            }
            return retList;
        }
Esempio n. 8
0
        public void InsertDevice(Device device)
        {
            lock (currentDeviceList)
            {
                for (int index = 0; index < currentDeviceList.Count; index++)
                {
                    if (currentDeviceList[index].UniqueName.Equals(device.UniqueName))
                    {
                        //overwrite the old information with the new discovery
                        currentDeviceList[index] = device;

                        return;
                    }
                }

                //coming here implies that the device was not found in the current list; add it
                currentDeviceList.Add(device);
            }
        }
Esempio n. 9
0
        public Tuple<bool, string> StartDriverForDevice(Device device, List<string> driverParams)
        {
            if (device.DriverBinaryName.Equals(""))
            {
                return new Tuple<bool, string>(false, "Driver not specified");
            }

            string driverFriendlyName = device.DriverBinaryName + " for " + device.FriendlyName;
            string driverAppName = "driver for " + device.FriendlyName;

            ModuleInfo moduleInfo = new ModuleInfo(driverFriendlyName, driverAppName, device.DriverBinaryName, null, true, driverParams.ToArray());

            // this will be set in StartModule -- why set here
            //moduleInfo.SetWorkingDir(Environment.CurrentDirectory + "\\" + moduleInfo.FriendlyName());

            moduleInfo.SetManifest(new Manifest());
            moduleInfo.Background = true;

            StartModule(moduleInfo);

            //add the module to the configuration and update details for the device
            //these changes are written to disk
            config.AddModule(moduleInfo);
            config.UpdateDeviceDetails(device.UniqueName, true, driverFriendlyName);

            return new Tuple<bool, string>(true, "Added driver module");
        }
Esempio n. 10
0
        private static Device CreateDevice(UPnPDevice upnpDevice)
        {
 
            string ipAddress = ExtractIpAddress(upnpDevice.PresentationURL);

            var device = new Device(upnpDevice.FriendlyName, GetUniqueName(upnpDevice.FriendlyName), ipAddress, DateTime.Now, "HomeOS.Hub.Drivers.AxisCamera");

            //intialize the parameters for this device
            device.Details.DriverParams = new List<string>() { device.UniqueName, "root", "" };

            return device;
        }
Esempio n. 11
0
        private void ReadDeviceList()
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlReader xmlReader = XmlReader.Create(DevicesFile, xmlReaderSettings);
            DateTime lastSeenDateTime;

            xmlDoc.Load(xmlReader);
            XmlElement root = xmlDoc.FirstChild as XmlElement;

            if (!root.Name.Equals("Devices"))
                throw new Exception(DevicesFile + " doesn;t start with Devices");

            foreach (XmlElement xmlDevice in root.ChildNodes)
            {
                if (!xmlDevice.Name.Equals("Device"))
                    throw new Exception("child is not a Device in " + DevicesFile);

                string friendlyName = xmlDevice.GetAttribute("FriendlyName");
                string uniqueName = xmlDevice.GetAttribute("UniqueName");
                string ipAddress = xmlDevice.GetAttribute("IPAddress");
                string lastSeenStr = xmlDevice.GetAttribute("LastSeen");
                string driverBinaryName = xmlDevice.GetAttribute("DriverBinaryName");

                //read the devicedetails now
                string configuredStr = xmlDevice.GetAttribute("Configured");
                string driverModuleFriendlyName = xmlDevice.GetAttribute("DriverModuleFriendlyName");

                //read the deviceDriverParams
                List<string> deviceDriverParams = new List<string>();

                XmlElement xmlDriverParams = (XmlElement) xmlDevice.ChildNodes.Item(0);

                if (!xmlDriverParams.Name.Equals("DriverParams"))
                    throw new Exception("child of Device is not DriverParams. it is " + xmlDriverParams.Name);

                int count = int.Parse(xmlDriverParams.GetAttribute("Count"));

                for (int index=0; index < count; index++) 
                {
                    deviceDriverParams.Add(xmlDriverParams.GetAttribute("Param"+index));
                }

                //sanity check and construct the device object

                if (!DateTime.TryParse(lastSeenStr, out lastSeenDateTime))
                {
                    // TODO: what should be the last seen time if there isn't one saved in the Devices configuration
                }

                Device device = new Device(friendlyName, uniqueName, ipAddress, lastSeenDateTime, driverBinaryName);

                bool configured = false;
                if (bool.TryParse(configuredStr, out configured))
                {
                    device.Details.Configured = configured;
                }

                device.Details.DriverFriendlyName = driverModuleFriendlyName;
                device.Details.DriverParams = deviceDriverParams;

                allDevices.Add(uniqueName, device);
            }

            xmlReader.Close();
        }
Esempio n. 12
0
        public void SetDeviceDriverParams(Device targetDevice, List<string> paramList)
        {
            lock (allDevices)
            {
                foreach (Device device in allDevices.Values)
                {
                    if (device.UniqueName.Equals(targetDevice.UniqueName))
                    {
                        //make sure that you update device, not the targetDevice
                        device.Details.DriverParams = paramList;

                        WriteDeviceList();

                        return;
                    }
                }

                //no matching device was found :(

                throw new Exception(String.Format("Matching device not found in config.allDevice. DeviceToUpdate = {0}", targetDevice.UniqueName)); 
            }
        }
        public async Task<List<Device>> GetDevicesAsync()
        {
            var batteryServiceDeviceInfoCollection = await DeviceInformation.FindAllAsync(GattDeviceService.GetDeviceSelectorFromShortId(0x180F), new string[] { "System.Devices.ContainerId" });
            var res = new List<Device>();

            foreach (var device in batteryServiceDeviceInfoCollection)
            {
                //Output("\nDevice id : " + device.Id + "  name " + device.Name);

            //    //foreach (var prop in device.Properties)
            //    //{
            //    //    Output(" " + prop.Key + " " + (prop.Value == null ? null : prop.Value.GetType() + " " + prop.Value));
            //    //}

                var deviceContainerId = "{" + device.Properties["System.Devices.ContainerId"] + "}";

                string macaddr = "";
                try
                {
                    macaddr = device.Id.Split('_')[1].Substring(0, 12);
                }
                catch
                {
                    Output("Unable to parse mac address for device " + device.Id);
                    continue;
                }

                Device d = new Device("BLE device " + device.Name, "bleproximity-"+macaddr, "", DateTime.Now, "HomeOS.Hub.Drivers.BLEProximity", false);
                //intialize the parameters for this device
                 d.Details.DriverParams = new List<string>() { macaddr };
                res.Add(d);
            }
            Output("BLE prox scout found " + res.Count + " paired devices with battery characteristics");
            return res;
        }
Esempio n. 14
0
        private Device CreateDeviceUsb(string serialString)
        {
            var devId = "Valve+" + serialString;
            string driverName = GetDriverName(devId);
            var device = new Device(devId, devId, serialString, DateTime.Now, driverName, false);

            //intialize the parameters for this device
            device.Details.DriverParams = new List<string>() { device.UniqueName };

            return device;
        }
Esempio n. 15
0
        private static Device CreateDevice(byte[] response, NetworkInterface netInterface)
        {
            var macAddress = getString(response, m_offset_MAC, m_length_MAC);
            var cameraIP = getIPAddressString(response, m_offset_Camera_IP);
            var routerIP = getIPAddressString(response, m_offset_router_IP);

            var device = new Device("Foscam - " + macAddress, GetUniqueName(macAddress), netInterface, cameraIP, DateTime.Now, "HomeOS.Hub.Drivers.Foscam");

            //intialize the parameters for this device
            device.Details.DriverParams = new List<string>() { device.UniqueName, "admin", "" };

            return device;
        }
Esempio n. 16
0
        //this is for devices discovered over Usb
        private Device CreateDeviceUsb(string serialString)
        {
            var devId = serialString;

            string driverName = GetDriverName(devId);
            string friendlyName = GetFriendlyName(devId);
            var device = new Device(friendlyName, devId, "", DateTime.Now, driverName, false);

            //intialize the parameters for this device
            device.Details.DriverParams = new List<string>() { device.UniqueName, serialPortofArduino };

            return device;
        }
        //this is for devices discovered over Wifi
        private Device CreateDeviceWifi(byte[] response, int length, IPEndPoint sender, NetworkInterface netInterface)
        {
            var devId = Encoding.ASCII.GetString(response, 0, length);
            string driverName = GetDriverName(devId);
            string friendlyName = GetFriendlyName(devId);
            var device = new Device(friendlyName, devId, netInterface, sender.Address.ToString(), DateTime.Now, driverName, false);

            //intialize the parameters for this device
            device.Details.DriverParams = new List<string>() { device.UniqueName };

            return device;
        }
        private List<Device> ScanDevices()
        {
            List<Device> retList = new List<Device>();
            //only one of these calls can be active because of socket conflicts
            lock (this)
            {
                logger.Log("SynapseWirelessScout:ScanningDevices\n");

                using (var client = new UdpClient(8401))
                {
                    
                    client.Client.ReceiveTimeout = 1000;

                    Byte[] sendBytes = Encoding.ASCII.GetBytes("Is anybody there?");
                    client.Send(sendBytes, sendBytes.Length, "localhost", queryPortNumber);
                    try
                    {
                        // loop until you timeout
                        while (true)
                        {
                            //IPEndPoint object will allow us to read datagrams sent from any source.
                            IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);

                            // Blocks until a message returns on this socket from a remote host.
                            Byte[] receiveBytes = client.Receive(ref RemoteIpEndPoint);
                            string returnData = Encoding.ASCII.GetString(receiveBytes);

                            //create device
                            string deviceName = returnData;
                            string driverName = GetDriverName(deviceName);
                            string deviceID = deviceName;
                            Device device = new Device(deviceName, deviceID, "", DateTime.Now, driverName, false);

                            //intialize the parameters for this device
                            device.Details.DriverParams = new List<string>() { device.UniqueName };
                            //logger.Log("Put device on deivcelist: {0} \n", device.ToString());

                            retList.Add(device);
                        }
                    }
                    catch
                    {
                        ;
                    }
                }
            }
            return retList;
        }
Esempio n. 19
0
        public List<string> GetDeviceDriverParams(Device targetDevice)
        {
            lock (allDevices)
            {
                foreach (Device device in allDevices.Values)
                {
                    if (device.UniqueName.Equals(targetDevice.UniqueName))
                    {
                        //make sure you fetch from device, not targetDevice
                        return device.Details.DriverParams;
                   }
                }

                //no matching device was found :(

                throw new Exception(String.Format("Matching device not found in allDevice. DeviceToUpdate = {0}", targetDevice.UniqueName));
            }
        }
Esempio n. 20
0
 //TODO: this function should be retired
 public Tuple<bool, string> StartDriverForDevice(Device device, string username, string password)
 {
     return StartDriverForDevice(device, new List<string>() { device.UniqueName, username, password });
 }
Esempio n. 21
0
 public List<string> GetDeviceDriverParams(Device targetDevice)
 {
     return config.GetDeviceDriverParams(targetDevice);
 }
Esempio n. 22
0
 public void SetDeviceDriverParams(Device targetDevice, List<string> paramList)
 {
     config.SetDeviceDriverParams(targetDevice, paramList);
 }