@iotile/iotile-device
Version:
A typescript library for interfacing with IOTile BLE devices
64 lines (63 loc) • 3.26 kB
TypeScript
import { IOTileDevice } from "../iotile-device";
import { IOTileAdapter } from "../iotile-serv";
import { ProgressNotifier, LoggingBase } from "@iotile/iotile-common";
import { ShockInfo } from "./types";
import { IOTileEvent } from "../../common/flexible-dict-report";
import { SignedListReport } from "../../common/iotile-reports";
export declare class POD1M extends LoggingBase {
device: IOTileDevice;
adapter: IOTileAdapter;
constructor(device: IOTileDevice, adapter: IOTileAdapter);
getShockInfo(shock: number): Promise<ShockInfo>;
getAccelerometerStatus(): Promise<{
'tile_state': string;
'recording': boolean;
'settled': boolean;
'streaming': boolean;
}>;
/**
* Download all trip data from a POD-1M.
*
* This method will download waveforms, trip details and environmental data from a POD-1M.
* If the method returns then all trip information was downloaded successfully. Any error
* downloading data from the device will cause an exception to be thrown indicating what
* went wrong.
*
* The download process proceeds as follows:
*
* 1. Sort and then receive up to 100 waveforms from the device. If we are given a
* highestReceivedWaveform ID, then all waveforms older than this will be dropped.
* On newer device firmware, the dropping will happen inside the device itself.
* On older device firmware (Pre POD-1Mv2), we will drop the waveforms after receiving
* them.
* 2. Check if any of the waveforms need their UTC timestamps fixed up
* 3. If UTC fixup is needed, roll back the environmental streamer to the beginning
* to make sure that the device sends us all potential waveform timestamp markers
* to allow us to assign utc timestamps.
* 4. Download environmental, system and trip data from the device.
* 5. If UTC fixup is needed, assign utc timestamps to all waveforms stamped in uptime.
* 6. Create IOTileEvent objects for each waveform
* 7. Return the list of received reports and the IOTileEvent objects which are guaranteed
* to have their timestamps in UTC.
*
* Since many of these steps are fast, not all of them are included in the progress bar.
* This routine will call ProgressNotifier.startOne()/finishOne() a total of 6 times so
* that is the amount of space in the progress bar that should be allocated for this routine.
*
* If this routine is called with the possibility of a sub-progress bar, then it will show
* progress separately for each report received and for all waveforms as a single progress
* bar.
*
* @param progress A progress notifier that can be used to update a ProgressModal as we go.
*/
downloadData(progress: ProgressNotifier, highestReceivedWaveform?: number): Promise<[SignedListReport[], IOTileEvent[]]>;
private sortReadings;
/**
* Download the top 100 waveforms from the POD-1M device.
*
* This routine will consume 3 progress steps.
*
*/
private getCompressedWaveforms;
downloadReports(notifier: ProgressNotifier): Promise<SignedListReport[]>;
}