예제 #1
0
        public Gatt Connect()
        {
            AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            var activity = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");

            m_gatt              = new Gatt();
            m_gatt.OnConnected += TriggerOnConnected;
            var callbacks = new AndroidJavaObject("com.blatand.GattCallbackInterfacer", new Gatt.InternalGattCallback(m_gatt));

            m_gatt.m_callbacks = callbacks;
            if (GetSDKInt() >= 23)
            {
                m_gatt.AndroidObject = m_androidObject.Call <AndroidJavaObject>("connectGatt", activity, false, callbacks, 2);
            }
            else
            {
                m_gatt.AndroidObject = m_androidObject.Call <AndroidJavaObject>("connectGatt", activity, false, callbacks);
            }

            return(m_gatt);
        }
예제 #2
0
 void TriggerOnConnected(Gatt gatt)
 {
     OnConnected(this, gatt);
 }
예제 #3
0
 internal GattService(AndroidJavaObject androidObject, Gatt gatt) : base(androidObject)
 {
     m_characteristics = new Dictionary <string, GattCharacteristic>();
     Gatt = gatt;
 }
예제 #4
0
 public InternalGattCallback(Gatt source) : base()
 {
     m_source = source;
 }