Exemplo n.º 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);
        }
Exemplo n.º 2
0
 void TriggerOnConnected(Gatt gatt)
 {
     OnConnected(this, gatt);
 }
Exemplo n.º 3
0
 internal GattService(AndroidJavaObject androidObject, Gatt gatt) : base(androidObject)
 {
     m_characteristics = new Dictionary <string, GattCharacteristic>();
     Gatt = gatt;
 }
Exemplo n.º 4
0
 public InternalGattCallback(Gatt source) : base()
 {
     m_source = source;
 }