bhaptics / tact-android

Other
1 stars 3 forks source link

Pattern playing on wrong vest #6

Closed michaeltheory closed 3 years ago

michaeltheory commented 3 years ago

Hello again!

Our use case is that we have a single Android app that acts as a hub for multiple vests. They all pair correctly and vibrate. The problem is they all vibrate even when I'm addressing a specific vest.

I manage each vest in its own object with the below code (Kotlin)

val pairedDeviceManager = PairedDeviceManagerImpl(activity.applicationContext)
hapticPlayer = HapticPlayerImpl()
bhapticsManager = BhapticsManagerImpl(activity.applicationContext, hapticPlayer, pairedDeviceManager)

We need to do this because we have an installation with 10 packs of VR headsets and vests. The headsets are running a WebVR experience so they cannot connect to the vests directly. We use an Android app on a tablet as the hub so the WebVR sends a socket to the tablet to tell a specific vest to play a specific pattern. The problem is, that pattern is played on every vest instead of the one that the bhapticsManager is paired to.

michaeltheory commented 3 years ago

If it's helpful, I do the pairing like this:

The global bhapticsManager (bhapticsManager = BhapticsModule.getBhapticsManager();) scans. When it finds a new vest, it creates a reference of a new class HapticVest and passes the address of the vest it represents. Then that class does this:

val pairedDeviceManager = PairedDeviceManagerImpl(activity.applicationContext)
hapticPlayer = HapticPlayerImpl()
bhapticsManager = BhapticsManagerImpl(activity.applicationContext, hapticPlayer, pairedDeviceManager)

bhapticsManager?.addBhapticsManageCallback(object : BhapticsManagerCallback {
    override fun onDeviceUpdate(list: List<BhapticsDevice>) {
        list.forEach { device ->
            if (device.address == address) {
                bhapticsManager?.pair(address)
                bhapticsManager?.stopScan()
            }
        }
    }

I also verified that when it's sending a command, it is only happening on the one correct object reference, yet all vests still vibrate

westside commented 3 years ago

Sorry for the late response. Out SDK does not support device-specific--control yet.

I'll provide simple example later. Can you give me your timeline of your project?

michaeltheory commented 3 years ago

Thanks for getting back to me. Our next milestone is to complete the setup at the end of June -- about a month from now.

michaeltheory commented 3 years ago

@westside just wanted to follow up on this

westside commented 3 years ago

@michaeltheory Really sorry for the late response. It took longer as I expected.

https://github.com/bhaptics/tact-android/tree/sample-multi-device/sample3-multi-device

Concept is simple. Just added index to the device and play it with the index.

It's not tested fully and I'm not sure it's going to be regular SDK. If you find any issues, please let me know.

Sorry again.

michaeltheory commented 3 years ago

Thank you -- this looks like it will be helpful. One question -- does it only work with 5 indices? We will be using 10 vests at once

westside commented 3 years ago

@michaeltheory Yes you're right. I'll update soon.
Sorry for the late response. Having busy these days.

westside commented 3 years ago

By the way, android will only allow 5 to 7 bluetooth connection(depending on the android device) at a time. @michaeltheory Did you test up to 10 devices?

westside commented 3 years ago

@michaeltheory Just updated the branch.