sim800
Version:
A modern and opiniated module for SIM800 GSM modems ( SIM800 / SIM800L ).
28 lines • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.deliveryReportInputSubscriberFactory = void 0;
const node_pdu_1 = require("node-pdu");
const sim_800_delivery_interface_1 = require("../interfaces/sim-800-delivery.interface");
const deliveryReportInputSubscriberFactory = (client, logger) => (data) => {
var _a;
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) {
(_a = logger.debug) === null || _a === void 0 ? void 0 : _a.call(logger, `Delivery report received for messageReference ${result.reference}`);
client.deliveryReportStream$.next({
date: new Date(result.dateTime.getIsoString()),
messageReference: result.reference,
status: sim_800_delivery_interface_1.Sim800DeliveryStatusMap[sim_800_delivery_interface_1.Sim800DeliveryRawStatusMap[result.status]],
detail: sim_800_delivery_interface_1.Sim800DeliveryRawStatusMap[result.status],
});
}
}
};
exports.deliveryReportInputSubscriberFactory = deliveryReportInputSubscriberFactory;
//# sourceMappingURL=delivery-report-input-subscriber.js.map