From f7ee8f01ffd7fe04c32cd94775054d242174f59d Mon Sep 17 00:00:00 2001
From: Paul Fertser <fercerpav@gmail.com>
Date: Mon, 2 Feb 2009 17:10:31 +0300
Subject: [PATCH] Preliminary support for SMS message delivery reports
I couldn't find enough reliable information for that type of PDU, therefore
support is incomplete for now.
---
framework/subsystems/ogsmd/device.py | 5 ++++
framework/subsystems/ogsmd/gsm/sms.py | 21 +++++++++++++++----
.../ogsmd/modems/abstract/unsolicited.py | 8 +++++++
3 files changed, 29 insertions(+), 5 deletions(-)
diff --git a/framework/subsystems/ogsmd/device.py b/framework/subsystems/ogsmd/device.py
index 914fd7d..3a0e898 100644
|
a
|
b
|
class Device( resource.Resource ): |
| 374 | 374 | def IncomingMessage( self, address, text, features ): |
| 375 | 375 | logger.info( "incoming message (unbuffered) from %s", address ) |
| 376 | 376 | |
| | 377 | @resource.queuedsignal |
| | 378 | @dbus.service.signal( DBUS_INTERFACE_SMS, "ss" ) |
| | 379 | def IncomingMessageReceipt( self, number, text ): |
| | 380 | logger.info( "incoming message delivery report from %s", number ) |
| | 381 | |
| 377 | 382 | # |
| 378 | 383 | # dbus org.freesmartphone.GSM.Network |
| 379 | 384 | # |
diff --git a/framework/subsystems/ogsmd/gsm/sms.py b/framework/subsystems/ogsmd/gsm/sms.py
index 43053b9..58a96a9 100644
|
a
|
b
|
class SMS(object): |
| 100 | 100 | sms = cls( smstype ) |
| 101 | 101 | offset = 0 |
| 102 | 102 | |
| 103 | | if sms.type == "sms-deliver" or sms.type == "sms-submit": |
| | 103 | if sms.type == "sms-deliver" or sms.type == "sms-submit" or sms.type == "sms-status-report": |
| 104 | 104 | # SCA - Service Center address |
| 105 | 105 | sca_len = bytes[offset] |
| 106 | 106 | offset += 1 |
| … |
… |
class SMS(object): |
| 124 | 124 | sms.pdu_mms = sms.pdu_rd |
| 125 | 125 | elif sms.type == "sms-submit-report": |
| 126 | 126 | sms.pdu_udhi = pdu_type & 0x04 != 0 |
| | 127 | elif sms.type == "sms-status-report": |
| | 128 | sms.pdu_udhi = pdu_type & 0x40 != 0 |
| | 129 | sms.pdu_srr = pdu_type & 0x20 != 0 |
| | 130 | sms.pdu_mms = pdu_type & 0x04 != 0 |
| 127 | 131 | |
| 128 | 132 | offset += 1 |
| 129 | | if sms.type == "sms-submit": |
| | 133 | if sms.type == "sms-submit" or sms.type == "sms-status-report": |
| 130 | 134 | # MR - Message Reference |
| 131 | 135 | sms.mr = bytes[offset] |
| 132 | 136 | offset += 1 |
| 133 | 137 | |
| 134 | 138 | # OA/DA - Originating or Destination Address |
| 135 | 139 | # WARNING, the length is coded in digits of the number, not in octets occupied! |
| 136 | | if sms.type == "sms-submit" or sms.type == "sms-deliver": |
| | 140 | if sms.type == "sms-submit" or sms.type == "sms-deliver" or sms.type == "sms-status-report": |
| 137 | 141 | oa_len = 1 + (bytes[offset] + 1) / 2 |
| 138 | 142 | offset += 1 |
| 139 | 143 | sms.oa = PDUAddress.decode( bytes[offset:offset+oa_len] ) |
| 140 | 144 | sms.da = sms.oa |
| 141 | 145 | |
| 142 | 146 | offset += oa_len |
| | 147 | |
| | 148 | if sms.type == "sms-status-report": |
| | 149 | # Skip SCTS, DT (discharge time), ST, PI FIXME |
| | 150 | offset += 4 |
| | 151 | |
| 143 | 152 | # PID - Protocol identifier |
| 144 | 153 | sms.pid = bytes[offset] |
| 145 | 154 | |
| … |
… |
class SMS(object): |
| 185 | 194 | |
| 186 | 195 | offset += 7 |
| 187 | 196 | |
| 188 | | if sms.type == "sms-submit-report" and not sms.pdu_udli: |
| | 197 | if ( sms.type == "sms-submit-report" and not sms.pdu_udli ) \ |
| | 198 | or sms.type == "sms-status-report": |
| | 199 | # FIXME can sms-status-report have userdata? |
| 189 | 200 | return sms |
| 190 | 201 | |
| 191 | 202 | # UD - User Data |
| … |
… |
class SMS(object): |
| 198 | 209 | self.type = type |
| 199 | 210 | self.sca = False |
| 200 | 211 | self.pdu_udhi = False |
| 201 | | self.pdu_srr = False |
| | 212 | self.pdu_srr = True # Request delivery report |
| 202 | 213 | self.pdu_sri = False |
| 203 | 214 | self.pdu_rp = False |
| 204 | 215 | self.pdu_vpf = 0 |
diff --git a/framework/subsystems/ogsmd/modems/abstract/unsolicited.py b/framework/subsystems/ogsmd/modems/abstract/unsolicited.py
index 2bd8f6d..715e6f3 100644
|
a
|
b
|
class AbstractUnsolicitedResponseDelegate( object ): |
| 148 | 148 | sms = ogsmd.gsm.sms.SMS.decode( pdu, "sms-deliver" ) |
| 149 | 149 | self._object.IncomingMessage( str(sms.oa), sms.ud, sms.featureMap ) |
| 150 | 150 | |
| | 151 | # +CDS: <PDU size>\r\n<PDU> |
| | 152 | def plusCDS( self, righthandside, pdu ): |
| | 153 | """ |
| | 154 | Incoming delivery report |
| | 155 | """ |
| | 156 | sms = ogsmd.gsm.sms.SMS.decode( pdu, "sms-status-report" ) |
| | 157 | self._object.IncomingMessageReceipt( str(sms.oa), "delivered" ) |
| | 158 | |
| 151 | 159 | # +CMTI: "SM",7 |
| 152 | 160 | def plusCMTI( self, righthandside ): |
| 153 | 161 | """ |