def sendSms(self, destination, text, waitForDeliveryReport=False, deliveryTimeout=15, sendFlash=False):
        """ Send an SMS text message
        
        :param destination: the recipient's phone number
        :type destination: str
        :param text: the message text
        :type text: str
        :param waitForDeliveryReport: if True, this method blocks until a delivery report is received for the sent message
        :type waitForDeliveryReport: boolean
        :param deliveryReport: the maximum time in seconds to wait for a delivery report (if "waitForDeliveryReport" is True)
        :type deliveryTimeout: int or float 
        
        :raise CommandError: if an error occurs while attempting to send the message
        :raise TimeoutException: if the operation times out
        """
        if self._smsTextMode:
            self.write('AT+CMGS="{0}"'.format(destination), timeout=3, expectedResponseTermSeq='> ')
            result = lineStartingWith('+CMGS:', self.write(text, timeout=15, writeTerm=chr(26)))
        else:
            pdus = encodeSmsSubmitPdu(destination, text, reference=self._smsRef, sendFlash=sendFlash)
            for pdu in pdus:
                self.write('AT+CMGS={0}'.format(pdu.tpduLength), timeout=3, expectedResponseTermSeq='> ')
                result = lineStartingWith('+CMGS:', self.write(str(pdu), timeout=15, writeTerm=chr(26))) # example: +CMGS: xx
        if result == None:
            raise CommandError('Modem did not respond with +CMGS response')
        reference = int(result[7:])
        self._smsRef = reference + 1
        if self._smsRef > 255:
            self._smsRef = 0
        sms = SentSms(destination, text, reference)
        # Add a weak-referenced entry for this SMS (allows us to update the SMS state if a status report is received)
        self.sentSms[reference] = sms
        if waitForDeliveryReport:
            self._smsStatusReportEvent = threading.Event()
            if self._smsStatusReportEvent.wait(deliveryTimeout):
                self._smsStatusReportEvent = None
            else: # Response timed out
                self._smsStatusReportEvent = None
                raise TimeoutException()
        return sms
def sendSms ( self , destination , text , waitForDeliveryReport = False , deliveryTimeout = 15 , sendFlash = False ) : if self . _smsTextMode : self . write ( 'AT+CMGS="{0}"' . format ( destination ) , timeout = 3 , expectedResponseTermSeq = '> ' ) result = lineStartingWith ( '+CMGS:' , self . write ( text , timeout = 15 , writeTerm = chr ( 26 ) ) ) else : pdus = encodeSmsSubmitPdu ( destination , text , reference = self . _smsRef , sendFlash = sendFlash ) for pdu in pdus : self . write ( 'AT+CMGS={0}' . format ( pdu . tpduLength ) , timeout = 3 , expectedResponseTermSeq = '> ' ) result = lineStartingWith ( '+CMGS:' , self . write ( str ( pdu ) , timeout = 15 , writeTerm = chr ( 26 ) ) ) if result == None : raise CommandError ( 'Modem did not respond with +CMGS response' ) reference = int ( result [ 7 : ] ) self . _smsRef = reference + 1 if self . _smsRef > 255 : self . _smsRef = 0 sms = SentSms ( destination , text , reference ) self . sentSms [ reference ] = sms if waitForDeliveryReport : self . _smsStatusReportEvent = threading . Event ( ) if self . _smsStatusReportEvent . wait ( deliveryTimeout ) : self . _smsStatusReportEvent = None else : self . _smsStatusReportEvent = None raise TimeoutException ( ) return sms
Send an SMS text message
        
        :param destination: the recipient's phone number
        :type destination: str
        :param text: the message text
        :type text: str
        :param waitForDeliveryReport: if True, this method blocks until a delivery report is received for the sent message
        :type waitForDeliveryReport: boolean
        :param deliveryReport: the maximum time in seconds to wait for a delivery report (if "waitForDeliveryReport" is True)
        :type deliveryTimeout: int or float 
        
        :raise CommandError: if an error occurs while attempting to send the message
        :raise TimeoutException: if the operation times out