Skip to content

Commit 1bbebd3

Browse files
feat: introduce startProbingONVIFDevices method (#7)
1 parent 880d1b0 commit 1bbebd3

File tree

5 files changed

+57
-5
lines changed

5 files changed

+57
-5
lines changed

.node-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11.5.0
1+
11.6.0

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11.5.0
1+
11.6.0

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
</p>
3333

3434
## Installation
35+
This package is designed to be run in a Node environment.
3536
```sh
3637
npm i onvif-probe-rx
3738
```
@@ -40,10 +41,10 @@ npm i onvif-probe-rx
4041
For the best developer experience use Typescript.
4142

4243
```ts
43-
import { probeONVIFDevices } from 'onvif-probe-rx'
44+
import { startProbingONVIFDevices } from 'onvif-probe-rx'
4445

45-
probeONVIFDevices()
46-
.run({})
46+
// starts probing the network using the default configuration
47+
startProbingONVIFDevices()
4748
.subscribe(console.info)
4849
```
4950

@@ -58,4 +59,18 @@ probeONVIFDevices()
5859
PROBE_NETWORK_TIMEOUT_MS: 20000
5960
})
6061
.subscribe(console.log)
62+
```
63+
64+
## Default Configuration
65+
```ts
66+
const DEFAULT_CONFIG: IProbeConfig = {
67+
PORT: 3702,
68+
MULTICAST_ADDRESS: '239.255.255.250',
69+
PROBE_SAMPLE_TIME_MS: 2000,
70+
PROBE_SAMPLE_START_DELAY_TIME_MS: 0,
71+
PROBE_NETWORK_TIMEOUT_MS: 2000 * 1.5,
72+
ONVIF_DEVICES: ['NetworkVideoTransmitter', 'Device', 'NetworkVideoDisplay'],
73+
DOM_PARSER: new DOMParser(),
74+
NOT_FOUND_STRING: 'unknown'
75+
}
6176
```

src/config.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,48 @@
11
import { DOMParser } from 'xmldom'
22

3+
/**
4+
* Probe configuration
5+
*/
36
export interface IProbeConfig {
7+
/**
8+
* Port number.
9+
*/
410
readonly PORT: number
11+
12+
/**
13+
* Multicast address.
14+
*/
515
readonly MULTICAST_ADDRESS: string
16+
17+
/**
18+
* How frequent, in milliseconds, the network is scanned for devices.
19+
*/
620
readonly PROBE_SAMPLE_TIME_MS: number
21+
22+
/**
23+
* Delay, in miliseconds, before the first scan is sent.
24+
*/
725
readonly PROBE_SAMPLE_START_DELAY_TIME_MS: number
26+
27+
/**
28+
* Time it takes to determine if a device is no longer present on the network.
29+
* This is best to be at least 1.5x longer than PROBE_SAMPLE_TIME_MS
30+
*/
831
readonly PROBE_NETWORK_TIMEOUT_MS: number
32+
33+
/**
34+
* ONVIF device types to check for.
35+
*/
936
readonly ONVIF_DEVICES: ReadonlyArray<string>
37+
38+
/**
39+
* An object the conforms to the W3C DOMParser spec. This helps parse respnse XML.
40+
*/
1041
readonly DOM_PARSER: DOMParser
42+
43+
/**
44+
* When an attribute is undefined, use this text instead.
45+
*/
1146
readonly NOT_FOUND_STRING: string
1247
}
1348

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,5 @@ export const probeONVIFDevices = () => reader<Partial<IProbeConfig>, Observable<
6868
}, [])
6969
)
7070
})
71+
72+
export const startProbingONVIFDevices = () => probeONVIFDevices().run({})

0 commit comments

Comments
 (0)