faucamp / python-gsmmodem

Python module to control a GSM modem attached to the system: send/receive SMS messages, handle calls, etc
GNU Lesser General Public License v3.0
386 stars 303 forks source link

please do not enable delivery report by default #82

Open sherpya opened 7 years ago

sherpya commented 7 years ago

the line self.write('AT+CSMP=49,167,0,0', parseError=False) # Enable delivery reports

enables delivery reports that have often a cost

If I'm correct it should be self.write('AT+CSMP=17,167,0,0', parseError=False) # Enable delivery reports

anyway it would be better to have it configurable

sherpya commented 7 years ago

I've also noticed encodeSmsSubmitPdu has a default keyword arg requestStatusReport=True

tomchy commented 7 years ago

Please switch to the updated fork :slightly_smiling_face: There is optional parameter "requestDelivery=True" inside GsmModem class which sets the option that you have mentioned:

self.write('AT+CSMP=17,167,0,0', parseError=False) # Not enable delivery reports

And you're right - it is related to encodeSmsSubmitPdu, which is used inside sendSms method of GsmModem class:

# Encode text into PDUs
pdus = encodeSmsSubmitPdu(destination, text, reference=self._smsRef, sendFlash=sendFlash)

and should be changed into:

# Encode text into PDUs
pdus = encodeSmsSubmitPdu(destination, text, reference=self._smsRef, sendFlash=sendFlash, requestStatusReport=self.requestDelivery)

It would be also nice to take this flag into account when user sets waitForDeliveryReport=True (sendSms method parameter) while reports are disabled.

Could you apply those changed, verify them and make a pull request to the mentioned above repository?