public class JseMetaWearBoard extends java.lang.Object implements MetaWearBoard
MetaWearBoard interface using only standard Java APIs. Platform specific functionality
is abstracted with the IO and BtleGatt interfaces.MetaWearBoard.Module, MetaWearBoard.UnexpectedDisconnectHandlerMETABOOT_SERVICE, METAWEAR_GATT_SERVICE, METAWEAR_NOTIFY_CHAR| Constructor and Description |
|---|
JseMetaWearBoard(BtleGatt gatt,
IO io,
java.lang.String macAddress,
java.lang.String libVersion)
Constructs a JseMetaWearBoard object
|
| Modifier and Type | Method and Description |
|---|---|
bolts.Task<java.lang.Boolean> |
checkForFirmwareUpdateAsync()
Checks if there is a newer version of the firmware available for your board.
|
bolts.Task<java.lang.Void> |
connectAsync()
Establishes a Bluetooth Low Energy connection to the MetaWear board
|
bolts.Task<java.lang.Void> |
connectAsync(long delay)
Establishes a Bluetooth Low Energy connection to the MetaWear board
|
bolts.Task<java.lang.Void> |
connectWithRetryAsync(int retries)
Establishes a Bluetooth Low Energy connection to the MetaWear board
|
bolts.Task<AnonymousRoute[]> |
createAnonymousRoutesAsync()
Reads the current state of the board and creates anonymous routes based on what data is being logged
|
void |
deserialize()
Restore serialized state from the local disk if available
|
void |
deserialize(java.io.InputStream ins)
Restore serialized state from the provided input stream
|
bolts.Task<java.lang.Void> |
disconnectAsync()
Disconnects from the board and cancels pending
MetaWearBoard.connectAsync() tasks |
bolts.Task<java.io.File> |
downloadFirmwareAsync(java.lang.String version)
Downloads the specific firmware release for the board to your local device.
|
bolts.Task<java.util.List<java.io.File>> |
downloadFirmwareUpdateFilesAsync()
Retrieves the files needed to update the board to the latest available firmware.
|
bolts.Task<java.util.List<java.io.File>> |
downloadFirmwareUpdateFilesAsync(java.lang.String version)
Retrieves the files needed to update the board to the specific firmware version.
|
bolts.Task<java.util.List<java.io.File>> |
downloadFirmwareUpdateFilesAsyncV2()
Retrieves the files needed to update the board to the latest available firmware.
|
bolts.Task<java.util.List<java.io.File>> |
downloadFirmwareUpdateFilesAsyncV2(java.lang.String version)
Variant of
MetaWearBoard.downloadFirmwareUpdateFilesAsyncV2() that lets the caller specify which firmware version to download |
bolts.Task<java.io.File> |
downloadLatestFirmwareAsync()
Downloads the latest firmware release for the board to your local device.
|
bolts.Task<org.json.JSONObject> |
dumpModuleInfo(org.json.JSONObject partial)
Queries all info registers.
|
bolts.Task<java.lang.String> |
findLatestAvailableFirmwareAsync()
Checks if a newer firmware version is available for the current board.
|
java.lang.String |
getFirmware() |
java.lang.String |
getMacAddress()
Retrieves the MAC address of the board
|
Model |
getModel()
Determines the board model of the currently connected device
|
java.lang.String |
getModelNumber() |
java.lang.String |
getModelString()
Same behavior as
MetaWearBoard.getModel() except the returned value is a friendly name rather than an enum |
<T extends MetaWearBoard.Module> |
getModule(java.lang.Class<T> moduleClass)
Retrieves a reference to the requested module if supported.
|
<T extends MetaWearBoard.Module> |
getModuleOrThrow(java.lang.Class<T> moduleClass)
Retrieves a reference to the requested module if supported, throws a checked exception if the function fails.
|
boolean |
inMetaBootMode()
Checks if the board is in the MetaBoot (bootloader) mode.
|
boolean |
isConnected()
Gets the connection state
|
void |
loadBoardAttributes() |
Observer |
lookupObserver(int id)
Retrieves an observer
|
Route |
lookupRoute(int id)
Retrieves a route
|
void |
onUnexpectedDisconnect(MetaWearBoard.UnexpectedDisconnectHandler handler)
Set a handler for unexpected disconnects
|
bolts.Task<java.lang.Byte> |
readBatteryLevelAsync()
Reads the battery level characteristic
|
bolts.Task<DeviceInformation> |
readDeviceInformationAsync()
Reads supported characteristics from the Device Information service
|
bolts.Task<java.lang.Integer> |
readRssiAsync()
Reads the current RSSI value
|
void |
serialize()
Serialize object state and write the state to the local disk
|
void |
serialize(java.io.OutputStream outs)
Serialize object state and write the state to the provided output stream
|
void |
tearDown()
Removes all routes and resources allocated on the board (observers, data processors, timers, and loggers)
|
public java.lang.String getFirmware()
public java.lang.String getModelNumber()
public Model getModel()
MetaWearBoardgetModel in interface MetaWearBoardpublic java.lang.String getModelString()
MetaWearBoardMetaWearBoard.getModel() except the returned value is a friendly name rather than an enumgetModelString in interface MetaWearBoardpublic java.lang.String getMacAddress()
MetaWearBoardgetMacAddress in interface MetaWearBoardpublic bolts.Task<java.lang.Integer> readRssiAsync()
MetaWearBoardreadRssiAsync in interface MetaWearBoardpublic bolts.Task<java.lang.Byte> readBatteryLevelAsync()
MetaWearBoardreadBatteryLevelAsync in interface MetaWearBoardpublic bolts.Task<DeviceInformation> readDeviceInformationAsync()
MetaWearBoardreadDeviceInformationAsync in interface MetaWearBoardpublic bolts.Task<java.util.List<java.io.File>> downloadFirmwareUpdateFilesAsync(java.lang.String version)
MetaWearBoarddownloadFirmwareUpdateFilesAsync in interface MetaWearBoardversion - Firmware revision to download, null to retrieve the latest versionpublic bolts.Task<java.util.List<java.io.File>> downloadFirmwareUpdateFilesAsync()
MetaWearBoarddownloadFirmwareUpdateFilesAsync in interface MetaWearBoardpublic bolts.Task<java.util.List<java.io.File>> downloadFirmwareUpdateFilesAsyncV2(java.lang.String version)
MetaWearBoardMetaWearBoard.downloadFirmwareUpdateFilesAsyncV2() that lets the caller specify which firmware version to downloaddownloadFirmwareUpdateFilesAsyncV2 in interface MetaWearBoardversion - Firmware revision to download, null to retrieve the latest versionpublic bolts.Task<java.util.List<java.io.File>> downloadFirmwareUpdateFilesAsyncV2()
MetaWearBoardMetaWearBoard.inMetaBootMode().downloadFirmwareUpdateFilesAsyncV2 in interface MetaWearBoardpublic bolts.Task<java.lang.String> findLatestAvailableFirmwareAsync()
MetaWearBoardfindLatestAvailableFirmwareAsync in interface MetaWearBoardpublic bolts.Task<java.io.File> downloadFirmwareAsync(java.lang.String version)
MetaWearBoarddownloadFirmwareAsync in interface MetaWearBoardversion - Firmware revision to download, null to retrieve the latest versionpublic bolts.Task<java.io.File> downloadLatestFirmwareAsync()
MetaWearBoarddownloadLatestFirmwareAsync in interface MetaWearBoardpublic bolts.Task<java.lang.Boolean> checkForFirmwareUpdateAsync()
MetaWearBoardcheckForFirmwareUpdateAsync in interface MetaWearBoardpublic void loadBoardAttributes()
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOExceptionjava.lang.ClassNotFoundExceptionpublic bolts.Task<java.lang.Void> connectAsync()
MetaWearBoardconnectAsync in interface MetaWearBoardpublic bolts.Task<java.lang.Void> connectWithRetryAsync(int retries)
MetaWearBoardconnectWithRetryAsync in interface MetaWearBoardretries - Number of retry attempts before completing the task with an errorpublic bolts.Task<java.lang.Void> connectAsync(long delay)
MetaWearBoardconnectAsync in interface MetaWearBoarddelay - How long to wait (in milliseconds) before attempting to connectpublic bolts.Task<java.lang.Void> disconnectAsync()
MetaWearBoardMetaWearBoard.connectAsync() tasksdisconnectAsync in interface MetaWearBoardpublic void onUnexpectedDisconnect(MetaWearBoard.UnexpectedDisconnectHandler handler)
MetaWearBoardonUnexpectedDisconnect in interface MetaWearBoardhandler - Handler for unexpected disconnectspublic boolean isConnected()
MetaWearBoardisConnected in interface MetaWearBoardpublic boolean inMetaBootMode()
MetaWearBoardinMetaBootMode in interface MetaWearBoardpublic <T extends MetaWearBoard.Module> T getModule(java.lang.Class<T> moduleClass)
MetaWearBoardgetModule in interface MetaWearBoardT - Runtime type the return value is casted asmoduleClass - Module class to lookuppublic <T extends MetaWearBoard.Module> T getModuleOrThrow(java.lang.Class<T> moduleClass) throws UnsupportedModuleException
MetaWearBoardgetModuleOrThrow in interface MetaWearBoardT - Runtime type the return value is casted asmoduleClass - ModuleId class to lookupUnsupportedModuleException - If the requested module is not supported or the board is in MetaBoot modepublic Route lookupRoute(int id)
MetaWearBoardlookupRoute in interface MetaWearBoardid - Numerical ID to look uppublic Observer lookupObserver(int id)
MetaWearBoardlookupObserver in interface MetaWearBoardid - Numerical ID to look uppublic void tearDown()
MetaWearBoardtearDown in interface MetaWearBoardpublic void serialize()
throws java.io.IOException
MetaWearBoardserialize in interface MetaWearBoardjava.io.IOException - If the internal OutputStream throws an exceptionpublic void serialize(java.io.OutputStream outs)
throws java.io.IOException
MetaWearBoardserialize in interface MetaWearBoardouts - Output stream to write tojava.io.IOException - If the provided OutputStream throws an exceptionpublic void deserialize()
throws java.io.IOException,
java.lang.ClassNotFoundException
MetaWearBoarddeserialize in interface MetaWearBoardjava.io.IOException - If the internal InputStream throws an exceptionjava.lang.ClassNotFoundException - Class of a serialized object cannot be foundpublic void deserialize(java.io.InputStream ins)
throws java.io.IOException,
java.lang.ClassNotFoundException
MetaWearBoarddeserialize in interface MetaWearBoardins - Input stream to read fromjava.io.IOException - If the provided InputStream throws an exceptionjava.lang.ClassNotFoundException - Class of a serialized object cannot be foundpublic bolts.Task<org.json.JSONObject> dumpModuleInfo(org.json.JSONObject partial)
MetaWearBoarddumpModuleInfo in interface MetaWearBoardpartial - Map of previously queries module info results, set to null to query all modulespublic bolts.Task<AnonymousRoute[]> createAnonymousRoutesAsync()
MetaWearBoardcreateAnonymousRoutesAsync in interface MetaWearBoard