How to get event for different baudrate? - android

I am working on native android application. In this application I am connecting hardware devices using usb cable, for this connection I used below library:
https://github.com/felHR85/UsbSerial
I have 3 different hardware devices and each device has different
baudrate.
I have one scan button in app. If user click on it then I need to
check which device is connected and print its information.
To implement this, I create 3 methods. Each method have same code
with different baudrate.
When user click on scan button then it will call 1st method and check
if the hardware is detected or not. If not detected then check with
2nd method.
Now the issue is, I am not getting any event if attached device is not connected with given baudrate. So I am not sure when I need to call 2nd method.
Note :- I am getting success if attached device baudrate is same as baudrate set in 1st method so its working. I need event like failed case. If I get any event if failed then I can call 2nd method in it but I am not getting any event like failed.

Related

Which method is called when someone tries to connect using WifiP2PManager.connect(Channel, WifiP2pConfig,ActionListener)?

I am tring to setup WIFI P2P on 2 devices using
manager.addLocalService(channel, service, ActionListener)
and then connect both devices using
manager.connect(channel, config, ActionListener).
I would like to know which method is called before the popup to accept/reject connection is shown on the target device. All I was able to find was onConnectionInfoAvailable(WifiP2pInfo p2pInfo), but it is called after the connection is established.
I basically want to receive the "instance name" of the device trying to connect to me using WIFI P2P and then reject the connection request without showing system dialog(that allows the user to accept/reject connection).
I can't anything that can help me do this on docs or any other place. If anyone knows how to do it or can point me in the right direction then please let me know.
I solved it. I can put the instancename and devicename (of device I want to connect to) in Map that is passed when setting up service. From other device I can retrieve map of all devices available using this and find the instancename of one I need.

Android Ble, Pheriperal Advertise status during the scan

In my application I need to start some BLE scans, get the results and then show them in a list or in a grid.
When i start the scan my device start to look for advertisements basing on which ScanFilters I wrote.
Every time a Pheriperal is found I the application trigger the scan callback method and i can add the new device into the list.
If i got an error the app trigger the callback method and i can tell the user about the broblem.
Example
Imagine the Scan going on for 30s.
At the moment it starts i get 3 Ble Pheriperal.
At second 15 one of them stop to advertise and turn bluetooth off.
At the end of the scan my list will have 3 Ble devices but i will not be able to connect to one of them.
How do I know which of them is the one which turned off?
Where do i get his status?
Thanks for the help.
You can try this, technically it is possible as per the documentation. in onScanResult callback, check for the callbackType parameter. If it is CALLBACK_TYPE_MATCH_LOST then get the device from the results and remove it from your cache.

Android- wifiDirect

I am developing a simple wifiDirect chat app.My app does peer searching and once peer's list is available one can select a particular device, the one to connect with. Then my code calls connect() which sends a notification to the other device (2nd phone) about connection (default). Once the second phone agrees to the connection then 1st phone becomes group owner while second phone running my app does nothing.
So my question is do I need to call connect() on both devices? Also when is this intent action WIFI_P2P_THIS_DEVICE_CHANGED_ACTION broadcast?
Need help, read android.developers.com and other official sites but couldn't figure out.
No, you only need to call connect() on one device. Note that this does not mean that the device that calls connect() will be the group owner. The system will decide the group owner itself. You can only suggest your preference through config.groupOwnerIntent = x; where x is from 0 to 15, 0 representing least intention to become owner while 15 represents the highest.
WIFI_P2P_THIS_DEVICE_CHANGED_ACTION event will be fired when the status of the device has changed.
Use the following code to fetch the updated details of the device.
(WifiP2pDevice)intent.getParcelableExtra(WifiP2pManager.EXTRA_WIFI_P2P_DEVICE));

Android - set pin for Bluetooth

I have been reading the Bluetooth documentation on Android's developer site.
I want to pair a Bluetooth device and then connect to it, but I don't want the request dialog to pop up (or even if it does set the pin using some API to dismiss it). I want to do it in Android 4.3+.
So far I see this involving the following steps:
1) App discovers device : use BroadcastReceiver to get BluetoothDevice
2) App pairs the device : uses BluetoothDevice.createBond(), and registers a BroadcastReceiver to get confirmation of pairing completion
3) App connects to device : uses BluetoothDevice.createRfCommSocketToServiceRecord(UUID)
My understanding is that the pop dialog for pairing will be shown to the user after step 2.
I know there is a setPin() API (now public) in the BluetoothDevice class.
If I call it right after step 2, will the dialog still appear and wait for user input, or will it appear and then dismiss, resulting in pairing success ?
Also does step 3 involve any input from the user ?
Step 3 doesn't involve user input.
I've been trying to do exactly the same, I use setPin() and it works, but the user Input dialogue is still there, there is an option to use cancelPairingUserInput but i'm not sure if this is still valid for API19 (that is the one which uses setPin() as far as I know...) or if there is another way to do it.
Hope this helps...

Is it possible to pair BluetoothDevice programmatically android?

Currently Iam using backport.android.bluetooth2.jar file for bluetooth programming with Android 1.5.Whenever device pairing fails it populates alert dialog for passKey and if i give passkey then in my log iam getting below error
07-21 12:25:52.419: WARN/BluetoothDeviceService(948): setPin(00:0E:6D:BA:89:F3) called but no native data available, ignoring. Maybe the PasskeyAgent Request was cancelled by the remote device or by bluez.
For successfully pair my BT device I always rebooting my tablet and manually pair the device with Settings options.So at last i realised to give this passKey programmatically but i haven't found any method for this.But in google opensource i found one method that is commented with #hide setPassKey(String Address,int passKey) in BluetoothDevice.java of backport.android.bluetooth2.jar .This will n't appear in my jar file.If any way is there for pairing the unbounded device please give reply ASAP?
In the AndroidBluetoothAPI_0.3.jar file following methods are available i,e: pair(address) and setPin() for setting the pin programmatically and connecting the BT device.For finding the signal strength method is available in this api.Below is the code project link
http://code.google.com/p/android-bluetooth/downloads/detail?name=AndroidBluetoothAPI_0.3.jar&can=2&q=

Categories

Resources