identi-recognition
v0.0.3
Published
identiRecognition
Downloads
6
Readme
HUMAN FACE SECURITY INTEGRATION
This package provides a unified way to interact with multiple access control devices, including XCore
and Terminal
, allowing for standardized command execution and status retrieval.
| Version | Descripcion | Estado | | ------- | ------------------- | ----------- | | 0.0.3 | Initial Integration | Development | | | | |
RELEASE NOTES :
[...]
Table of Contents
Installation
To install this package, use the following command:
npm install identi-recognition
Make sure you have axios installed as a dependency if not already present in your project:
npm install device-control-package
Usage
First, import the desired classes from the package:
const { XCore, Terminal } = require('device-control-package')
// Create instances for each device with their respective IP addresses
const xcoreDevice = new XCore('192.168.1.100')
const terminalDevice = new Terminal('192.168.1.101')
Device Classes
XCore Class
The XCore
class allows you to interact with XCore devices. It includes methods for status retrieval and sending commands.
| Method | Description |
| ------------------ | ------------------------------------------------- |
| getStatus()
| Retrieves the current status of the XCore device. |
| sendCommand(cmd)
| Sends a command to the XCore device. |
| restartDevice()
| Restarts the XCore device. |
| getLogs()
| Retrieves the logs of the XCore device. |
| updateFirmware()
| Updates the firmware of the device. |
Terminal Class
The Terminal
class provides similar functionality for Terminal devices. It supports status monitoring, command execution, and more.
| Method | Description |
| ------------------------ | ---------------------------------------------------- |
| getStatus()
| Retrieves the current status of the Terminal device. |
| sendCommand(cmd)
| Sends a command to the Terminal device. |
| reboot()
| Reboots the Terminal device. |
| setConfiguration(data)
| Applies new configuration settings to the device. |
| clearLogs()
| Clears the logs of the Terminal device. |
Configuration
Some methods may require additional configurations. You can set global configuration values in a config file:
module.exports = {
requestTimeout: 5000, // Timeout for each request in milliseconds
retryAttempts: 3 // Number of retry attempts for failed requests
}
Create a config.js file in the root directory of your project to set these values.
Adittional, when creating Xcore Objects , make sure to call the getStatus() ALWAYS , so you can make sure the device was correctly configured. If it fails, try changing the _versionPro parameter when creating the object
API Reference
XCore Methods
getStatus()
Retrieves the current status of the XCore device.
const status = await xcoreDevice.getStatus() console.log(status) // Output: { status: 'online', ... }
sendCommand(command: string)
Sends a specified command to the device.
const response = await xcoreDevice.sendCommand('RESTART') console.log(response) // Output: { success: true, ... }
restartDevice()
Restarts the XCore device.
const result = await xcoreDevice.restartDevice() console.log(result) // Output: { success: true, message: 'Device restarting...' }
getLogs()
Retrieves system logs from the XCore device.
const logs = await xcoreDevice.getLogs() console.log(logs) // Output: [ { timestamp: '...', message: 'Log entry...' }, ... ]
updateFirmware()
Updates the firmware of the device using the given update file.
const updateStatus = await xcoreDevice.updateFirmware('path/to/update.bin') console.log(updateStatus) // Output: { success: true, version: '2.0.1' }
Terminal Methods
getStatus()
Retrieves the current status of the Terminal device.
const status = await terminalDevice.getStatus() console.log(status) // Output: { status: 'online', ... }
sendCommand(command: string)
Sends a command to the Terminal device.
const response = await terminalDevice.sendCommand('LOCK_DOOR') console.log(response) // Output: { success: true, message: 'Command executed' }
reboot()
Reboots the Terminal device.
const result = await terminalDevice.reboot() console.log(result) // Output: { success: true, message: 'Device rebooting...' }
setConfiguration(configObject: object)
Applies new configuration settings to the Terminal device.
const newConfig = { volume: 80, brightness: 70 } const result = await terminalDevice.setConfiguration(newConfig) console.log(result) // Output: { success: true, message: 'Configuration applied' }
clearLogs()
Clears the logs stored in the Terminal device.
const result = await terminalDevice.clearLogs() console.log(result) // Output: { success: true, message: 'Logs cleared' }
Error Handling
The package provides a built-in error handler to capture and log errors. Errors are caught and handled internally, returning meaningful messages to the user.
Examples
Here’s a quick example of how you can use this package:
const { XCore, Terminal } = require('device-control-package')
const xcore = new XCore('192.168.1.100')
const terminal = new Terminal('192.168.1.101')
// ALWAYS CALL THE Get status of XCore
// IF it fails , try changing the _versionPro parameter
xcore
.getStatus()
.then((status) => console.log('XCore Status:', status))
.catch((error) => {
const xcore = new XCore('192.168.1.100', (_versionPro = false))
})
// Send a command to Terminal
terminal.sendCommand('LOCK_DOOR').then((response) => console.log('Command Response:', response))