Saturday, October 31, 2015
Android Bluetooth APIs - Learning Part II
Below is the snippet to retrieve list of bonded devices.
Set pairedDevices = btAdapter.getBondedDevices();
getName() returns the public identifier of the devices
getAddress() returns the MAC address of the device
In order to find the nearby devices, which is called scanning we need to use the below code
btAdapter.startDiscovery() is the method to start scanning operation. btAdapter.cancelDiscovery() will cancel the initiated scanning
These two methods are working via Asynchronous feedbacks by Broadcast Receivers.
private final BroadcastReceiver receiver = new BroadcastReceiver()
{
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if(BluetoothDevice.ACTION_FOUND.equals(action))
{
BluetoothDevice device = intent.getParcellableExtra(BluetoothDevice.EXTRA_DEVICE);
}
}
}
Connecting to a Device:
Similar to any other connection, there is a Server and Client which communicates via RFCOMM sockets.
On Android, RFCOMM sockets are represented as BluetoothSocket object.
Below is the code to connect to a Bluetooth Device
public class ConnectThreads extends Thread
{
private BluetoothSocket bTSocket;
public boolean connect(BluetoothDevice btDevice, UUID uuid)
{
BluetoothSocket socket = null;
try
{
socket = btDevice.createRFCommSocketToServiceRecord()
}
catch(Exception ex)
{
ex.printStackTrace();
}
try
{
socket.connect();
}
catch(Exception ex)
{
ex.printStackTrace();
try
{
}
catch(Excpetion ex)
{
}
}
}
}
References:
Linphone Management of Bandwidth parameter
References:
https://www.linphone.org/docs/liblinphone/group__media__parameters.html#ga1e0c01a25f78d14c6813213adf795e54
https://www.linphone.org/docs/liblinphone/group__media__parameters.html#ga1e0c01a25f78d14c6813213adf795e54
SIP SDP bandwidth information
The SDP includes an optional bandwidth attribute with the following syntax
b=:
where is single alpha numeric word giving the meaning of the bandwidth figure, and where the default units of
bandwidth value is kilobits per second. This attribute specifies the proposed bandwidth to be used by the session or media.
The typical use is with the modifier “AS” (Application specific Maximum) which may be used to specify the total bandwidth for a
single media stream from one site (source)
another modifier value is CT. If the bandwidth of a session or a media in a session is different from the bandwidth implicit from the scope,
a b=“CT” line should be supplied for the session giving the proposed upper limit to the bandwidth used (the “conference total” bandwidth)
The primary purpose of this is to give an approximate idea as to whether two or more sessions can co-exist simultaneously. when using CT
modifier with RTP, if several RTP sessions are part of the conference, the conference total refers to the total bandwidth of all the RTP sessions.
References:
Quirks of Unzipping on MAC
Some of the files were not able to be unzipped using either “unzip” command or “ditto” command via terminal
however, since they were getting opened perfectly using the “Archive Utility”, one option was to use the
terminal to open such files. e.g. below
open -a "Archive Utility" 0B9822F3-FE6C-4FB6-AB47-C98DA932279D_205155390.zip
The only inconvenience is that we cannot specify the destination folder.
This can be automated using a simple shell script like this
for file in *; do
echo $file
open -a "Archive Utility" $file
done
References:
Subscribe to:
Posts (Atom)