1 | import { Observable } from 'rxjs/Observable';
|
2 | export interface SerialPermissionOptions {
|
3 | vid: string;
|
4 | pid: string;
|
5 | driver: string;
|
6 | }
|
7 | export interface SerialOpenOptions {
|
8 | baudRate: number;
|
9 | }
|
10 | /**
|
11 | * @name Serial
|
12 | * @description
|
13 | * This plugin provides functions for working with Serial connections
|
14 | *
|
15 | * @usage
|
16 | *
|
17 | * ```
|
18 | * import { Serial } from 'ionic-native';
|
19 | *
|
20 | * Serial.requestPermission().then(() => {
|
21 | * Serial.open({
|
22 | * baudRate: 9800
|
23 | * }).then(() => {
|
24 | * console.log('Serial connection opened');
|
25 | * });
|
26 | * }).catch((error: any) => console.log(error));
|
27 | *
|
28 | * ```
|
29 | */
|
30 | export declare class Serial {
|
31 | /**
|
32 | * Request permission to connect to a serial device
|
33 | *
|
34 | * @param options {SerialPermissionOptions} Options used to request serial permissions for an unknown device
|
35 | * @return {Promise<any>} Returns a promise that resolves when permissions are granted
|
36 | */
|
37 | static requestPermission(options?: SerialPermissionOptions): Promise<any>;
|
38 | /**
|
39 | * Open connection to a serial device
|
40 | *
|
41 | * @param options {SerialOpenOptions} Options used to open serial connection
|
42 | * @return {Promise<any>} Returns a promise that resolves when the serial connection is opened
|
43 | */
|
44 | static open(options: SerialOpenOptions): Promise<any>;
|
45 | /**
|
46 | * Write to a serial connection
|
47 | *
|
48 | * @param data {any} data to write to the serial connection
|
49 | * @return {Promise<any>} Returns a promise that resolves when the write is complete
|
50 | */
|
51 | static write(data: any): Promise<any>;
|
52 | /**
|
53 | * Write hex to a serial connection
|
54 | *
|
55 | * @param data {any} data to write to the serial connection
|
56 | * @return {Promise<any>} Returns a promise that resolves when the write is complete
|
57 | */
|
58 | static writeHex(data: any): Promise<any>;
|
59 | /**
|
60 | * Read from a serial connection
|
61 | *
|
62 | * @return {Promise<any>} Returns a promise that resolves with data read from the serial connection
|
63 | */
|
64 | static read(): Promise<any>;
|
65 | /**
|
66 | * Watch the incoming data from the serial connection. Clear the watch by unsubscribing from the observable
|
67 | *
|
68 | * @returns {Observable<any>} Observable returns an observable that you can subscribe to
|
69 | */
|
70 | static registerReadCallback(): Observable<any>;
|
71 | /**
|
72 | * Close the serial connection
|
73 | *
|
74 | * @return {Promise<any>} Returns a promise that resolves when the serial connection is closed
|
75 | */
|
76 | static close(): Promise<any>;
|
77 | }
|