Java 类android.bluetooth.le.BluetoothLeAdvertiser 实例源码
项目:beacons-android
文件:Advertiser.java
/**
* Attempt to start BLE advertising.
* @param bleAdvertiser BLE advertiser
* @return True if no exception occurred while trying to start advertising.
*/
boolean start(BluetoothLeAdvertiser bleAdvertiser) {
try {
bleAdvertiser.startAdvertising(getAdvertiseSettings(), getAdvertiseData(),
getAdvertiseScanResponse(), this);
} catch (IllegalStateException e) {
// tried to start advertising after Bluetooth was turned off
// let upper level notice that BT is off instead of reporting an error
if (BuildConfig.DEBUG) {
Log.e(TAG, "start", e);
}
return false;
}
return true;
}
项目: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!");
}
}
项目:AsteroidOSSync
文件:P_AndroidBluetoothManager.java
@Override
public final void stopAdvertising(AdvertiseCallback callback)
{
final BluetoothLeAdvertiser ad = L_Util.getBluetoothLeAdvertiser(m_adaptor);
if (ad != null)
{
ad.stopAdvertising(callback);
}
else
{
m_bleManager.getLogger().e("Tried to stop advertising, but the BluetoothLeAdvertiser was null!");
}
}
项目:beacons-android
文件:Advertiser.java
/**
* Mark the advertiser as stopped and attempt to actually stop BLE advertisements.
* @param bleAdvertiser BLE advertiser, or null
* @return True if there was no error while trying to stop the Bluetooth advertiser.
*/
boolean stop(BluetoothLeAdvertiser bleAdvertiser) {
updateEstimatedPDUCount();
mStatus = STATUS_STOPPED;
if (null != bleAdvertiser) {
bleAdvertiser.stopAdvertising(this);
}
return true;
}
项目:swan-sense-studio
文件:BLEManager.java
private void advertise() throws ExpressionParseException {
final BluetoothLeAdvertiser bleAdvertiser = btAdapter.getBluetoothLeAdvertiser();
AdvertiseData.Builder dataBuilder = new AdvertiseData.Builder().setIncludeDeviceName(true);
for(Map.Entry<String, String> expressionEntry : registeredExpressions.entrySet()) {
SensorValueExpression svExpression = (SensorValueExpression) ExpressionFactory.parse(expressionEntry.getValue());
String sensorValuePath = svExpression.getEntity() + ":" + svExpression.getValuePath();
UUID serviceUuid = getUuidForSensorValuePath(sensorValuePath);
dataBuilder.addServiceUuid(new ParcelUuid(serviceUuid));
}
bleAdvertiser.startAdvertising(advertiseSettings, dataBuilder.build(), advertisingCallback);
}
项目: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
文件:L_Util.java
public static void stopAdvertising(BluetoothAdapter adapter)
{
if (adapter != null)
{
final BluetoothLeAdvertiser adv = adapter.getBluetoothLeAdvertiser();
if (adv != null)
{
adv.stopAdvertising(m_nativeAdvertiseCallback);
}
}
}
项目:BLEServerSimple
文件:AdvertiseAdaptor.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private BluetoothLeAdvertiser getAdvertiser(BluetoothAdapter adapter) {
return adapter.getBluetoothLeAdvertiser();
}
项目:AsteroidOSSync
文件:L_Util.java
public static BluetoothLeAdvertiser getBluetoothLeAdvertiser(BluetoothAdapter adapter)
{
return adapter.getBluetoothLeAdvertiser();
}
项目:SweetBlue
文件:L_Util.java
public static BluetoothLeAdvertiser getBluetoothLeAdvertiser(BluetoothAdapter adapter)
{
return adapter.getBluetoothLeAdvertiser();
}