-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
68 lines (55 loc) · 2.04 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/// <reference types="node" />
import * as events from 'events'
type HandlersSpec = {
connected?: () => void,
event?: (evt: string, src: KnxDeviceAddress, dest: KnxGroupAddress, value: Buffer ) => void,
error?: (connstatus: any) => void
}
type ConnectionSpec = {
ipAddr?: string,
ipPort?: number,
interface?: string,
physAddr?: string,
debug?: boolean,
manualConnect?: true,
minimumDelay?: number,
handlers: HandlersSpec,
}
type KnxDeviceAddress = string
type KnxGroupAddress = string
// The type of the KnxValue depends on the DPT that it is associated with
type KnxValue = number|string|boolean|Date
// Possible formats "X" or "X.Y", i.e. "1" or "1.001"
type DPT = string
type DatapointOptions = {
ga: KnxGroupAddress,
dpt: DPT
}
interface DatapointEvent {
on( event: 'change', listener: (old_value: KnxValue, new_value: KnxValue) => void): this
on(event: string, listener: Function): this
}
declare module 'knx' {
export interface IConnection extends events.EventEmitter {
debug: boolean
Disconnect(): void
read( ga: KnxGroupAddress, cb?: (value: Buffer) => void ): void
write( ga: KnxGroupAddress, value: Buffer, dpt: DPT, cb?: () => void): void
}
export class Connection extends events.EventEmitter implements IConnection {
public debug: boolean
constructor( conf: ConnectionSpec )
Disconnect(): void
read( ga: KnxGroupAddress, cb?: (value: Buffer) => void ): void
write( ga: KnxGroupAddress, value: Buffer, dpt: DPT, cb?: () => void): void
writeRaw( ga: KnxGroupAddress, value: Buffer, bitlength?: number, cb?: () => void): void
}
export class Datapoint extends events.EventEmitter implements DatapointEvent {
readonly current_value: KnxValue
readonly dptid: DPT
constructor(options: DatapointOptions, conn?: IConnection)
bind(conn: Connection): void
write(value: KnxValue): void
read(callback?: (src: KnxDeviceAddress, value: KnxValue) => void): void
}
}