Example #1
0
        public static void ConnectToPeripheral(string identifier,
                                               Action <string> connectedPeripheralAction       = null,
                                               Action <string, string> discoveredServiceAction = null,
                                               Action <string, string, string> discoveredCharacteristicAction = null,
                                               Action <string> disconnectedPeripheralAction = null)
        {
            if (!s_isInitialized)
            {
                return;
            }
            //Debug.Log("Connect to peripheral " + identifier);
            if (s_deviceDiscoverEvents.ContainsKey(identifier))
            {
                return;
            }
            var addr = DeviceAddressDatabase.GetAddressValue(identifier);

            DllInterface.ConnectDevice(addr);
            var evt = new BleDiscoverEvents(connectedPeripheralAction,
                                            discoveredServiceAction,
                                            discoveredCharacteristicAction,
                                            disconnectedPeripheralAction);

            s_deviceDiscoverEvents.Add(identifier, evt);
        }