Set network over bluetooth

connect to bluetooth PAN network

in ubuntu 18.04, the network is managed by network-manager (nm), and bluetooth is controlled by bluez. that means, we need setup the bluetooth first then set the network-manager.

1. pair the bluetooth device

pair the bluetooth device with PAN profile and enable the bluetooth PAN.

2. connect the bluetooth PAN network

follow the previous example: we can use the command to show the network status like:

nmcli device status

and it should output like:

wlan0              wifi      connected     wifi-ap          
lxcbr0             bridge    connected     lxcbr0             
eth0               ethernet  connected     Wired connection 1
7C:2E:BD:9C:B1:AB  bt        disconnected  --                 
vethT6EPN0         ethernet  unmanaged     --                 
vethURCRXT         ethernet  unmanaged     --                 
lo                 loopback  unmanaged     --

we need control the connection by using connection id, we can use the command:

nmcli con show

and it should output like:

....
BTNET    a7b6ea93-1444-493d-b449-e2c92fb1aa04  bluetooth  --
...

now, we can use the command to connect the bluetooth network:

sudo nmcli con up "BTNET"

Android app get property method

Get property in Application (from android studio)

android SDK dose not have methods to get/set property, we can use the following code to get property

static public String getprop(String key, String defValue) {
    String value = defValue;
    try {
        Class<?> c = Class.forName("android.os.SystemProperties");
        Method get = c.getMethod("get", String.class, String.class);
        value = (String) get.invoke(c, key, "null");
    }
    catch (Exception e) {
        Log.e(TAG, "getprop exception: " + e.toString());
    }
    return value;
}