Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

[Android] USB Ant Stick-RequestAccess return SEARCH_TIMEOUT

Rank

Total Posts: 1

Joined 2021-01-12

PM

Hi all,
i have implemented an android app when found and connect the sensors with the Ant+ SDK , the code work fine with the device with ant hardware, but i have problem when use the usb ant stick.

The problem is the following:
after create a MultiDeviceSearch object, the SearchCallbacks found the sensors, but when i call the specific requestAccess, the IPluginAccessResultReceiver return a SEARCH_TIMEOUT result.

This is the code for request a FitnessMachine sensor (but the problem is for all device type):

val multiDeviceSearch MultiDeviceSearch(contextdevicesTypecallbacksrssiCallback)

val callbacks object SearchCallbacks {
        override fun onSearchStarted
(p0MultiDeviceSearch.RssiSupport?) {
        }

        override fun onDeviceFound
(p0MultiDeviceSearchResult?) {
            p0
?.let {
                onNewDeviceFound
(p0)
            
}
        }

        override fun onSearchStopped
(p0RequestAccessResult?) {
        }
    }

private fun onNewDeviceFound(multiDeviceSearchResultMultiDeviceSearchResult{

        val id 
multiDeviceSearchResult.antDeviceNumber.toString()
        
val name =
            
"${multiDeviceSearchResult.deviceDisplayName}_${multiDeviceSearchResult.antDeviceType}"


        
val device when (multiDeviceSearchResult.antDeviceType{
            DeviceType
.FITNESS_EQUIPMENT -> {
                AntFitnessEquipmentDevice
(
                    
name name,
                    
id id,
                    
multiDeviceSearchResult multiDeviceSearchResult,
                    
context context
                
)
            
}
            
else -> {
                
//nothing for now
                
null
            }
        }
    } 


this is the AntFitnessEquipmentDevice class

class AntFitnessEquipmentDevice(
    
override val nameString,
    
override val idString,
    
override val multiDeviceSearchResultMultiDeviceSearch.MultiDeviceSearchResult,
    private 
val contextContext
{

    
private var fitnessEquipmentPccAntPlusFitnessEquipmentPcc? = null
    
private var handlePccReleaseHandle<AntPlusFitnessEquipmentPcc>? = null

    
var equipmentTypeAntPlusFitnessEquipmentPcc.EquipmentType UNRECOGNIZED


    
//region Parent Methods
    
override fun requestAccess() {
        handle
?.close()
        
handle AntPlusFitnessEquipmentPcc.requestNewOpenAccess(
            
context,
            
multiDeviceSearchResult.antDeviceNumber,
            
0,
            
resultReceiver,
            
stateChangeReceiver,
            
fitnessEquipmentStateReceiver
        
)
    
}

    override fun release
() {
        fitnessEquipmentPcc
?.releaseAccess()
    
}

    override fun close
() {
        handle
?.close()
    
}

    
//endregion

    //region Private Methods

    
private fun onPcc() {
        fitnessEquipmentPcc
?.let {
            subscribeCommonReceiver
(it)
        
}
    }

    
//endregion

    //region Callback

    //    AntPlusBikeCadencePcc var1,
    //    RequestAccessResult var2,
    //    DeviceState var3
    
private val resultReceiver =
        
AntPluginPcc.IPluginAccessResultReceiver<AntPlusFitnessEquipmentPcc{ pccrequestAccessResultdeviceState ->
            
when (requestAccessResult{
                SUCCESS 
-> {
                    fitnessEquipmentPcc 
pcc
                    actualState 
deviceState
                    onPcc
()
                
}
                DEPENDENCY_NOT_INSTALLED 
-> {
                    
// TODO alert??
                
}
                SEARCH_TIMEOUT 
-> {
                    retryRequestAccess
()
                
}
//                USER_CANCELLED -> {}
//                CHANNEL_NOT_AVAILABLE -> {}
//                OTHER_FAILURE -> {}
//                DEVICE_ALREADY_IN_USE -> {}
//                ALREADY_SUBSCRIBED -> {}
//                BAD_PARAMS -> {}
//                ADAPTER_NOT_DETECTED -> {}
//                UNRECOGNIZED -> {}
                
else -> {
                    
// nothing
                
}
            }
        }

    
private val stateChangeReceiver IDeviceStateChangeReceiver { deviceState ->
        
actualState deviceState
        onChangeState
(deviceState)
    
}

    
//    estTimestamp: Long,
//    eventFlags: EnumSet<EventFlag>?,
//    equipmentType: AntPlusFitnessEquipmentPcc.EquipmentType?,
//    equipmentState: AntPlusFitnessEquipmentPcc.EquipmentState?
    
private val fitnessEquipmentStateReceiver =
        
AntPlusFitnessEquipmentPcc.IFitnessEquipmentStateReceiver { __equipmentTypeequipmentState ->

            
fitnessEquipmentPcc?.let { pcc ->

                
this.equipmentType equipmentType

            }

        }

    
//   estTimestamp: Long,
//   eventFlags: EnumSet<EventFlag>?,
//   capabilities: AntPlusFitnessEquipmentPcc.Capabilities?
    
private val capabilitiesReceiver =
        
AntPlusFitnessEquipmentPcc.ICapabilitiesReceiver { __capabilities ->

            
        
}


//endregion


Can you help me?
Thanks      
Rank

Total Posts: 1

Joined 2022-11-02

PM

Hi, did you ever manage to fix this problem ?      
Rank

Total Posts: 1

Joined 2023-09-14

PM

Hello, I think you should check USB Permissions: Make sure that your Android app has the necessary permissions to access USB devices. In your app's manifest file, include the following permission: pizza tower

xml
<uses-permission android:name="android.permission.USB_PERMISSION" /> 

Additionally, you may need to request USB permission at runtime before accessing the USB ANT stick      
Rank

Total Posts: 5

Joined 2023-10-26

PM

KarinClean - 14 September 2023 05:09 PM
Hello, I think you should check USB Permissions: Make sure that your Android app has the necessary permissions to access USB devices. In your app's manifest file, include the following permission: happy wheels

xml
<uses-permission android:name="android.permission.USB_PERMISSION" /> 

Additionally, you may need to request USB permission at runtime before accessing the USB ANT stick

Thanks for your response, issue has been resolved.      
Rank

Total Posts: 5

Joined 2024-04-23

PM

KarinClean - 14 September 2023 05:09 PM
Hello, I think you should check USB Permissions: Make sure that your Android app has the necessary permissions to access USB devices. In your app's manifest file, include the following permission: tifa sexdoll

xml
<uses-permission android:name="android.permission.USB_PERMISSION" /> 

Additionally, you may need to request USB permission at runtime before accessing the USB ANT stick


It seems like you've mixed up the permission name. The correct permission for accessing USB devices is android.permission.USB_PERMISSION, not "pizza tower". Make sure to include the correct permission name in your app's manifest file. Here's the corrected XML:
<uses-permission android:name="android.permission.USB_PERMISSION" >

Then, you'll need to request USB permission at runtime before accessing the USB ANT stick in your app.      
RankRank

Total Posts: 31

Joined 2023-08-06

PM

Not all USB ANT sticks are compatible with Emoji Kitchen Android devices. The stick must be supported by the ANT+ API. Also, confirm that your Android device supports USB OTG (On-The-Go) and that you are using an OTG cable if necessary.