Java 类android.bluetooth.le.AdvertiseSettings 实例源码

项目:RangeThings    文件:GattServer.java   
private void startAdvertising() {
    if (mBluetoothLeAdvertiser == null) return;

    AdvertiseSettings settings = new AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .setConnectable(true)
            .setTimeout(0)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
            .build();

    AdvertiseData data = new AdvertiseData.Builder()
            .setIncludeDeviceName(true)
            .setIncludeTxPowerLevel(false)
            .addServiceUuid(new ParcelUuid(GattProfile.SERVICE_UUID))
            .build();

    mBluetoothLeAdvertiser.startAdvertising(settings, data, mAdvertiseCallback);
}
项目:mDL-ILP    文件:BLEConnection.java   
private void startAdvertising() {
    AdvertiseSettings advSettings = new AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
            .setConnectable(true)
            .build();

    AdvertiseData advData = new AdvertiseData.Builder()
            .setIncludeTxPowerLevel(true)
            .addServiceUuid(Constants.SERVICE_pUUID)
            .addServiceData(Constants.SERVICE_pUUID, serviceData)
            .build();

    AdvertiseData advScanResponse = new AdvertiseData.Builder()
            .setIncludeDeviceName(true)
            .build();

    if (mAdvertiser != null) {
        gattService.startAdvertising();
        mAdvertiser.startAdvertising(advSettings, advData, advScanResponse, advCallback);
        Log.d(TAG, "Started advertisement of mDL service with data " + new String(serviceData));
    } else {
        Log.e(TAG, "mAdvertiser not available!");
    }
}
项目:mobly-bundled-snippets    文件:JsonDeserializer.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static AdvertiseSettings jsonToBleAdvertiseSettings(JSONObject jsonObject)
        throws JSONException {
    AdvertiseSettings.Builder builder = new AdvertiseSettings.Builder();
    if (jsonObject.has("AdvertiseMode")) {
        int mode = MbsEnums.BLE_ADVERTISE_MODE.getInt(jsonObject.getString("AdvertiseMode"));
        builder.setAdvertiseMode(mode);
    }
    // Timeout in milliseconds.
    if (jsonObject.has("Timeout")) {
        builder.setTimeout(jsonObject.getInt("Timeout"));
    }
    if (jsonObject.has("Connectable")) {
        builder.setConnectable(jsonObject.getBoolean("Connectable"));
    }
    if (jsonObject.has("TxPowerLevel")) {
        int txPowerLevel =
                MbsEnums.BLE_ADVERTISE_TX_POWER.getInt(jsonObject.getString("TxPowerLevel"));
        builder.setTxPowerLevel(txPowerLevel);
    }
    return builder.build();
}
项目:Quick-Bluetooth-LE    文件:BLEServer.java   
public BtError startServer(){
    BtError error = checkBluetooth();
    if(error != BtError.None)
        return error;
    bleAdvertiser = btAdapter.getBluetoothLeAdvertiser();
    gattServer = btManager.openGattServer(context, gattServerCallback);
    for(BluetoothGattService service : services){
        gattServer.addService(service);
    }
    if(bleAdvertiser == null)
        return BtError.NoServer;
    AdvertiseSettings.Builder settings = new AdvertiseSettings.Builder();
    settings.setAdvertiseMode(advertiseMode);
    settings.setConnectable(true);
    settings.setTimeout(0);
    settings.setTxPowerLevel(advertiseTransmitPower);
    AdvertiseData.Builder data = new AdvertiseData.Builder();
    data.setIncludeDeviceName(advertiseDeviceName);
    //data.addServiceUuid(new ParcelUuid(SERVICE_COMMUNICATION));
    bleAdvertiser.startAdvertising(settings.build(), data.build(), advertiseCallback);
    serverRunning = true;
    return BtError.None;
}
项目:blefun-androidthings    文件:GattServer.java   
private void startAdvertising() {
    BluetoothAdapter bluetoothAdapter = mBluetoothManager.getAdapter();
    mBluetoothLeAdvertiser = bluetoothAdapter.getBluetoothLeAdvertiser();
    if (mBluetoothLeAdvertiser == null) {
        Log.w(TAG, "Failed to create advertiser");
        return;
    }

    AdvertiseSettings settings = new AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .setConnectable(true)
            .setTimeout(0)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
            .build();

    AdvertiseData data = new AdvertiseData.Builder()
            .setIncludeDeviceName(true)
            .setIncludeTxPowerLevel(false)
            .addServiceUuid(new ParcelUuid(SERVICE_UUID))
            .build();

    mBluetoothLeAdvertiser
            .startAdvertising(settings, data, mAdvertiseCallback);
}
项目:sample-bluetooth-le-gattserver    文件:GattServerActivity.java   
/**
 * Begin advertising over Bluetooth that this device is connectable
 * and supports the Current Time Service.
 */
private void startAdvertising() {
    BluetoothAdapter bluetoothAdapter = mBluetoothManager.getAdapter();
    mBluetoothLeAdvertiser = bluetoothAdapter.getBluetoothLeAdvertiser();
    if (mBluetoothLeAdvertiser == null) {
        Log.w(TAG, "Failed to create advertiser");
        return;
    }

    AdvertiseSettings settings = new AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .setConnectable(true)
            .setTimeout(0)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
            .build();

    AdvertiseData data = new AdvertiseData.Builder()
            .setIncludeDeviceName(true)
            .setIncludeTxPowerLevel(false)
            .addServiceUuid(new ParcelUuid(TimeProfile.TIME_SERVICE))
            .build();

    mBluetoothLeAdvertiser
            .startAdvertising(settings, data, mAdvertiseCallback);
}
项目:BLEServerSimple    文件:AdvertiseAdaptor.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private AdvertiseSettings makeAdvertiseSetting() {

    AdvertiseSettings.Builder builder = new AdvertiseSettings.Builder();

    //Set advertise mode to control the advertising power and latency.
    builder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY);
    //Set advertise TX power level to control the transmission power level for the advertising.
    builder.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_ULTRA_LOW);
    //Set whether the advertisement type should be connectable or non-connectable.
    builder.setConnectable(CONNECTABLE);
    //Limit advertising to a given amount of time.
    builder.setTimeout(TIMEOUT);

    return builder.build();
}
项目:BleUARTPeripheral    文件:MainActivity.java   
private void startAdvertising() {
    if (mBluetoothLeAdvertiser == null) return;

    AdvertiseSettings settings = new AdvertiseSettings.Builder()
            .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .setConnectable(true)
            .setTimeout(0)
            .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
            .build();

    AdvertiseData data = new AdvertiseData.Builder()
            .setIncludeDeviceName(true)
            .addServiceUuid(new ParcelUuid(UARTProfile.UART_SERVICE))
            .build();

    mBluetoothLeAdvertiser.startAdvertising(settings, data, mAdvertiseCallback);
}
项目:unity-bluetooth    文件:BLEServicePeripheral.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void start(String uuidString) {
    mServiceUUID = UUID.fromString(uuidString);
    if (mBtAdvertiser == null) {
        return;
    }

    BluetoothGattService btGattService = new BluetoothGattService(mServiceUUID, BluetoothGattService.SERVICE_TYPE_PRIMARY);
    btGattService.addCharacteristic(mBtGattCharacteristic);
    BluetoothGattServerCallback btGattServerCallback = createGattServerCallback(mServiceUUID, UUID.fromString(CHARACTERISTIC_UUID));
    mBtGattServer = mBtManager.openGattServer(mActivity.getApplicationContext(), btGattServerCallback);
    mBtGattServer.addService(btGattService);

    mDataBuilder = new AdvertiseData.Builder();
    mDataBuilder.setIncludeTxPowerLevel(false);
    mDataBuilder.addServiceUuid(new ParcelUuid(mServiceUUID));

    mSettingsBuilder=new AdvertiseSettings.Builder();
    mSettingsBuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED);
    mSettingsBuilder.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH);

    mBleAdvertiser = mBtAdapter.getBluetoothLeAdvertiser();
    mBleAdvertiser.startAdvertising(mSettingsBuilder.build(), mDataBuilder.build(), mAdvertiseCallback);
}
项目:Quick-Bluetooth-LE    文件:BLEServer.java   
public BtError startServer(){
    BtError error = checkBluetooth();
    if(error != BtError.None)
        return error;
    bleAdvertiser = btAdapter.getBluetoothLeAdvertiser();
    gattServer = btManager.openGattServer(context, gattServerCallback);
    for(BluetoothGattService service : services){
        gattServer.addService(service);
    }
    if(bleAdvertiser == null)
        return BtError.NoServer;
    AdvertiseSettings.Builder settings = new AdvertiseSettings.Builder();
    settings.setAdvertiseMode(advertiseMode);
    settings.setConnectable(true);
    settings.setTimeout(0);
    settings.setTxPowerLevel(advertiseTransmitPower);
    AdvertiseData.Builder data = new AdvertiseData.Builder();
    data.setIncludeDeviceName(advertiseDeviceName);
    //data.addServiceUuid(new ParcelUuid(SERVICE_COMMUNICATION));
    bleAdvertiser.startAdvertising(settings.build(), data.build(), advertiseCallback);
    serverRunning = true;
    return BtError.None;
}
项目:Mycroft-Android    文件:BeaconUtil.java   
public void broadcastAsBeacon() {
        Beacon beacon = new Beacon.Builder()
                .setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
                .setId2("1")
                .setId3("2")
                .setManufacturer(0x0118) // Radius Networks.  Change this for other beacon layouts
                .setTxPower(-59)
                .setDataFields(Arrays.asList(new Long[]{0l})) // Remove this for beacon layouts without d: fields
                .build();
// Change the layout below for other beacon types
        BeaconParser beaconParser = new BeaconParser()
                .setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25");
        BeaconTransmitter beaconTransmitter = new BeaconTransmitter(context, beaconParser);
        beaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {

            @Override
            public void onStartFailure(int errorCode) {
                Log.e("Class", "Advertisement start failed with code: " + errorCode);
            }

            @Override
            public void onStartSuccess(AdvertiseSettings settingsInEffect) {
                Log.i("class", "Advertisement start succeeded.");
            }
        });
    }
项目:beacons-android    文件:EddystoneGattConfigurator.java   
@SuppressLint("InlinedApi")
@Override
public int setAdvertiseInterval(int advertiseIntervalMs) {
    Util.log(TAG, "setAdvertiseInterval() called with: advertiseIntervalMs = [" + advertiseIntervalMs + "]");

    @Advertiser.Mode int mode;

    if (advertiseIntervalMs <= 100 + (250 - 100) / 2) {
        // 100 ms
        mode = AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY;
    } else if (advertiseIntervalMs >= 1000 - (1000 - 250) / 2) {
        // 1000 ms
        mode = AdvertiseSettings.ADVERTISE_MODE_LOW_POWER;
    } else {
        // 250 ms actually
        mode = AdvertiseSettings.ADVERTISE_MODE_BALANCED;
    }

    if (mode != getModifiedOrOriginalBeacon().getAdvertiseMode()) {
        // restarting a beacon destroys the GATT connection, make sure we use a stopped clone
        getOrCloneConfiguredBeacon().edit().setAdvertiseMode(mode).apply();
    }

    return getAdvertiseInterval();
}
项目:SweetBlue    文件:NativeUtil.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static void setToAdvertising(BleManager mgr, final AdvertiseSettings settings, L_Util.AdvertisingCallback callback, Interval delay)
{
    if (Utils.isLollipop())
    {
        L_UtilBridge.setAdvListener(callback);
        mgr.getPostManager().postToUpdateThreadDelayed(new Runnable()
        {
            @Override
            public void run()
            {
                L_Util.getNativeAdvertisingCallback().onStartSuccess(settings);
            }
        }, delay.millis());
    }
}
项目:IBeaconBroadcastDemo    文件:MainActivity.java   
public AdvertiseSettings createAdvertiseSettings(boolean connectable, int timeoutMillis) {
    AdvertiseSettings.Builder builder = new AdvertiseSettings.Builder();
    builder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED);
    builder.setConnectable(connectable);
    builder.setTimeout(timeoutMillis);
    builder.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH);
    return builder.build();
}
项目:IBeaconBroadcastDemo    文件:MainActivity.java   
public void onStartSuccess(android.bluetooth.le.AdvertiseSettings settingsInEffect) {
    if (settingsInEffect != null) {
        Log.d("debug", "onStartSuccess TxPowerLv="
                + settingsInEffect.getTxPowerLevel()
                + " mode=" + settingsInEffect.getMode()
                + " timeout=" + settingsInEffect.getTimeout());
    } else {
        Log.d("debug", "onStartSuccess, settingInEffect is null");
    }
    switchView.setChecked(true);
    setProgressBarIndeterminateVisibility(false);
}
项目:mobly-bundled-snippets    文件:JsonSerializer.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Bundle serializeBleAdvertisingSettings(AdvertiseSettings advertiseSettings) {
    Bundle result = new Bundle();
    result.putString(
            "TxPowerLevel",
            MbsEnums.BLE_ADVERTISE_TX_POWER.getString(advertiseSettings.getTxPowerLevel()));
    result.putString(
            "Mode", MbsEnums.BLE_ADVERTISE_MODE.getString(advertiseSettings.getMode()));
    result.putInt("Timeout", advertiseSettings.getTimeout());
    result.putBoolean("IsConnectable", advertiseSettings.isConnectable());
    return result;
}
项目:mobly-bundled-snippets    文件:MbsEnums.java   
private static RpcEnum buildBleAdvertiseTxPowerEnum() {
    RpcEnum.Builder builder = new RpcEnum.Builder();
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return builder.build();
    }
    return builder.add(
                    "ADVERTISE_TX_POWER_ULTRA_LOW",
                    AdvertiseSettings.ADVERTISE_TX_POWER_ULTRA_LOW)
            .add("ADVERTISE_TX_POWER_LOW", AdvertiseSettings.ADVERTISE_TX_POWER_LOW)
            .add("ADVERTISE_TX_POWER_MEDIUM", AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM)
            .add("ADVERTISE_TX_POWER_HIGH", AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)
            .build();
}
项目:mobly-bundled-snippets    文件:MbsEnums.java   
private static RpcEnum buildBleAdvertiseModeEnum() {
    RpcEnum.Builder builder = new RpcEnum.Builder();
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return builder.build();
    }
    return builder.add("ADVERTISE_MODE_BALANCED", AdvertiseSettings.ADVERTISE_MODE_BALANCED)
            .add("ADVERTISE_MODE_LOW_LATENCY", AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
            .add("ADVERTISE_MODE_LOW_POWER", AdvertiseSettings.ADVERTISE_MODE_LOW_POWER)
            .build();
}
项目:mobly-bundled-snippets    文件:BluetoothLeAdvertiserSnippet.java   
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
    Log.e("Bluetooth LE advertising started with settings: " + settingsInEffect.toString());
    SnippetEvent event = new SnippetEvent(mCallbackId, "onStartSuccess");
    Bundle advertiseSettings =
            JsonSerializer.serializeBleAdvertisingSettings(settingsInEffect);
    event.getData().putBundle("SettingsInEffect", advertiseSettings);
    sEventCache.postEvent(event);
}
项目:react-native-ibeacon-simulator    文件:BeaconBroadcast.java   
@ReactMethod
public void startSharedAdvertisingBeaconWithString(String uuid, int major, int minor,String identifier) {
int manufacturer = 0x4C;
Beacon beacon = new Beacon.Builder()
        .setId1(uuid)
        .setId2(String.valueOf(major))
        .setId3(String.valueOf(minor))
        .setManufacturer(manufacturer)
        .setBluetoothName(identifier)
        .setTxPower(-59)
        .build();
BeaconParser beaconParser = new BeaconParser()
        .setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24");
this.beaconTransmitter = new BeaconTransmitter(context, beaconParser);
this.beaconTransmitter.startAdvertising(beacon, new AdvertiseCallback() {

    @Override
    public void onStartFailure(int errorCode) {
        Log.d("ReactNative", "Error from start advertising " + errorCode);
    }

    @Override
    public void onStartSuccess(AdvertiseSettings settingsInEffect) {
        Log.d("ReactNative", "Success start advertising");
    }
});
}
项目:noise    文件:BluetoothSyncService.java   
private AdvertiseSettings buildAdvertiseSettings() {
    AdvertiseSettings.Builder builder = new AdvertiseSettings.Builder();
    builder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_POWER);
    builder.setTimeout(0); // Advertise as long as Bluetooth is on, blatantly ignoring Google's advice.
    builder.setConnectable(false);
    return builder.build();
}
项目:BLE-HID-Peripheral-for-Android    文件:HidPeripheral.java   
/**
 * Starts advertising
 */
public final void startAdvertising() {
    handler.post(new Runnable() {
        @Override
        public void run() {
            // set up advertising setting
            final AdvertiseSettings advertiseSettings = new AdvertiseSettings.Builder()
                    .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)
                    .setConnectable(true)
                    .setTimeout(0)
                    .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
                    .build();

            // set up advertising data
            final AdvertiseData advertiseData = new Builder()
                    .setIncludeTxPowerLevel(false)
                    .setIncludeDeviceName(true)
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_DEVICE_INFORMATION.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BLE_HID.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BATTERY.toString()))
                    .build();

            // set up scan result
            final AdvertiseData scanResult = new Builder()
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_DEVICE_INFORMATION.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BLE_HID.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BATTERY.toString()))
                    .build();

            Log.d(TAG, "advertiseData: " + advertiseData + ", scanResult: " + scanResult);
            bluetoothLeAdvertiser.startAdvertising(advertiseSettings, advertiseData, scanResult, advertiseCallback);
        }
    });
}
项目:mesh-core-on-android    文件:JniCallbacks.java   
private AdvertiseSettings createAdvSettings(boolean connectable, int timeoutMillis) {
AdvertiseSettings.Builder mSettingsbuilder = new AdvertiseSettings.Builder();
mSettingsbuilder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED);
mSettingsbuilder.setConnectable(connectable);
mSettingsbuilder.setTimeout(timeoutMillis);
mSettingsbuilder.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH);
AdvertiseSettings mAdvertiseSettings = mSettingsbuilder.build();
if(mAdvertiseSettings == null){
    if(D){
        Log.e(TAG,"mAdvertiseSettings == null");
    }
}
return mAdvertiseSettings;
}
项目:mesh-core-on-android    文件:JniCallbacks.java   
@Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
    super.onStartSuccess(settingsInEffect);
    if (settingsInEffect == null) {
        Log.e(TAG, "onStartSuccess, settingInEffect is null");
    }
}
项目:coinblesk-client-gui    文件:BluetoothLEServer.java   
private void startAdvertisingService(final UUID uuid) {
    if (bluetoothLeAdvertiseCallbacks == null) {
        bluetoothLeAdvertiseCallbacks = new ArrayList<>();
    }

    AdvertiseCallback advertiseCallback = new AdvertiseCallback() {
        @Override
        public void onStartSuccess(AdvertiseSettings settingsInEffect) {
            Log.d(TAG, "BLE advertising - uuid: " + uuid.toString()
                    + " - onStartSuccess - settings: " + settingsInEffect.toString());
        }

        @Override
        public void onStartFailure(int errorCode) {
            Log.w(TAG, "BLE advertising - uuid: " + uuid.toString()
                    + " - onStartFailure - errorCode=" + errorCode);
        }
    };
    bluetoothLeAdvertiseCallbacks.add(advertiseCallback);

    bluetoothAdapter.getBluetoothLeAdvertiser().startAdvertising(
            new AdvertiseSettings.Builder()
                    .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
                    .setConnectable(true)
                    .setTimeout(0)
                    .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)
                    .build(),
            new AdvertiseData.Builder()
                    .setIncludeDeviceName(false)
                    .addServiceUuid(new ParcelUuid(uuid))
                    .build(),
            advertiseCallback
    );
}
项目:AsteroidOSSync    文件:P_Task_Advertise.java   
@Override
public void onStartSuccess(AdvertiseSettings settingsInEffect)
{
    getLogger().d("Advertising started successfully.");
    getServer().invokeAdvertiseListeners(BleServer.AdvertisingListener.Status.SUCCESS, m_listener);
    succeed();
}
项目:AsteroidOSSync    文件:BleAdvertisingPacket.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
/*package*/ AdvertiseSettings getNativeSettings(BleAdvertisingMode mode, BleTransmissionPower power, Interval timeout) {
    AdvertiseSettings.Builder settings = new AdvertiseSettings.Builder();
    settings.setAdvertiseMode(mode.getNativeMode());
    settings.setTxPowerLevel(power.getNativeMode());
    settings.setConnectable(isConnectable());
    settings.setTimeout((int) timeout.millis());
    return settings.build();
}
项目:AsteroidOSSync    文件:P_AndroidBluetoothManager.java   
@Override
public final void startAdvertising(AdvertiseSettings settings, AdvertiseData adData, AdvertiseCallback callback)
{
    final BluetoothLeAdvertiser ad = L_Util.getBluetoothLeAdvertiser(m_adaptor);
    if (ad != null)
    {
        ad.startAdvertising(settings, adData, callback);
    }
    else
    {
        m_bleManager.getLogger().e("Tried to start advertising, but the BluetoothLeAdvertiser was null!");
    }
}
项目:BLE-Mesh    文件:BLEPeripheral.java   
@Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
    if (settingsInEffect != null) {
        Timber.d("Advertise success TxPowerLv="
                + settingsInEffect.getTxPowerLevel()
                + " mode=" + settingsInEffect.getMode());
    } else {
        Timber.d("Advertise success");
    }
}
项目:BLE-Mesh    文件:BLEPeripheral.java   
private AdvertiseSettings createAdvSettings() {
    AdvertiseSettings.Builder builder = new AdvertiseSettings.Builder();
    builder.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH);
    builder.setConnectable(true);
    builder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED);
    return builder.build();
}
项目:beacons-android    文件:Advertiser.java   
public Advertiser(SettingsProvider provider) {
        mAdvertiseSettings = new AdvertiseSettings.Builder()
                .setAdvertiseMode(provider.getAdvertiseMode())
                .setTxPowerLevel(provider.getTxPowerLevel())
                .setConnectable(provider.isConnectable())
                // oups! https://code.google.com/p/android/issues/detail?id=232219
//                .setTimeout(provider.getTimeout())
                .build();
    }
项目:beacons-android    文件:Advertiser.java   
@Override
public void onStartSuccess(AdvertiseSettings settingsInEffect) {
    mStatus = STATUS_RUNNING;
    mSettingsInEffect = settingsInEffect;

    // on start or restart, rebase the clock time used for PDU count estimation
    mLastPDUUpdateTime = SystemClock.elapsedRealtime();

    if (null != mAdvertisersManager) {
        mAdvertisersManager.onAdvertiserStarted(this);
    }
}
项目:beacons-android    文件:EddystoneGattConfigurator.java   
@Override
public int getAdvertiseInterval() {
    switch (getModifiedOrOriginalBeacon().getAdvertiseMode()) {
        case AdvertiseSettings.ADVERTISE_MODE_LOW_POWER:
        default:
            return 1000;
        case AdvertiseSettings.ADVERTISE_MODE_BALANCED:
            return 250;
        case AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY:
            return 100;
    }
}
项目:uriio-android    文件:Uriio.java   
/**
 * Creates an UriioBeacon beacon based on the provided URL registration result.
 * @param urlResource         URL registration info
 * @param beaconTimeToLive    Initial value for the beacon's TTL for issuing ephemeral short URLs.
 * @return A new beaoon, without saving or starting it. You can adjust any other beacon properties and save it.
 */
@NonNull
public static UriioBeacon createBeacon(UrlResource urlResource, int beaconTimeToLive) {
    return new UriioBeacon(urlResource.getId(), urlResource.getToken(),
            beaconTimeToLive, urlResource.getUrl(),
            AdvertiseSettings.ADVERTISE_MODE_BALANCED,
            AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM);
}
项目:DeviceConnect-Android    文件:AbstractHOGPServer.java   
/**
 * アドバタイジングを開始します.
 */
private void startAdvertising() {
    if (DEBUG) {
        Log.d(TAG, "startAdvertising");
    }

    mHandler.post(new Runnable() {
        @Override
        public void run() {
            // set up advertising setting
            final AdvertiseSettings advertiseSettings = new AdvertiseSettings.Builder()
                    .setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH)
                    .setConnectable(true)
                    .setTimeout(0)
                    .setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_LOW_LATENCY)
                    .build();

            // set up advertising data
            final AdvertiseData advertiseData = new AdvertiseData.Builder()
                    .setIncludeTxPowerLevel(false)
                    .setIncludeDeviceName(true)
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_DEVICE_INFORMATION.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BLE_HID.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BATTERY.toString()))
                    .build();

            // set up scan result
            final AdvertiseData scanResult = new AdvertiseData.Builder()
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_DEVICE_INFORMATION.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BLE_HID.toString()))
                    .addServiceUuid(ParcelUuid.fromString(SERVICE_BATTERY.toString()))
                    .build();

            mBluetoothLeAdvertiser.startAdvertising(advertiseSettings, advertiseData, scanResult, mAdvertiseCallback);
        }
    });
}
项目:ble-android-sdk    文件:LBleAdvertiser.java   
@Override
public void startAdvertising(String uuid, List<ScanResult> closestBeaconId, String fallbackUrl) {
    stopAdvertising();
    advertiser.startAdvertising(
            new AdvertiseSettings.Builder().setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED).build(),
            new AdvertiseData.Builder().addServiceUuid(ParcelUuid.fromString(uuid)).build(),
            callback
    );
}
项目:Scatterbrain    文件:BleUtil.java   
public static AdvertiseSettings createAdvSettings(int timeoutMillis) {
    AdvertiseSettings.Builder builder = new AdvertiseSettings.Builder();
    builder.setAdvertiseMode(AdvertiseSettings.ADVERTISE_MODE_BALANCED);
    builder.setConnectable(true);
    builder.setTimeout(timeoutMillis);
    builder.setTxPowerLevel(AdvertiseSettings.ADVERTISE_TX_POWER_HIGH);
    return builder.build();
}
项目:SweetBlue    文件:L_Util.java   
@Override
public void onStartSuccess(AdvertiseSettings settingsInEffect)
{
    if (m_userAdvCallback != null)
    {
        m_userAdvCallback.onStartSuccess(fromNativeSettings(settingsInEffect));
    }
}
项目:SweetBlue    文件:L_Util.java   
public static boolean startAdvertising(BluetoothAdapter adapter, AdvertiseSettings settings, AdvertiseData adData, AdvertisingCallback callback)
{
    final BluetoothLeAdvertiser adv = adapter.getBluetoothLeAdvertiser();
    if (adv == null)
        return false;

    m_userAdvCallback = callback;
    adv.startAdvertising(settings, adData, m_nativeAdvertiseCallback);
    return true;
}
项目:SweetBlue    文件:BleAdvertisingPacket.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
/*package*/ AdvertiseSettings getNativeSettings(BleAdvertisingMode mode, BleTransmissionPower power, Interval timeout) {
    AdvertiseSettings.Builder settings = new AdvertiseSettings.Builder();
    settings.setAdvertiseMode(mode.getNativeMode());
    settings.setTxPowerLevel(power.getNativeMode());
    settings.setConnectable(isConnectable());
    settings.setTimeout((int) timeout.millis());
    return settings.build();
}