sim800
Version:
A modern and opiniated module for SIM800 GSM modems ( SIM800 / SIM800L ).
22 lines • 1.05 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.deliveryReportSubscriberFactory = void 0;
const node_pdu_1 = require("node-pdu");
const deliveryReportSubscriberFactory = (client, logger) => (data) => {
if (data.includes('+CDS:')) {
client.receivingDeliveryReport = true;
// This is the start of a delivery report, we need to monitor the next line
}
else if (client.receivingDeliveryReport) {
client.receivingDeliveryReport = false;
// This is the end of a delivery report, we need to parse the data
const result = (0, node_pdu_1.parse)(data);
if (result instanceof node_pdu_1.Report) {
console.log(`DELIVERY REPORT FOR MESSAGE #${result.reference}`);
console.log(`DELIVERY REPORT RECEIVED AT, ${result.dateTime.getIsoString()}`);
console.log('STATUS', result.status);
}
}
};
exports.deliveryReportSubscriberFactory = deliveryReportSubscriberFactory;
//# sourceMappingURL=delivery-report-subscriber.js.map