diff --git a/pycrate_mobile/NAS.py b/pycrate_mobile/NAS.py index daff218..bf4067d 100644 --- a/pycrate_mobile/NAS.py +++ b/pycrate_mobile/NAS.py @@ -39,6 +39,7 @@ from .TS44018_RR import * from .TS24011_PPSMS import * from .TS23040_SMS import * +from .TS23041_CBS import * from .TS23038 import * from .TS24008_GMM import * diff --git a/pycrate_mobile/TS23041_CBS.py b/pycrate_mobile/TS23041_CBS.py index e5d7813..acbe50b 100644 --- a/pycrate_mobile/TS23041_CBS.py +++ b/pycrate_mobile/TS23041_CBS.py @@ -28,8 +28,11 @@ #*/ __all__ = [ - 'CBS_WarningType_dict', + 'CBSWarningType_dict', + 'CBSWarningType', + 'CBSWarningSecurityInfo', 'CBS_MessageId_dict', + 'encode_cbs_pages' ] #------------------------------------------------------------------------------# @@ -37,7 +40,12 @@ __all__ = [ # release 13 (d30) #------------------------------------------------------------------------------# -from .TS23038 import * +from struct import pack, unpack + +from pycrate_core.elt import * +from pycrate_core.base import * +from .TS23038 import * +from .TS23040_SMS import TP_SCTS #------------------------------------------------------------------------------# @@ -45,7 +53,7 @@ from .TS23038 import * # TS 23.041, section 9.3.24 #------------------------------------------------------------------------------# -CBS_WarningType_dict = { +CBSWarningType_dict = { 0 : 'Earthquake', 1 : 'Tsunami', 2 : 'Earthquake and Tsunami', @@ -54,6 +62,26 @@ CBS_WarningType_dict = { #5-0x7f: future use } +class CBSWarningType(Envelope): + _GEN = ( + Uint('Value', bl=7, dic=CBSWarningType_dict), + Uint('EmergencyUserAlert', bl=1), + Uint('Popup', bl=1), + Uint('pad', bl=7, rep=REPR_HEX) + ) + + +#------------------------------------------------------------------------------# +# Warning-Security-Information +# TS 23.041, section 9.3.25 +#------------------------------------------------------------------------------# + +class CBSWarningSecurityInfo(Envelope): + _GEN = ( + TP_SCTS(), + Buf('DigitalSignature', bl=344, rep=REPR_HEX) + ) + #------------------------------------------------------------------------------# # Message Identifier @@ -85,7 +113,7 @@ CBS_MessageId_dict = { # also EU-Alert Level 3 / Korean Public Alert System (KPAS) Class 1 4374: 'CMAS CBS for CMAS Severe Alerts with Severity of Extreme, Urgency of Expected, and Certainty of Likely', # also EU-Alert Level 3 / Korean Public Alert System (KPAS) Class 1 - 4375: 'CMAS CBS for CMAS Severe Alerts with Severity of Severe, Urgency of Immediate, and Certainty of Observed' + 4375: 'CMAS CBS for CMAS Severe Alerts with Severity of Severe, Urgency of Immediate, and Certainty of Observed', # also EU-Alert Level 3 / Korean Public Alert System (KPAS) Class 1 4376: 'CMAS CBS for CMAS Severe Alerts with Severity of Severe, Urgency of Immediate, and Certainty of Likely', # also EU-Alert Level 3 / Korean Public Alert System (KPAS) Class 1 @@ -108,7 +136,7 @@ CBS_MessageId_dict = { # also EU-Alert Level 3 / Korean Public Alert System (KPAS) Class 1 4387: 'CMAS CBS for CMAS Severe Alerts with Severity of Extreme, Urgency of Expected, and Certainty of Likely for additional languages', # also EU-Alert Level 3 / Korean Public Alert System (KPAS) Class 1 - 4388: 'CMAS CBS for CMAS Severe Alerts with Severity of Severe, Urgency of Immediate, and Certainty of Observed for additional languages' + 4388: 'CMAS CBS for CMAS Severe Alerts with Severity of Severe, Urgency of Immediate, and Certainty of Observed for additional languages', # also EU-Alert Level 3 / Korean Public Alert System (KPAS) Class 1 4389: 'CMAS CBS for CMAS Severe Alerts with Severity of Severe, Urgency of Immediate, and Certainty of Likely for additional languages', # also EU-Alert Level 3 / Korean Public Alert System (KPAS) Class 1 @@ -129,3 +157,21 @@ CBS_MessageId_dict = { #45056-65534: future operator specific 65535: 'reserved', # used with SIM, not settable by MMI } + + +#------------------------------------------------------------------------------# +# Warning Message Content E-UTRAN +# TS 23.041, section 9.3.35 +#------------------------------------------------------------------------------# + +def encode_cbs_pages(msg, dcs7b=True, char_preamb=''): + if dcs7b: + pages = encode_7b_cbs(msg, char_preamb) + else: + pages = encode_cbs(msg) + msg = pack('>B', len(pages)) + for page, page_len in pages: + msg += page + pack('>B', page_len) + return msg + + diff --git a/pycrate_mobile/TS24007.py b/pycrate_mobile/TS24007.py index 46dd58f..2ca57b2 100644 --- a/pycrate_mobile/TS24007.py +++ b/pycrate_mobile/TS24007.py @@ -53,7 +53,7 @@ __all__ = [ from binascii import hexlify from pycrate_core.utils import * -from pycrate_core.elt import Element, Envelope, REPR_RAW, REPR_HEX, REPR_BIN +from pycrate_core.elt import Element, Envelope, EltErr, REPR_RAW, REPR_HEX, REPR_BIN from pycrate_core.base import * from pycrate_core.repr import * from pycrate_csn1.csnobj import CSN1Obj diff --git a/pycrate_mobile/__init__.py b/pycrate_mobile/__init__.py index 49ca87d..4921843 100644 --- a/pycrate_mobile/__init__.py +++ b/pycrate_mobile/__init__.py @@ -28,6 +28,6 @@ __all__ = ['GSMTAP', 'MCC_MNC', 'PPP', 'SIGTRAN', 'TS24007', 'NAS', 'NASLTE', 'TS24008_IE', 'TS24008_MM', 'TS24008_GMM', 'TS24008_CC', 'TS24008_SM', - 'TS23038', 'TS23040_SMS', 'TS24011_PPSMS', + 'TS23038', 'TS23040_SMS', 'TS23041_CBS', 'TS24011_PPSMS', 'TS24301_IE', 'TS24301_NAS', 'TS24301_EMM', 'TS24301_ESM'] __version__ = '0.2.0'