BGX Framework
The Silicon Labs BGX device provides a bridge between Bluetooth Low Energy (BLE) and Serial communication. More...
Classes |
|
protocol | <BGXpressDelegate > |
Delegate class for the
BGXpressManager
object.
More...
|
|
class | BGXpressManager |
This class is used to interact with a BGX device.
More...
|
|
Enumerations |
|
enum |
ConnectionState
{
DISCONNECTED , SCANNING , CONNECTING , INTERROGATING , CONNECTED , DISCONNECTING , CONNECTIONTIMEDOUT } |
Possible values for the connection state of the
BGXpressManager
.
More...
|
|
enum |
BusMode
{
UNKNOWN_MODE , STREAM_MODE , LOCAL_COMMAND_MODE , REMOTE_COMMAND_MODE , UNSUPPORTED_MODE } |
Values of the bus mode.
More...
|
|
Variables |
|
NSErrorDomain | NSBGXErrorDomain |
The NSBGXErrorDomain is used as an error domain for NSError objects passed by BGXpress.framework.
More...
|
|
Detailed Description
The Silicon Labs BGX device provides a bridge between Bluetooth Low Energy (BLE) and Serial communication.
BGXpress.framework makes it easier to write an iOS app that interacts with BGX. It supports discovery of BGX devices, connecting and disconnecting, setting and detecting the bus mode of the BGX, sending and receiving data, and OTA (Over The Air) Firmware Updates of the BGX accessed through the Silicon Labs DMS (Device Management Service).
- Remarks
- BGXpress.framework is designed for use with iOS.
- BGXpress.framework is currently designed for connecting to one BGX at a time.
Class Documentation
◆ BGXpressDelegate
protocol BGXpressDelegate |
Delegate class for the BGXpressManager object.
Your application should supply an object conforming to the BGXpressDelegate protocol which has a lifecycle similar to the instance of
BGXpressManager
you create. The BGXCommander example app uses the AppDelegate for this purpose. The various methods in this protocol are called in order to indicate changes to the Bluetooth state, ConnectionState, BusMode, when devices are discovered, when data is read or data is written.
Inherits <NSObject>.
Instance Methods |
|
(void) | - connectionStateChanged: |
Detect connection state changes.
More...
|
|
(void) | - busModeChanged: |
Detect bus mode changes.
More...
|
|
(void) | - dataRead: |
Delegate method is called when data is received.
More...
|
|
(void) | - dataWritten |
Delegate method used to advise that the data has been written.
More...
|
|
(void) | - deviceDiscovered |
Delegate method called when a device is discovered.
More...
|
|
(void) | - bluetoothStateChanged: |
Notify application about bluetooth state changes.
More...
|
|
Method Documentation
◆ connectionStateChanged:()
|
required |
Detect connection state changes.
Delegate method advising when the connection state has changed and the new connection state
- Parameters
-
newConnectionState
ConnectionState of the current connection
◆ busModeChanged:()
|
required |
Detect bus mode changes.
Delegate method called when the bus mode changes or is read. If you call the BGXpressManager method -(BOOL)readBusMode, this delegate will be called with the bus mode that was read whether or not it was different than the previous bus mode.
- Parameters
-
newBusMode
the new bus mode for the connection
◆ dataRead:()
|
required |
Delegate method is called when data is received.
- Parameters
-
newData
updated values
◆ dataWritten()
|
required |
Delegate method used to advise that the data has been written.
◆ deviceDiscovered()
|
required |
Delegate method called when a device is discovered.
Check the devicesDiscovered property of BGXpressManager for the list of device that have been discovered.
◆ bluetoothStateChanged:()
|
optional |
Notify application about bluetooth state changes.
Passes the notifications from the CBManager through so that the calling app will know when to start/stop scanning (you get an error when you start scanning before you we get the bluetooth state change notification saying that bluetooth is on which seems like a flaw in the design of this API).
- Parameters
-
state
The state of the CBManager which in theory the calling application shouldn't have to know about.
◆ BGXpressManager
class BGXpressManager |
This class is used to interact with a BGX device.
Create one of these objects in your application and store it in a place where it will be retained while your application is running. The BGXCommander example app uses the AppDelegate class to store an instance of the BGXpressManager class. Your app should do this or something that is equivalent. We recommend against storing it as a property of a UIViewController instance because view controllers may be created and destroyed during the lifecycle of your app.
- Remarks
- Most of the methods of this class are asynchronous. To determine that an operation has occurred, rely on the BGXpressDelegate.
- Operations may fail because of an incompatible state of this object (e.g. connectToDevice:), or the state of the Bluetooth hardware (e.g. startScan).
Inherits NSObject, <CBCentralManagerDelegate>, and <CBPeripheralDelegate>.
Instance Methods |
|
(BOOL) | - startScan |
Call this method to start scanning for devices.
More...
|
|
(BOOL) | - stopScan |
Call this method to stop scanning for devices.
More...
|
|
(BOOL) | - connectToDevice: |
Method to connect to a device.
More...
|
|
(BOOL) | - disconnect |
Method used to disconnect from a device.
More...
|
|
(BOOL) | - readBusMode |
Method used to read the BusMode for a device eg Stream, Local or Remote commands.
More...
|
|
(BOOL) | - writeBusMode: |
Method used to write new bus mode for device.
More...
|
|
(BOOL) | - canWrite |
Method to see if you can write to the device.
More...
|
|
(BOOL) | - writeData: |
Method used to write data to a device.
More...
|
|
(BOOL) | - writeString: |
Method used to write a string to device.
More...
|
|
(BOOL) | - sendCommand:args: |
Method used to send commands to the device.
More...
|
|
(NSString *) | - device_unique_id |
Returns the device unique id.
More...
|
|
Class Methods |
|
(NSString *) | + uniqueIDForPeripheral: |
Get the unique ID for the specified peripheral.
More...
|
|
Properties |
|
id< BGXpressDelegate > | delegate |
NSString * | modelNumber |
NSMutableArray * | devicesDiscovered |
ConnectionState | connectionState |
BusMode | busMode |
Method Documentation
◆ startScan()
- (BOOL) startScan |
|
Call this method to start scanning for devices.
- Returns
- Boolean value to indicate if scanning will start.
- Remarks
- Calling this method will clear the contents of the devicesDiscovered mutable array property.
◆ stopScan()
- (BOOL) stopScan |
|
Call this method to stop scanning for devices.
- Returns
- Boolean value to indicate if scanning will stop.
◆ connectToDevice:()
- (BOOL) connectToDevice: | (NSString *) |
deviceName
|
Method to connect to a device.
- Parameters
-
deviceName
The name of the device you wish to connect to
- Returns
- Boolean value to indicate if there has been a successful connection to the device
◆ disconnect()
- (BOOL) disconnect |
|
Method used to disconnect from a device.
◆ readBusMode()
- (BOOL) readBusMode |
|
Method used to read the BusMode for a device eg Stream, Local or Remote commands.
- Returns
- Boolean value, FALSE if not connected else TRUE.
◆ writeBusMode:()
- (BOOL) writeBusMode: | ( BusMode ) |
newBusMode
|
Method used to write new bus mode for device.
- Parameters
-
newBusMode
The new BusMode for the device
- Returns
- Boolean value, FALSE if not connected or BusMode not changed. TRUE if BusMode written.
◆ canWrite()
- (BOOL) canWrite |
|
Method to see if you can write to the device.
- Returns
- Boolean value, TRUE if device is connected and no data waiting to be written to the device, else FALSE.
◆ writeData:()
- (BOOL) writeData: | (NSData *) |
data
|
Method used to write data to a device.
- Parameters
-
data
Data to be writted to device.
- Returns
- Boolean value advising if the data has been written to the device or not.
◆ writeString:()
- (BOOL) writeString: | (NSString *) |
string
|
Method used to write a string to device.
- Parameters
-
string
String value to be writted to device.
- Returns
- Boolean value advising if the string has been written to the device or not.
◆ sendCommand:args:()
- (BOOL) sendCommand: | (NSString *) |
command
|
|
args: | (NSString *) |
args
|
|
Method used to send commands to the device.
- Parameters
-
command
Command args
Arguments
- Returns
- Boolean value advising if the command has been written to the device or not.
◆ device_unique_id()
- (NSString *) device_unique_id |
|
Returns the device unique id.
- Returns
- NSString with the unique id of the device. Nil on error.
◆ uniqueIDForPeripheral:()
+ (NSString *) uniqueIDForPeripheral: | (CBPeripheral *) |
peripheral
|
Get the unique ID for the specified peripheral.
- Parameters
-
peripheral
the peripheral to be read.
This call assumes that the services and characteristics have been discovered and that the device id characteristic has already been read once.
- Returns
- NSString with the unique id of the device. Nil on error.
Property Documentation
◆ delegate
|
read write nonatomic weak |
◆ modelNumber
|
read write nonatomic strong |
◆ devicesDiscovered
|
read write nonatomic strong |
◆ connectionState
|
read write nonatomic assign |
◆ busMode
|
read write nonatomic assign |
Enumeration Type Documentation
◆ ConnectionState
enum ConnectionState |
Possible values for the connection state of the BGXpressManager .
Enumerator | |
---|---|
DISCONNECTED |
The BGXpressManager is not connected to any BGX device and is not scanning. |
SCANNING |
The BGXpressManager is scanning for BGX devices. |
CONNECTING |
The BGXpressManager is connecting to a BGX device. |
INTERROGATING |
The BGXpressManager has connected to a BGX device and is discovering bluetooth services and characteristics. |
CONNECTED |
The BGXpressManager is connected to a BGX device. |
DISCONNECTING |
The BGXpressManager is in the process of disconnecting from a BGX device. |
CONNECTIONTIMEDOUT |
A connection that was in progress has timed out. |
◆ BusMode
enum BusMode |
Values of the bus mode.
Variable Documentation
◆ NSBGXErrorDomain
NSErrorDomain NSBGXErrorDomain |
The NSBGXErrorDomain is used as an error domain for NSError objects passed by BGXpress.framework.