@nger/onvif-rx
v1.0.4
Published
Interact with ONVIF cameras and devices using RXJS
Downloads
7
Maintainers
Readme
About
This library aims to provide an easy way to interact with ONVIF devices from within Node. It is built with TypeScript to provide IDE's easy access to documentation and typing information.
The API is generated dynamically by reading ONVIF WSDL and XSD files.
This library is very early and not garaunteed to work for evey camera. Feel free to create a Github issue if it's not working for you.
This library does not "discover" devices on the network - for that try onvif-probe-rx
Docs
For more information about the TypeScript API checkout the generated API docs.
Roadmap
- [x] Generate API with typings and docs from WSDL's and XSD's
- [x] Execute simple (parameter-less) requests
- [x] Execute requests with paremeters
Node Installation
This package is designed to be run in both the browser and node environments.
npm i onvif-rx
Browser Installation (expiremental)
<head>
<!-- simplest method, gets the latest version, but not minifed -->
<script src="https://unpkg.com/onvif-rx"></script>
<!-- RECOMMENDED: use a specific version to avoid a redirect and get a minified version -->
<script src="https://unpkg.com/[email protected]/dist/onvif-rx-umd.min.js"></script>
</head>
Usage
The library is designed to be used in 2 distinct ways.
- Managed - you construct a manged device using service URL and username/password combo. This makes running commands painless.
- Ad Hoc - you can call methods individually with different username/passwords if needed.
Managed Usage
import { createManagedDeviceInNode } from 'onvif-rx'
const device = createManagedDeviceInNode({
deviceUrl: 'http://192.168.1.11/onvif/device_service',
password: 'admin',
username: '1234'
})
device.api.Device.GetUsers()
.toPromise()
.then(res=> {
res.match({ // results are wrapped in a managed object for safer processing
ok: success => console.log(success.json), // successful response object
fail: railure => console.log(railure.status, railure.statusMessage) // request failure object
})
})
Ad Hoc Usage
import { Device } from 'onvif-rx'
import { maybe } from 'typescript-monads'
Device.GetUsers()
.run({
system: DEFAULT_NODE_ENV,
deviceUrl: 'http://192.168.1.11/onvif/device_service',
user: maybe({ // currently requires a wrapper object, will improve in the future
username: 'admin',
password: '1234'
})
})
.toPromise()
.then(res=> {
res.match({
ok: success => console.log(success.json), // successful response object
fail: railure => console.log(railure.status, railure.statusMessage) // request failure object
})
})