@@ -0,0 +1,3233 @@
+package com.google.heartrate.wearos.app.bluetooth.server;%0A%0Aimport android.bluetooth.le.AdvertiseCallback;%0Aimport android.bluetooth.le.AdvertiseData;%0Aimport android.bluetooth.le.AdvertiseSettings;%0Aimport android.bluetooth.le.BluetoothLeAdvertiser;%0Aimport android.content.Context;%0Aimport android.os.ParcelUuid;%0Aimport android.util.Log;%0A%0Aimport com.google.heartrate.wearos.app.bluetooth.BluetoothUtils;%0Aimport com.google.heartrate.wearos.app.gatt.GattException;%0A%0Aimport java.util.Set;%0Aimport java.util.UUID;%0A%0A/**%0A * %7B@link BluetoothAdvertiser%7D is the wrapper over %7B@link BluetoothLeAdvertiser%7D class.%0A * %3Cp%3E%0A * Advertising allows devices to broadcast information defining their intentions.%0A * Peripheral uses advertising to allow centrals to find it and, subsequently, to establish a connection with it.%0A * %3Cp%3E%0A * A peripheral can use %7B@link BluetoothAdvertiser%7D to advertise its existence and show it's complete or partial%0A * list of GATT services it offers.%0A *%0A */%0Apublic class BluetoothAdvertiser %7B%0A    private static final String TAG = BluetoothAdvertiser.class.getSimpleName();%0A%0A    /** %7B@link BluetoothAdvertiser%7D for advertising process. */%0A    private final BluetoothLeAdvertiser mBluetoothLeAdvertiser;%0A%0A    /** Advertising callback to receive async responses from %7B@link BluetoothAdvertiser%7D . */%0A    final AdvertiseCallback mAdvertiseCallback = new AdvertiseCallback() %7B%0A        @Override%0A        public void onStartSuccess(AdvertiseSettings settingsInEffect) %7B%0A            Log.i(TAG, %22BluetoothLE Advertise Started.%22);%0A        %7D%0A%0A        @Override%0A        public void onStartFailure(int errorCode) %7B%0A            Log.e(TAG, String.format(%22BluetoothLE Advertise Failed: %25d%22,  + errorCode));%0A        %7D%0A    %7D;%0A%0A    public BluetoothAdvertiser(Context context) throws GattException %7B%0A        mBluetoothLeAdvertiser = BluetoothUtils.getBluetoothLeAdvertiser(context);%0A    %7D%0A%0A    /**%0A     * Start advertising centrals about peripheral existence.%0A     *%0A     * @param serviceUuids list of GATT services peripheral offers%0A     */%0A    public void start(Set%3CUUID%3E serviceUuids) %7B%0A        Log.d(TAG, %22Starting advertising%22);%0A%0A        AdvertiseSettings.Builder advertiseSettings = new AdvertiseSettings.Builder()%0A                /* Balanced between advertising frequency and power consumption */%0A                .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)%0A                .setTimeout(0)%0A                /* Medium transmission (TX) power level */%0A                .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM);%0A%0A        AdvertiseData.Builder advertiseData = new AdvertiseData.Builder()%0A                .setIncludeDeviceName(true)%0A                .setIncludeTxPowerLevel(false);%0A%0A        for (UUID serviceUuid : serviceUuids) %7B%0A            advertiseData.addServiceUuid(new ParcelUuid(serviceUuid));%0A        %7D%0A%0A        mBluetoothLeAdvertiser.startAdvertising(%0A                advertiseSettings.build(),%0A                advertiseData.build(),%0A                mAdvertiseCallback);%0A    %7D%0A%0A    /**%0A     * Stop advertising centrals about peripheral existence.%0A     */%0A    public void stop() %7B%0A        Log.d(TAG, %22Stopping advertising%22);%0A%0A        mBluetoothLeAdvertiser.stopAdvertising(mAdvertiseCallback);%0A    %7D%0A%7D%0A

Add bluetooth advertiser implementation