Skip to content
A higher abstraction level .NET library for Silicon Labs/Bluegiga BLE112 modules
C#
Branch: master
Clone or download
Pull request Compare This branch is 6 commits ahead of jedinja:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
BGLibExt.Samples.DeviceDiscovery
BGLibExt.Samples.FlowerCareSmartMonitor
BGLibExt.Samples.MiTemperatureHumidityMonitor
BGLibExt Updated samples Oct 4, 2019
BGLibExtTest Refactored almost all existing code Sep 13, 2019
.gitignore
BGLibExt.sln
LICENSE
README.md

README.md

BGLibExt

A higher abstraction level .NET library for Silicon Labs/Bluegiga BLE112 modules.

This library is based on work by jedinja/monomyo and jrowberg/bglib. The BGLib was left as it was and the higher level abstraction code from jedinja/monomyo was refactored to be used as a library and some BLE advertisement related features have been added. So thanks goes out to them since they did most of the work.

Installation

Install nuget package BGLibExt

Usage

Discover devices

var ble = new BleConnector("COM1");
ble.ScanResponse += OnDiscoverDevices;
ble.StartDeviceDiscovery();
Task.Delay(5000).Wait();
ble.StopDeviceDiscovery();
ble.ScanResponse -= OnDiscoverDevices;

private void OnDiscoverDevices(object sender, BleScanResponseReceivedEventArgs args)
{
}

Connect to device

var ble = new BleConnector("COM1");
var peripheralMap = ble.Connect(address, addressType);

Disconnect from device

var ble = new BleConnector("COM1");
var peripheralMap = ble.Connect(address, addressType);
ble.Disconnect();

Read characteristic

var ble = new BleConnector("COM1");
var peripheralMap = ble.Connect(address, addressType);
var data = ble.ReadCharacteristic(characteristicId, false);

Write characteristic

var ble = new BleConnector("COM1");
var peripheralMap = ble.Connect(address, addressType);
ble.WriteCharacteristic(characteristicId, false);

Characteristic notifications

var ble = new BleConnector("COM1");
var peripheralMap = ble.Connect(address, addressType);
// Validate peripheralMap
// Get uuid of characteristic for enabling notifications
ble.WriteClientCharacteristicConfiguration(uuid, BleCCCValue.NotificationsEnabled);
ble.CharacteristicValueChanged += OnValueChanged;

private void OnValueChanged(object sender, BleCharacteristicValueChangedEventArgs e)
{
}
You can’t perform that action at this time.