Search in sources :

Example 1 with AdvertiseData

use of android.bluetooth.le.AdvertiseData in project physical-web by google.

the class FatBeaconBroadcastService method broadcastUrl.

/////////////////////////////////
// utilities
/////////////////////////////////
// Broadcast via bluetooth the stored URL
private void broadcastUrl() {
    byte[] bytes = null;
    try {
        bytes = mDisplayInfo.getBytes("UTF-8");
    } catch (UnsupportedEncodingException e) {
        Log.e(TAG, "Could not encode URL", e);
        return;
    }
    AdvertiseData advertiseData = AdvertiseDataUtils.getFatBeaconAdvertisementData(bytes);
    AdvertiseSettings advertiseSettings = AdvertiseDataUtils.getAdvertiseSettings(true);
    mBluetoothLeAdvertiser.stopAdvertising(mAdvertiseCallback);
    mBluetoothLeAdvertiser.startAdvertising(advertiseSettings, advertiseData, mAdvertiseCallback);
}
Also used : AdvertiseSettings(android.bluetooth.le.AdvertiseSettings) UnsupportedEncodingException(java.io.UnsupportedEncodingException) AdvertiseData(android.bluetooth.le.AdvertiseData)

Example 2 with AdvertiseData

use of android.bluetooth.le.AdvertiseData in project physical-web by google.

the class PhysicalWebBroadcastService method broadcastUrl.

/////////////////////////////////
// utilities
/////////////////////////////////
// Broadcast via bluetooth the stored URL
private void broadcastUrl(byte[] url) {
    final AdvertiseData advertisementData = AdvertiseDataUtils.getAdvertisementData(url);
    final AdvertiseSettings advertiseSettings = AdvertiseDataUtils.getAdvertiseSettings(false);
    mBluetoothLeAdvertiser.stopAdvertising(mAdvertiseCallback);
    mBluetoothLeAdvertiser.startAdvertising(advertiseSettings, advertisementData, mAdvertiseCallback);
}
Also used : AdvertiseSettings(android.bluetooth.le.AdvertiseSettings) AdvertiseData(android.bluetooth.le.AdvertiseData)

Aggregations

AdvertiseData (android.bluetooth.le.AdvertiseData)2 AdvertiseSettings (android.bluetooth.le.AdvertiseSettings)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1