@cutos/core 0.0.17 → 0.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +246 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
The CUTOS (CUT Operating System) Core API is a JavaScript library that provides essential functionalities for LWA (Local Web Application) edge computing and communication in the CUTOS ecosystem. The module is designed to facilitate communication between edge devices, edge gateways, and the cloud. Key features include platform information accessing, edge database operations, IPC (Inter-Process Communication), logging, heartbeat monitoring, and device management, etc. The API is designed to be modular and extensible.
|
|
4
|
+
|
|
5
|
+
## Core API Modules Components
|
|
6
|
+
|
|
7
|
+
### Platform
|
|
8
|
+
- The CoreAPI class is the main entry point for interacting with the CUTOS Core API.
|
|
9
|
+
- It provides methods for connecting to the platform, accessing information, and obtaining instances of other classes such as Database, IPC, Logger, etc.
|
|
10
|
+
|
|
11
|
+
### IPC Implementation
|
|
12
|
+
- IPC (Inter-Process Communication) is implemented for communication between processes on the same machine or between processes on different machines within the same network segment.
|
|
13
|
+
- The IPC class allows sending messages to a specific channel and registering listeners for incoming messages.
|
|
14
|
+
|
|
15
|
+
### Database Operations
|
|
16
|
+
- The Database class facilitates database operations, including table creation, insertion, updating, querying, and synchronization.
|
|
17
|
+
- Provides a structured interface for managing edge databases.
|
|
18
|
+
|
|
19
|
+
### Device and Driver Management
|
|
20
|
+
- The Device and Driver classes represent edge devices and drivers, respectively. The Device can also refer to external devices or modules, such as NFC, fingerprint modules, ID card readers, printers, sensors, GPIO and so on.
|
|
21
|
+
- Devices and drivers communicate for data transmission, command reception, and status updates.
|
|
22
|
+
- Heartbeat monitoring is implemented for drivers to ensure continuous communication.
|
|
23
|
+
|
|
24
|
+
### Notification
|
|
25
|
+
- The Notification class provides functionality for registering, unregistering, and emitting events.
|
|
26
|
+
|
|
27
|
+
### Logging
|
|
28
|
+
- The Logger class enables logging of information, warnings, errors, and debug messages.
|
|
29
|
+
- Logs are sent and saved to the CUTOS Cloud. In the CUSOS Cloud administration web page, the logs can be queried for a specified device.
|
|
30
|
+
|
|
31
|
+
# Conclusion
|
|
32
|
+
|
|
33
|
+
The CUTOS Core API provides a comprehensive set of classes for interacting with the CUTOS platform. Developers can use these classes to build applications, manage databases, communicate with devices, and handle various aspects of the CUTOS ecosystem. The modular design allows for flexibility and extensibility, making it suitable for a wide range of use cases within the IoT and smart device domain.
|
|
34
|
+
|
|
35
|
+
# Table of Contents
|
|
36
|
+
|
|
37
|
+
1.Quick Start
|
|
38
|
+
|
|
39
|
+
- Installation
|
|
40
|
+
- Initialization
|
|
41
|
+
|
|
42
|
+
2.PlatformAPI
|
|
43
|
+
|
|
44
|
+
- Version
|
|
45
|
+
- Platform Information
|
|
46
|
+
- Configuration
|
|
47
|
+
- Box Information
|
|
48
|
+
- Shell Command Execution
|
|
49
|
+
- Volume Control
|
|
50
|
+
|
|
51
|
+
3.IPC (Inter-Process Communication)
|
|
52
|
+
|
|
53
|
+
4.Database
|
|
54
|
+
|
|
55
|
+
5.Device & Driver
|
|
56
|
+
|
|
57
|
+
6.Notification
|
|
58
|
+
|
|
59
|
+
7.Logger
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
# Quick Start
|
|
63
|
+
|
|
64
|
+
##### Install
|
|
65
|
+
|
|
66
|
+
`
|
|
67
|
+
npm install @cutos/core
|
|
68
|
+
`
|
|
69
|
+
|
|
70
|
+
##### Initialize
|
|
71
|
+
|
|
72
|
+
```js
|
|
73
|
+
// Initialize the CUTOS Core module
|
|
74
|
+
import { CoreAPI } from '@cutos/core';
|
|
75
|
+
CoreAPI.init();
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
# Platform API
|
|
79
|
+
|
|
80
|
+
### CoreAPI.getVersion
|
|
81
|
+
##### Get platform version information
|
|
82
|
+
```js
|
|
83
|
+
CoreAPI.getVersion();
|
|
84
|
+
```
|
|
85
|
+
- Return result example:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
0.0.17
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### CoreAPI.getPlatform
|
|
92
|
+
##### Get platform information
|
|
93
|
+
|
|
94
|
+
```js
|
|
95
|
+
CoreAPI.getPlatform(callback);
|
|
96
|
+
```
|
|
97
|
+
- callback: callback function
|
|
98
|
+
|
|
99
|
+
##### Example:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
CoreAPI.getPlatform(result => {
|
|
103
|
+
console.log(result)
|
|
104
|
+
});
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
- Return result example:
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"arch": "x64",
|
|
112
|
+
"type": "Windows_NT"
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### CoreAPI.getConfig
|
|
117
|
+
##### Get configuration information
|
|
118
|
+
```js
|
|
119
|
+
CoreAPI.getConfig(callback);
|
|
120
|
+
```
|
|
121
|
+
- callback: callback function
|
|
122
|
+
|
|
123
|
+
##### Example:
|
|
124
|
+
|
|
125
|
+
```js
|
|
126
|
+
CoreAPI.getConfig(result => {
|
|
127
|
+
console.log(result)
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
- Return result example:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"srvAddress": "www.cut-os.com",
|
|
136
|
+
"srvRestProtocol": "https",
|
|
137
|
+
"enableTimeSync": true,
|
|
138
|
+
"playReport": false,
|
|
139
|
+
"language": "Chinese",
|
|
140
|
+
"debug": false
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
### CoreAPI.getSignInfo
|
|
144
|
+
##### Get device information
|
|
145
|
+
|
|
146
|
+
```js
|
|
147
|
+
CoreAPI.getSignInfo(callback);
|
|
148
|
+
```
|
|
149
|
+
- callback: callback function
|
|
150
|
+
|
|
151
|
+
##### Example:
|
|
152
|
+
|
|
153
|
+
```js
|
|
154
|
+
CoreAPI.getSignInfo(result => {
|
|
155
|
+
console.log(result)
|
|
156
|
+
})
|
|
157
|
+
```
|
|
158
|
+
### CoreAPI.getBoxInfo
|
|
159
|
+
##### Get host information
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
CoreAPI.getBoxInfo(callback);
|
|
163
|
+
```
|
|
164
|
+
- callback: callback function
|
|
165
|
+
|
|
166
|
+
##### Example:
|
|
167
|
+
|
|
168
|
+
```js
|
|
169
|
+
CoreAPI.getBoxInfo(result => {
|
|
170
|
+
console.log(result)
|
|
171
|
+
})
|
|
172
|
+
```
|
|
173
|
+
- Return result example:
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"id": 1004,
|
|
178
|
+
"macAddress": "54-48-10-D9-BB-27_D8-9C-67-6D-DA-B3_D8-9C-67-6D-DA-B4",
|
|
179
|
+
"ipAddress": "192.168.1.136",
|
|
180
|
+
"masterIpAddress": "",
|
|
181
|
+
"status": 1
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
-Return results:
|
|
185
|
+
- `macAddress`: Host MAC address
|
|
186
|
+
- `ipAddress`: host IP address
|
|
187
|
+
- `masterIpAddress`: Master IP address, used when multiple hosts form a host group
|
|
188
|
+
- `status`: 1 means online, 0 means offline
|
|
189
|
+
|
|
190
|
+
### CoreAPI.getVolume
|
|
191
|
+
##### Get the volume
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
CoreAPI.getVolume(callback);
|
|
195
|
+
```
|
|
196
|
+
- callback: callback function
|
|
197
|
+
|
|
198
|
+
##### Example:
|
|
199
|
+
|
|
200
|
+
```js
|
|
201
|
+
CoreAPI.getVolume(result => {
|
|
202
|
+
console.log(result)
|
|
203
|
+
})
|
|
204
|
+
```
|
|
205
|
+
- Return result example:
|
|
206
|
+
|
|
207
|
+
```js
|
|
208
|
+
10
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### CoreAPI.setVolume
|
|
212
|
+
##### Set the volume
|
|
213
|
+
|
|
214
|
+
```js
|
|
215
|
+
CoreAPI.setVolume(value,callback)
|
|
216
|
+
```
|
|
217
|
+
- value: volume (0-100)
|
|
218
|
+
- callback: callback function
|
|
219
|
+
|
|
220
|
+
##### Example:
|
|
221
|
+
|
|
222
|
+
```js
|
|
223
|
+
CoreAPI.setVolume(70,result => {
|
|
224
|
+
console.log(result)
|
|
225
|
+
})
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
- Return result example:
|
|
229
|
+
|
|
230
|
+
```js
|
|
231
|
+
success
|
|
232
|
+
```
|
|
233
|
+
### CoreAPI.shell
|
|
234
|
+
##### Shell command execution
|
|
235
|
+
|
|
236
|
+
```js
|
|
237
|
+
CoreAPI.shell(command, callback)
|
|
238
|
+
```
|
|
239
|
+
- command: command
|
|
240
|
+
- callback: callback function
|
|
241
|
+
|
|
242
|
+
##### Example:
|
|
243
|
+
|
|
244
|
+
```js
|
|
245
|
+
CoreAPI.shell('sudo reboot', null) //Restart the system
|
|
246
|
+
```
|