MetaWear
public class MetaWear : NSObject
extension MetaWear: CBPeripheralDelegate
extension MetaWear: DFUServiceDelegate
extension MetaWear: LoggerDelegate
Each MetaWear object corresponds a physical MetaWear board. It contains methods for connecting, disconnecting, saving and restoring state.
-
Assign a delegate to receive information about what the device is doing
Declaration
Swift
public var logDelegate: LogDelegate?
-
The corresponding CoreBluetooth object
Declaration
Swift
public let peripheral: CBPeripheral
-
The scanner that disovered this device
Declaration
Swift
public private(set) weak var scanner: MetaWearScanner? { get }
-
This is passed to MetaWearCpp functions
Declaration
Swift
public private(set) var board: OpaquePointer! { get }
-
Data from the advertisement packet This is continually updated when the scanner is active
Declaration
Swift
public var advertisementData: [String : Any] { get }
-
Received signal strength indicator This is continually updated when the scanner is active
Declaration
Swift
public private(set) var rssi: Int { get }
-
Callback block invoked each advertisementData and rssi is updated
Declaration
Swift
public var advertisementReceived: (() -> Void)?
-
MAC address of the device, available only after you have connected once
Declaration
Swift
public internal(set) var mac: String? { get }
-
Details about the device, available only after you have connected once
Declaration
Swift
public internal(set) var info: DeviceInformation? { get }
-
Indication that the BLE link is connected and the MetaWearCpp library is properly initialized
Declaration
Swift
public private(set) var isConnectedAndSetup: Bool { get }
-
Check if this advertised or discovered as a MetaBoot
Declaration
Swift
public private(set) var isMetaBoot: Bool { get }
-
Get the most update to date name of the device
Note
peripheral.name may be cached, use the name from advertising dataDeclaration
Swift
public var name: String { get }
-
Helper utility create a file name specifically for this device
Declaration
Swift
public var uniqueUrl: URL { get }
-
In order to ensure crash free behavior of the MetaWearCpp library, all calls into it should occur from this queue
Declaration
Swift
public var apiAccessQueue: DispatchQueue { get }
-
Bolts-Swift shortcut to apiAccessQueue
Declaration
Swift
public var apiAccessExecutor: Executor { get }
-
Smooth out the RSSI into something less jumpy
Declaration
Swift
public func averageRSSI(lastNSeconds: Double = 5.0) -> Double?
-
Connect to the device and initialize the MetaWearCpp libray
Declaration
Swift
public func connectAndSetup() -> Task<Task<MetaWear>>
Return Value
Task that completes when the device disconnects
-
Disconnect or cancel a connection attempt
Declaration
Swift
public func cancelConnection()
-
Retrieves the current RSSI value for the peripheral while it is connected
Declaration
Swift
public func readRSSI() -> Task<Int>
-
Add this to a persistent list retrieved with
MetaWearScanner.retrieveSavedMetaWearsAsync(...)
Declaration
Swift
public func remember()
-
Remove this from the persistent list
MetaWearScanner.retrieveSavedMetaWearsAsync(...)
Declaration
Swift
public func forget()
-
Dump all MetaWearCpp libray state
Declaration
Swift
public func serialize() -> [UInt8]
-
Restore MetaWearCpp libray state, must be called before
connectAndSetup()
Declaration
Swift
public func deserialize(_ _data: [UInt8])
-
Undocumented
Declaration
Swift
public func readHardwareRev() -> Task<String>
-
Undocumented
Declaration
Swift
public func readModelNumber() -> Task<String>
-
Undocumented
Declaration
Swift
public func readFirmwareRev() -> Task<String>
-
Undocumented
Declaration
Swift
public func readSerialNumber() -> Task<String>
-
Undocumented
Declaration
Swift
public func readManufacturer() -> Task<String>
-
Undocumented
Declaration
Swift
public func getCharacteristic(_ serviceUUID: CBUUID, _ characteristicUUID: CBUUID) -> (error: Error?, characteristic: CBCharacteristic?)
-
Undocumented
Declaration
Swift
public func readCharacteristic(_ serviceUUID: CBUUID, _ characteristicUUID: CBUUID) -> Task<Data>
-
Undocumented
Declaration
Swift
public func clearAndReset()
-
Undocumented
Declaration
Swift
public func macroEndRecord() -> Task<Int32>
-
Undocumented
Declaration
Swift
public func createAnonymousDatasignals() -> Task<[OpaquePointer]>
-
Undocumented
Declaration
Swift
public func timerCreate(period: UInt32, repetitions: UInt16 = 0xFFFF, immediateFire: Bool = false) -> Task<OpaquePointer>
-
Simplify common LED operations with a straightforward interface Use mbl_mw_led_write_pattern for precise control
Declaration
Swift
public func flashLED(color: MBLColor, intensity: CGFloat, _repeat: UInt8 = 0xFF, onTime: UInt16 = 200, period: UInt16 = 800)
-
Wrapper around mbl_mw_led_stop_and_clear
Declaration
Swift
public func turnOffLed()
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didDiscoverServices error: Error?)
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didDiscoverCharacteristicsFor service: CBService, error: Error?)
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?)
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didWriteValueFor characteristic: CBCharacteristic, error: Error?)
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didUpdateNotificationStateFor characteristic: CBCharacteristic, error: Error?)
-
Undocumented
Declaration
Swift
public func peripheralIsReady(toSendWriteWithoutResponse peripheral: CBPeripheral)
-
Undocumented
Declaration
Swift
public func peripheral(_ peripheral: CBPeripheral, didReadRSSI RSSI: NSNumber, error: Error?)
-
Get a pointer to the latest firmware for this device
Declaration
Swift
public func latestFirmware() -> Task<FirmwareBuild>
-
Get a pointer to the latest firmware for this device or nil if already on the latest
Declaration
Swift
public func checkForFirmwareUpdate() -> Task<FirmwareBuild?>
-
Install the provided firmware (or latest if none provided)
Declaration
Swift
public func updateFirmware(delegate: DFUProgressDelegate? = nil, build: FirmwareBuild? = nil) -> Task<Void>
-
Declaration
Swift
public func dfuStateDidChange(to state: DFUState)
-
Declaration
Swift
public func dfuError(_ error: DFUError, didOccurWithMessage message: String)
-
Declaration
Swift
public func logWith(_ level: iOSDFULibrary.LogLevel, message: String)