Commit 7372470439f1a60fafa9a54ac12ceef4d186607f

Authored by Adhidarma Hadiwinoto
1 parent 04fcfc6b4b
Exists in master

Disable message counter

Showing 2 changed files with 10 additions and 21 deletions Side-by-side Diff

... ... @@ -21,7 +21,7 @@ const dbCops = require('./db-cops');
21 21 const reportSender = require('./report-sender');
22 22 // const msisdn = require('./msisdn');
23 23 const registerModem = require('./register-modem');
24   -const counters = require('./counters');
  24 +// const counters = require('./counters');
25 25  
26 26 const modemInfo = {
27 27 device: config.modem.device,
... ... @@ -36,8 +36,8 @@ const modemInfo = {
36 36 signalStrength: null,
37 37 signalStrengthTs: null,
38 38 signalStrengthTsReadable: null,
39   - messageSentCounter: null,
40   - messageReceivedCounter: null,
  39 + // messageSentCounter: null,
  40 + // messageReceivedCounter: null,
41 41 };
42 42  
43 43 let lastTs = new Date();
... ... @@ -61,17 +61,6 @@ function writeToPort(data) {
61 61 });
62 62 }
63 63  
64   -// eslint-disable-next-line no-unused-vars
65   -async function writeToPortAndWaitForOK(data) {
66   - await mutex.setLockWaitForCommand();
67   - const result = await writeToPort(data);
68   -
69   - await mutex.setLockWaitForCommand();
70   - mutex.releaseLockWaitForCommand();
71   -
72   - return result;
73   -}
74   -
75 64 async function readSMS(slot) {
76 65 const parserCMGR = new ParserRegex({ regex: REGEX_WAIT_FOR_OK_OR_ERROR });
77 66 parserCMGR.on('data', (data) => {
... ... @@ -148,7 +137,7 @@ parserReadLine.on('data', (data) => {
148 137 registerModem(modemInfo);
149 138 }
150 139 } else if (data.indexOf('+CMTI: ') === 0) {
151   - counters.increment('MESSAGE_RECEIVED', modemInfo);
  140 + // counters.increment('MESSAGE_RECEIVED', modemInfo);
152 141 onIncomingSMS(data);
153 142 } else if (data.indexOf('+COPS: ') === 0) {
154 143 onCOPS(data);
... ... @@ -292,7 +281,7 @@ async function sendSMS(destination, msg) {
292 281 await mutex.setLockWaitForCommand();
293 282  
294 283 logger.info('Sending message', { destination, msg });
295   - counters.increment('MESSAGE_SENT', modemInfo);
  284 + // counters.increment('MESSAGE_SENT', modemInfo);
296 285  
297 286 const correctedDestination = `+${destination}`.replace(/^0/, '62').replace(/^\++/, '+');
298 287  
lib/register-modem.js
... ... @@ -8,7 +8,7 @@ const locks = require('locks');
8 8 const config = require('komodo-sdk/config');
9 9 const logger = require('komodo-sdk/logger');
10 10  
11   -const counters = require('./counters');
  11 +// const counters = require('./counters');
12 12  
13 13 const mutex = locks.createMutex();
14 14  
... ... @@ -26,9 +26,9 @@ async function sender(modemInfo) {
26 26 logger.info('Getting message counters before registering modem');
27 27  
28 28 // eslint-disable-next-line no-param-reassign
29   - modemInfo.messageSentCounter = await counters.get('MESSAGE_SENT', modemInfo);
  29 + // modemInfo.messageSentCounter = await counters.get('MESSAGE_SENT', modemInfo);
30 30 // eslint-disable-next-line no-param-reassign
31   - modemInfo.messageReceivedCounter = await counters.get('MESSAGE_RECEIVED', modemInfo);
  31 + // modemInfo.messageReceivedCounter = await counters.get('MESSAGE_RECEIVED', modemInfo);
32 32  
33 33 const requestOptions = {
34 34 url: reportUrl(),
... ... @@ -44,8 +44,8 @@ async function sender(modemInfo) {
44 44 report_port: config.http_command_server.listen_port,
45 45 report_apikey: config.http_command_server.apikey,
46 46 report_path_sms: '/sms',
47   - counter_sent: modemInfo.messageSentCounter,
48   - counter_received: modemInfo.messageReceivedCounter,
  47 + // counter_sent: modemInfo.messageSentCounter,
  48 + // counter_received: modemInfo.messageReceivedCounter,
49 49 },
50 50 };
51 51