swarms
Version:
The ultimate node.js library for controlling Bitcraze Crazyflie 2.0 drones
64 lines (63 loc) • 1.92 kB
TypeScript
/// <reference types="node" />
import { Crazyflie } from '.';
import { TOC, TOCItem } from './toc';
import { EventEmitter } from 'events';
export declare class TOCFetcher extends EventEmitter {
private crazyflie;
type: TOC_TYPES;
fetched: boolean;
port: number;
toc: TOC;
readonly cachePath: string;
length: number;
crc: number;
maxPackets: number;
maxOperations: number;
/**
* Fetches TOC from the Crazyflie. Specify port because both parameters and logging use the same system
* (https://wiki.bitcraze.io/doc:crazyflie:crtp:log#table_of_content_access)
* (https://wiki.bitcraze.io/doc:crazyflie:crtp:param#toc_access)
*/
constructor(crazyflie: Crazyflie, type: TOC_TYPES);
start(): Promise<TOC>;
handleTOCInfo(data: Buffer): Promise<void>;
/**
* Loop through all TOC ids and see if we already have it. If not, retrieve it.
*/
private fetchRemainingTOCItems();
/**
* Fetch TOC item from the Crazyflie
* (https://wiki.bitcraze.io/doc:crazyflie:crtp:log#get_toc_item)
*/
private fetchTOCItem(id);
/**
* Handle TOC item response
* (https://wiki.bitcraze.io/doc:crazyflie:crtp:log#get_toc_item)
*/
handleTOCItem(data: Buffer): Promise<void>;
/**
* Save a TOC to cache
*/
cacheTOC(crc: number, items: TOCItem[]): Promise<void>;
/**
* Get TOC from cache according to cyclic redundancy check (checksum) value
* Will return null if no crc in cache
*/
getTOCFromCache(crc: number): Promise<TOC>;
/**
* Gets the complete TOC cache
* Will return null if file doesn't exist or invalid JSON
*/
getTOCCache(): Promise<TOCCache>;
/**
* Deletes cache
*/
clearCache(): Promise<void>;
}
export declare const enum TOC_TYPES {
PARAM = 0,
LOG = 1,
}
export interface TOCCache {
[crc: number]: TOCItem[];
}