• Mobile
  • Extensions
  • Releases
  • GitHub
  • Blog
  • Sponsor
Show / Hide Table of Contents
  • Home
  • Quick Start
  • Setup
    • Dependency Injection
    • Startup
    • Static Instances
    • iOS
    • Android
  • Configuration Extensions
  • Jobs
    • Setup
    • Create a Job
    • Querying, Cancelling, and Adhoc
    • Frequently Asked Questions
  • Bluetooth LE Client
    • Setup
    • Scanning
    • Peripheral
    • Best Practices
    • Manged Scanning
    • Managed Peripheral
  • Bluetooth LE Hosting
    • Setup
    • GATT
    • Advertising
  • Geofencing
  • GPS
    • Setup
  • Motion Activity
  • Local Notifications
    • Getting Started
    • Channels
  • Push Notifications
    • Getting Started
    • Native
    • Azure Notification Hubs
    • Firebase Messaging
    • One Signal
  • Beacons
    • Ranging
    • Monitoring (Background)
  • HTTP Transfers
    • Getting Started
    • Advanced
  • Framework
    • Getting Started
    • ViewModel
  • Sensors
    • Getting Started
    • Accelerometer
    • Ambient Light
    • Barometer
    • Compass
    • Gyroscope
    • Humidity
    • Magnetometer
    • Pedometer
    • Proximity
    • Temperature

Title: BLE Manager

Order: 2

BleManager

The adapter is where everything begins and ends. Unlike the platform implementations of the adapter scan, the BLE plugin Scan() method will scan continuously (or restart the scan when the cycle completes) until you dispose of the Scan() token.

General

Monitor and read status of adapter

// current status
BleManager.Status

// monitor status changes
BleManager.WhenStatusChanged().Subscribe(status => {});

Scan for Devices

var scanner = CrossBleAdapter.Current.Scan().Subscribe(scanResult => 
{
    // do something with it
    // the scanresult contains the device, RSSI, and advertisement packet

});

scanner.Dispose(); // to stop scanning

Scan for Devices - Advanced

CrossBleAdapter.Current.Scan(
    new ScanConfig 
    {
        ServiceUuids = { new Guid("<your guid here>") }
    }
)
.Subscribe(scanResult => 
{
})

General Scan

var scan = CentralManager.Scan().Subscribe(scanResult => {});

// to stop scan 
scan.Dispose();

Specific Scans

Find a named peripheral

// this will return a single result and complete - you can await it if you want
var peripheral = CentralManager.ScanForPeripheral("YourDevice");

var peripheral = CentralManager.ScanForPeripheral(YourDevice);

Change Adapter State (Power on/off)

Supported by Android only

if (CrossBleAdapter.Current.CanChangeAdapterState)
    CrossBleAdapter.Current.SetAdapterState(true); // or false to disable

Get Connected Devices

var devices = CrossBleAdapter.Current.GetConnectedDevices();
foreach (var device in devices)
{
    // do something
}

Extensions

// this essentially recreates the scan cycles like on Android
CrossBleAdapter.Current.ScanInterval(TimeSpan).Subscribe(scanResult => {});

Toggle State of Adapter

// returns true if successful
CrossBleAdapter.Current.ToggleAdapterState();
  • Improve this Doc
In This Article
Back to top Generated by DocFX