Example #1
0
        private static void UpdateNotification()
        {
            if (!s_isInitialized)
            {
                return;
            }
            int deviceNum = DllInterface.GetConnectDeviceNum();

            for (int i = 0; i < deviceNum; ++i)
            {
                ulong  addr       = DllInterface.GetConnectDeviceAddr(i);
                string identifier = DeviceAddressDatabase.GetAddressStr(addr);

                int num = DllInterface.GetDeviceNotificateNum(addr);
                //Debug.Log("UpdateNotification " + identifier + "::" +num + "  " + i + "/" + deviceNum );
                for (int j = 0; j < num; ++j)
                {
                    var    data               = DllInterface.GetDeviceNotificateData(addr, j);
                    var    serviceHandle      = DllInterface.GetDeviceNotificateServiceUuid(addr, j);
                    var    charastricHandle   = DllInterface.GetDeviceNotificateCharastricsUuid(addr, j);
                    string serviceUUID        = UuidDatabase.GetUuidStr(serviceHandle);
                    string characteristicUUID = UuidDatabase.GetUuidStr(charastricHandle);

                    var           key = new BleCharastericsKeyInfo(identifier, serviceUUID, characteristicUUID);
                    BleNotifyData bleNotifyData;
                    if (s_notifyEvents.TryGetValue(key, out bleNotifyData))
                    {
                        if (bleNotifyData.notifiedCharacteristicAction != null)
                        {
                            bleNotifyData.notifiedCharacteristicAction(serviceUUID, characteristicUUID, data);
                        }
                    }
                }
            }
        }