static void Main(string[] args)
        {
            RemotingConfiguration.Configure(CONFIG_FILE, false);
            var services = RemotingConfiguration.GetRegisteredWellKnownServiceTypes();

            if (services.Length == 0)
            {
                Console.WriteLine("You must specify app.config file with wellknown tag inside a service tag.");
                Console.ReadLine();
                return;
            }
            var config   = ConfigurationSettings.AppSettings;
            var type     = config["type"];
            var assembly = config["assembly"];
            var brokers  = new List <IBrokerClient>();

            for (int i = 2; i < config.Count; i++)
            {
                WellKnownClientTypeEntry entry = new WellKnownClientTypeEntry(type, assembly, config[i]);
                brokers.Add((IBrokerClient)Activator.GetObject(entry.ObjectType, entry.ObjectUrl));
            }
            var    central         = new CentralManager(brokers);
            ObjRef objrefWellKnown = RemotingServices.Marshal(central, services[0].ObjectUri);

            Console.WriteLine("Início do Server CentralManager.\n Espera de pedidos");
            Console.ReadLine();
        }
Exemple #2
0
        public async void StartScanningForDevices(Guid serviceUuid)
        {
            await WaitForState(CBCentralManagerState.PoweredOn);

            Debug.WriteLine("Adapter: Starting a scan for devices.");

            CBUUID[] serviceUuids = null; // TODO: convert to list so multiple Uuids can be detected
            if (serviceUuid != Guid.Empty)
            {
                var suuid = CBUUID.FromString(serviceUuid.ToString());
                serviceUuids = new CBUUID[] { suuid };

                Debug.WriteLine("Adapter: Scanning for " + suuid);
            }

            // clear out the list
            DiscoveredDevices = new List <IDevice>();

            // start scanning
            IsScanning = true;
            CentralManager.ScanForPeripherals(serviceUuids);

            // in 10 seconds, stop the scan
            await Task.Delay(10000);

            // if we're still scanning
            if (IsScanning)
            {
                Console.WriteLine("Adapter: Scan timeout has elapsed.");
                IsScanning = false;
                CentralManager.StopScan();
                ScanTimeoutElapsed(this, new EventArgs());
            }
        }
Exemple #3
0
        public void ConnectToDevice(IDevice device)
        {
            //TODO: if it doesn't connect after 10 seconds, cancel the operation
            // (follow the same model we do for scanning).
            CentralManager.ConnectPeripheral(device.NativeDevice as CBPeripheral, new PeripheralConnectionOptions());

            /*
             * // in 10 seconds, stop the connection
             * await Task.Delay(10000);
             *
             * // if we're still trying to connect
             * if (IsConnecting)
             * {
             *  Console.WriteLine("Adapter: Connect timeout has elapsed.");
             *  Central. ...
             *  ConnectTimeoutElapsed(this, new EventArgs());
             * }
             */
        }
        /// <summary>
        /// Begins the scanning for bluetooth LE devices. Automatically called after 10 seconds
        /// to prevent battery drain.
        /// </summary>
        /// <returns>The scanning for devices.</returns>
        public async Task BeginScanningForDevices()
        {
            Console.WriteLine("BluetoothLEManager: Starting a scan for devices.");

            // clear out the list
            DiscoveredDevices = new List <CBPeripheral>();

            // start scanning
            IsScanning = true;
            CentralManager.ScanForPeripherals(peripheralUuids: null);

            // in 10 seconds, stop the scan
            await Task.Delay(10000);

            // if we're still scanning
            if (IsScanning)
            {
                Console.WriteLine("BluetoothLEManager: Scan timeout has elapsed.");
                CentralManager.StopScan();
                ScanTimeoutElapsed(this, new EventArgs());
            }
        }
Exemple #5
0
 public void DisconnectDevice(IDevice device)
 {
     CentralManager.CancelPeripheralConnection(device.NativeDevice as CBPeripheral);
 }
Exemple #6
0
 public void StopScanningForDevices()
 {
     Console.WriteLine("Adapter: Stopping the scan for devices.");
     IsScanning = false;
     CentralManager.StopScan();
 }
Exemple #7
0
 private void Awake()
 {
     instance = this;
     bm       = GetComponent <BoardManager>();
 }
 void Awake()
 {
     centralManagerInstance = this;
 }
 public void DisconnectDevice(CBPeripheral peripheral)
 {
     CentralManager.CancelPeripheralConnection(peripheral);
 }
 internal BGPeripheral(string address, bool isPublicAddress, BGLibApi bgApi, sbyte rssi = 0, CentralManager source = null)
     : base(address, isPublicAddress, rssi, source)
 {
     _bgApi = bgApi;
     _procedureCompletedWaitHandle = new AsyncAutoResetEvent(false);
 }