The BGXDevice class is used to represent the BGX device.
More...
The BGXDevice class is used to represent the BGX device.
It contains a group of properties as well as methods used to perform appropriate actions on a BGXDevice.
Supports two delegates, deviceDelegate and serialDelegate, as well as KVO.
◆ BGXSerialDelegate-p
protocol BGXSerialDelegate-p |
BGXSerialDelegate protocol.
The BGXSerialDelegate is used to perform serial read/write operations with the BGX.
◆ busModeChanged:forDevice:()
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:forDevice:()
- (void) dataRead: |
|
(NSData *) |
newData |
forDevice: |
|
(BGXDevice *) |
device |
|
|
| |
|
required |
Delegate method is called when data is received.
- Parameters
-
◆ dataWrittenForDevice:()
- (void) dataWrittenForDevice: |
|
(BGXDevice *) |
device |
|
|
required |
Delegate method used to advise that the data has been written.
◆ BGXDeviceDelegate-p
protocol BGXDeviceDelegate-p |
BGXDeviceDelegate protocol is used to be notified of state changes and device-level events.
◆ connectionTimeoutForDevice:()
- (void) connectionTimeoutForDevice: |
|
(BGXDevice *) |
device |
|
|
optional |
The device was connecting but the connection operation failed to finish within the timeout period.
The device is probably disconnected as a result.
- Parameters
-
device | The device whose connection timed out. |
◆ stateChangedForDevice:()
- (void) stateChangedForDevice: |
|
(BGXDevice *) |
device |
|
|
optional |
The value of the deviceState variable changed.
This could mean that the device connected, disconnected, and so on. The typical flow is: Connect operation: Disconnected -> Connecting -> Interrogating -> Connected.
Disconnect operation: Connected -> Disconnecting -> Disconnected
- Parameters
-
device | The device whose state changed. |
◆ rssiChangedForDevice:()
- (void) rssiChangedForDevice: |
|
(BGXDevice *) |
device |
|
|
optional |
The RSSI value changed for the device.
- Parameters
-
device | The device for which the RSSI changed. |
◆ BGXDevice
Inherits NSObject, and <CBPeripheralDelegate>.
◆ connect()
Method to connect to the device.
Operation happens asynchronously. Observe the deviceState property to determine the outcome of the operation.
- Returns
- BOOL value to indicate if the connection operation started successfully.
◆ disconnect()
Method to disconnect to the device.
Operation happens asynchronously. Observe the deviceState property to determine the outcome of the operation.
- Returns
- BOOL value to indicate if the disconnection operation started successfully.
◆ readBusMode()
Method used to read the BusMode for a device e.g., Stream, Local or Remote commands.
This operation occurs asynchronously. Observe the changes to the busMode property.
- Returns
- BOOL value, YES to indicate that the read operation could be initiated. NO if the read operation could not be started.
◆ writeBusMode:()
- (BOOL) writeBusMode: |
|
(BusMode) |
newBusMode |
|
Deprecated Use writeBusMode: password: completionHandler: instead.
Method used to write new bus mode for device. Operation occurs asynchronously.
- Parameters
-
newBusMode | The new BusMode for the device |
- Returns
- BOOL value, YES if BusMode write operation could be started.
◆ writeBusMode:password:completionHandler:()
Method used to write new bus mode for device.
Operation occurs asynchronously. You may get an error if the password you pass is wrong.
- Parameters
-
newBusMode | The new BusMode for the device |
password | The password for the bus mode characteristic. Pass nil for no password. |
completionHandler | This will be called when the operation completes. You will get an error as a parameter to the completionHandler if the password is wrong or if you pass nil when a password is required. |
◆ canWrite()
Method to see if you can write to the device.
- Returns
- BOOL value, YES if device is connected and no data waiting to be written to the device, else NO.
◆ writeData:()
- (BOOL) writeData: |
|
(NSData *) |
data |
|
Method used to write data to a device.
- Parameters
-
data | Data to be written to device. |
- Returns
- BOOL 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 written to device. |
- Returns
- BOOL 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
- BOOL value advising if the command has been written to the device or not.
◆ device_unique_id()
- (nullable NSString *) device_unique_id |
|
|
|
Returns the device unique id.
- Returns
- NSString with the unique id of the device. Nil on error.
◆ nameForDeviceState:()
Printable name for a device state value.
◆ peripheral()
- (CBPeripheral *) peripheral |
|
|
|
Access to the CBPeripheral.
◆ _deviceState
◆ _busMode
◆ _writeWithResponse
- (BOOL) _writeWithResponse |
|
protected |
◆ deviceDelegate
◆ serialDelegate
◆ name
◆ rssi
◆ identifier
◆ deviceState
◆ busMode
◆ modelNumber
- (NSString*) modelNumber |
|
readwritenonatomicstrong |
◆ firmwareRevision
- (NSString*) firmwareRevision |
|
readwritenonatomicstrong |
◆ bootloaderVersion
- (NSString*) bootloaderVersion |
|
readwritenonatomicstrong |
◆ fastAck
YES = The device supports fastAck and will operate in fastAck mode.
NO = The device does not support fastAck and will operate in legacy mode.
◆ writeWithResponse
- (BOOL) writeWithResponse |
|
readwritenonatomicassign |
YES = Writes occur using CBCharacteristicWriteWithResponse NO = Writes occur using CBCharacteristicWriteWithoutResponse = YES.
Note: If the device supports fastAck, writeWithoutResponse will always be used.
◆ busmode_write_completion_handler_t
typedef void(^ busmode_write_completion_handler_t) (BGXDevice *, NSError *err) |
◆ DeviceState
DeviceState values.
Enumerator |
---|
Interrogating | The BGXDevice has connected and Bluetooth services and characteristics are being discovered.
|
Disconnected | The BGXDevice is not connected (to this iOS device).
|
Connecting | The BGXDevice is in the process of connecting.
|
Connected | The BGXDevice is connected.
|
Disconnecting | The BGXDevice is in the process of disconnecting.
|
◆ BusMode
Values of the bus mode.
Enumerator |
---|
UNKNOWN_MODE | an invalid mode used to indicate that the
mode has not been determined
|
STREAM_MODE | send and receive serial data to the device to
which the BGX is connected
|
LOCAL_COMMAND_MODE | data received over the serial lines is
processed as a command by the BGX and results returned over the serial lines
|
REMOTE_COMMAND_MODE | data received over Bluetooth is processed as
a command by the BGX and results returned over Bluetooth
|
UNSUPPORTED_MODE | an invalid mode state
|