@starak/sim800c 0.0.1
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/LICENSE +21 -0
- package/README.md +36 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +189 -0
- package/dist/index.js.map +1 -0
- package/package.json +24 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Ståle Raknes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# SIM800C
|
|
2
|
+
Simple library for sending and receiving messages with sim800c
|
|
3
|
+
|
|
4
|
+
### Installation
|
|
5
|
+
```bash
|
|
6
|
+
$ npm install @starak/sim800c
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
### Usage
|
|
10
|
+
```js
|
|
11
|
+
const {GSM, SerialPort} = require('@starak/sim800c');
|
|
12
|
+
|
|
13
|
+
(async () => {
|
|
14
|
+
let SIM_PATH;
|
|
15
|
+
await SerialPort.list().then((ports) => {
|
|
16
|
+
const port = ports.find(p => p.path.includes('tty.usbserial'));
|
|
17
|
+
if(port){
|
|
18
|
+
console.log('Using SIM', port.path);
|
|
19
|
+
SIM_PATH = port.path;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if(SIM_PATH) {
|
|
24
|
+
const gsm = new GSM(SIM_PATH);
|
|
25
|
+
await gsm.ready();
|
|
26
|
+
await gsm.sendMessage('55512345', 'Hello from SIM800C');
|
|
27
|
+
console,log('Message sent');
|
|
28
|
+
gsm.on('newMessage', async (message) => {
|
|
29
|
+
console.log('newMessage', message);
|
|
30
|
+
await gsm.deleteMessage(message.index);
|
|
31
|
+
});
|
|
32
|
+
}else{
|
|
33
|
+
throw new Error('No SIM found');
|
|
34
|
+
}
|
|
35
|
+
})();
|
|
36
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import EventEmitter from "events";
|
|
3
|
+
import { SerialPort, SerialPortMock } from "serialport";
|
|
4
|
+
import { GsmMessage } from "./types";
|
|
5
|
+
export * from "serialport";
|
|
6
|
+
export declare class GSM extends EventEmitter {
|
|
7
|
+
port: SerialPort | SerialPortMock;
|
|
8
|
+
_ready: Promise<void>;
|
|
9
|
+
constructor(path: string);
|
|
10
|
+
ready(): Promise<void>;
|
|
11
|
+
private onDataHandler;
|
|
12
|
+
private sendCommand;
|
|
13
|
+
reset(): Promise<void>;
|
|
14
|
+
private setTextMode;
|
|
15
|
+
private setPDUMode;
|
|
16
|
+
private setRecipient;
|
|
17
|
+
private setMessage;
|
|
18
|
+
sendMessage(number: string, message: string): Promise<void>;
|
|
19
|
+
deleteMessage(index: number): Promise<void>;
|
|
20
|
+
deleteAllMessages(): Promise<void>;
|
|
21
|
+
private Messages;
|
|
22
|
+
getMessages(): Promise<GsmMessage[]>;
|
|
23
|
+
getMessage(index: number): Promise<GsmMessage>;
|
|
24
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// noinspection JSUnusedGlobalSymbols
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.GSM = void 0;
|
|
22
|
+
const events_1 = __importDefault(require("events"));
|
|
23
|
+
const serialport_1 = require("serialport");
|
|
24
|
+
const pdu_ts_1 = require("pdu.ts");
|
|
25
|
+
__exportStar(require("serialport"), exports);
|
|
26
|
+
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
27
|
+
class GSM extends events_1.default {
|
|
28
|
+
constructor(path) {
|
|
29
|
+
super();
|
|
30
|
+
this.onDataHandler = async (data) => {
|
|
31
|
+
var _a;
|
|
32
|
+
if (data.includes('+CMTI:')) { // New Message
|
|
33
|
+
const index = data.toString().split(',')[1];
|
|
34
|
+
const message = await this.getMessage(+index);
|
|
35
|
+
if (message) {
|
|
36
|
+
if (message.message.multipart && (message.message.parts || 0) > (((_a = message.message.parts_raw) === null || _a === void 0 ? void 0 : _a.length) || 0)) {
|
|
37
|
+
// We need to wait for the rest of the message
|
|
38
|
+
await sleep(500);
|
|
39
|
+
setImmediate(() => this.onDataHandler(data));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
this.emit('newMessage', message);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
this.port = new serialport_1.SerialPort({ path: path, baudRate: 115200 });
|
|
48
|
+
this.port.on('open', async () => {
|
|
49
|
+
await this.reset();
|
|
50
|
+
this.emit('ready');
|
|
51
|
+
});
|
|
52
|
+
this.port.on('data', (data) => {
|
|
53
|
+
this.emit('data', data);
|
|
54
|
+
setImmediate(() => this.onDataHandler(data));
|
|
55
|
+
});
|
|
56
|
+
this._ready = new Promise((resolve) => {
|
|
57
|
+
this.on('ready', resolve);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async ready() {
|
|
61
|
+
return this._ready;
|
|
62
|
+
}
|
|
63
|
+
async sendCommand(command, terminator = '\r') {
|
|
64
|
+
const { port } = this;
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
const listener = async (d) => {
|
|
67
|
+
data += d.toString();
|
|
68
|
+
if (data.includes('OK') || data.includes('>')) {
|
|
69
|
+
port.removeListener('data', listener);
|
|
70
|
+
resolve();
|
|
71
|
+
}
|
|
72
|
+
else if (data.includes('ERROR')) {
|
|
73
|
+
port.removeListener('data', listener);
|
|
74
|
+
reject('error');
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
//console.log('none', command, data);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
let data = '';
|
|
81
|
+
port.on('data', listener);
|
|
82
|
+
port.write(`${command}${terminator}`);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async reset() {
|
|
86
|
+
return this.sendCommand('ATZ');
|
|
87
|
+
}
|
|
88
|
+
async setTextMode() {
|
|
89
|
+
return this.sendCommand('AT+CMGF=1');
|
|
90
|
+
}
|
|
91
|
+
async setPDUMode() {
|
|
92
|
+
return this.sendCommand('AT+CMGF=0');
|
|
93
|
+
}
|
|
94
|
+
async setRecipient(number) {
|
|
95
|
+
return this.sendCommand(`AT+CMGS="${number}"`);
|
|
96
|
+
}
|
|
97
|
+
async setMessage(message) {
|
|
98
|
+
return this.sendCommand(`${message}`, '\x1a');
|
|
99
|
+
}
|
|
100
|
+
async sendMessage(number, message) {
|
|
101
|
+
await this.reset();
|
|
102
|
+
await this.setTextMode();
|
|
103
|
+
await this.setRecipient(number);
|
|
104
|
+
await this.setMessage(message);
|
|
105
|
+
}
|
|
106
|
+
async deleteMessage(index) {
|
|
107
|
+
var _a;
|
|
108
|
+
const messages = await this.getMessages();
|
|
109
|
+
const current = messages.find(m => m.index === index);
|
|
110
|
+
let indexes = [];
|
|
111
|
+
if (current && current.message.multipart) {
|
|
112
|
+
indexes = ((_a = current.message.parts_raw) === null || _a === void 0 ? void 0 : _a.map(m => m.index)) || [];
|
|
113
|
+
}
|
|
114
|
+
else if (current) {
|
|
115
|
+
indexes = [index];
|
|
116
|
+
}
|
|
117
|
+
for (const i of indexes) {
|
|
118
|
+
await this.sendCommand(`AT+CMGD=${i}`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async deleteAllMessages() {
|
|
122
|
+
return this.sendCommand('AT+CMGD=1,4');
|
|
123
|
+
}
|
|
124
|
+
async Messages() {
|
|
125
|
+
await this.reset();
|
|
126
|
+
await this.setPDUMode();
|
|
127
|
+
const { port } = this;
|
|
128
|
+
return new Promise((resolve, reject) => {
|
|
129
|
+
const listener = async (d) => {
|
|
130
|
+
data += d.toString();
|
|
131
|
+
const lines = data.split('\r\n');
|
|
132
|
+
data = lines.pop() || '';
|
|
133
|
+
for (const line of lines) {
|
|
134
|
+
if (line.includes('OK')) {
|
|
135
|
+
port.removeListener('data', listener);
|
|
136
|
+
resolve(msgs.map(m => ({ ...m, message: pdu_ts_1.PDUParser.Parse(m.raw) })));
|
|
137
|
+
}
|
|
138
|
+
else if (line.includes('ERROR')) {
|
|
139
|
+
port.removeListener('data', listener);
|
|
140
|
+
reject();
|
|
141
|
+
}
|
|
142
|
+
else if (line.startsWith('+CMGL: ')) {
|
|
143
|
+
const [index, state, raw] = line.replace(/^\+CMGL:\s/, '')
|
|
144
|
+
.split(',')
|
|
145
|
+
.map(s => s.replace(/"/g, ''));
|
|
146
|
+
current = { index: +index, state, raw, message: {} };
|
|
147
|
+
msgs.push(current);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
current.raw += line;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
let data = '', msgs = [], current = {};
|
|
155
|
+
port.on('data', listener);
|
|
156
|
+
port.write('AT+CMGL=4\r');
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
async getMessages() {
|
|
160
|
+
const messages = await this.Messages();
|
|
161
|
+
return messages.map(m => {
|
|
162
|
+
if (m.message.udh) {
|
|
163
|
+
if (m.message.udh.current_part === 1) {
|
|
164
|
+
const parts = messages
|
|
165
|
+
.filter(m2 => m2.message.udh)
|
|
166
|
+
.filter(m2 => m2.message.udh.reference_number === m.message.udh.reference_number);
|
|
167
|
+
return {
|
|
168
|
+
...m,
|
|
169
|
+
message: {
|
|
170
|
+
...m.message,
|
|
171
|
+
text: parts.map(m2 => m2.message.text).join(''),
|
|
172
|
+
multipart: true,
|
|
173
|
+
parts: m.message.udh.parts,
|
|
174
|
+
parts_raw: parts
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return undefined;
|
|
179
|
+
}
|
|
180
|
+
return { ...m, multipart: false };
|
|
181
|
+
}).filter(m => m !== undefined);
|
|
182
|
+
}
|
|
183
|
+
async getMessage(index) {
|
|
184
|
+
const messages = await this.getMessages();
|
|
185
|
+
return messages.find(m => m.index === index);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
exports.GSM = GSM;
|
|
189
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,qCAAqC;;;;;;;;;;;;;;;;;;;;AAErC,oDAAkC;AAClC,2CAAsD;AACtD,mCAAiC;AAGjC,6CAA2B;AAE3B,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAE9E,MAAa,GAAI,SAAQ,gBAAY;IAGjC,YAAY,IAAY;QACpB,KAAK,EAAE,CAAC;QAmBJ,kBAAa,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;;YAC3C,IAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAC,EAAE,cAAc;gBACvC,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC5C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC;gBAC9C,IAAG,OAAO,EAAC;oBACP,IAAG,OAAO,CAAC,OAAO,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA,MAAA,OAAO,CAAC,OAAO,CAAC,SAAS,0CAAE,MAAM,KAAI,CAAC,CAAC,EAAG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AS,EAAE,KAAK,EAAC,CAAC;QACpC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAiB,CAAC;IACpD,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,KAAa;QACjC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1C,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAe,CAAC;IAC/D,CAAC;CACJ;AAxKD,kBAwKC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@starak/sim800c",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Simple library for sending and receiving messages with sim800c",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist/**/*"
|
|
8
|
+
],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [],
|
|
13
|
+
"author": "starak",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"pdu.ts": "^1.1.4",
|
|
17
|
+
"serialport": "^10.5.0"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@types/node": "^17.0.21",
|
|
21
|
+
"ts-node": "^10.9.1",
|
|
22
|
+
"typescript": "^4.9.5"
|
|
23
|
+
}
|
|
24
|
+
}
|