mirror of https://gerrit.osmocom.org/pysim
Move "suspend_uicc" command from pySim-shell to ts_102_221.py
The SUSPEND UICC command is a TS 102 221 (UICC) command, so move it to the UICC Card Profile. Also, make sure that any shell command sets specified in the CardProfile are actually installed during equip(). Change-Id: I574348951f06b749aeff986589186110580328bc
This commit is contained in:
parent
4e5aa304fc
commit
659781cbe1
|
@ -199,6 +199,11 @@ close_channel
|
||||||
:func: Iso7816Commands.close_chan_parser
|
:func: Iso7816Commands.close_chan_parser
|
||||||
|
|
||||||
|
|
||||||
|
TS 102 221 commands
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
These are commands as specified in ETSI TS 102 221, the core UICC specification.
|
||||||
|
|
||||||
suspend_uicc
|
suspend_uicc
|
||||||
~~~~~~~~~~~~
|
~~~~~~~~~~~~
|
||||||
This command allows you to perform the SUSPEND UICC command on the card. This is a relatively
|
This command allows you to perform the SUSPEND UICC command on the card. This is a relatively
|
||||||
|
@ -209,8 +214,8 @@ The pySim command just sends that SUSPEND UICC command and doesn't perform the f
|
||||||
including the electrical power down.
|
including the electrical power down.
|
||||||
|
|
||||||
.. argparse::
|
.. argparse::
|
||||||
:module: pySim-shell
|
:module: pySim.ts_102_221
|
||||||
:func: Iso7816Commands.suspend_uicc_parser
|
:func: CardProfileUICC.AddlShellCommands.suspend_uicc_parser
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -219,6 +219,9 @@ class PysimApp(cmd2.Cmd):
|
||||||
self._onchange_conserve_write(
|
self._onchange_conserve_write(
|
||||||
'conserve_write', False, self.conserve_write)
|
'conserve_write', False, self.conserve_write)
|
||||||
self._onchange_apdu_trace('apdu_trace', False, self.apdu_trace)
|
self._onchange_apdu_trace('apdu_trace', False, self.apdu_trace)
|
||||||
|
if self.rs.profile:
|
||||||
|
for cmd_set in self.rs.profile.shell_cmdsets:
|
||||||
|
self.register_command_set(cmd_set)
|
||||||
self.register_command_set(Iso7816Commands())
|
self.register_command_set(Iso7816Commands())
|
||||||
self.register_command_set(Ts102222Commands())
|
self.register_command_set(Ts102222Commands())
|
||||||
self.register_command_set(PySimCommands())
|
self.register_command_set(PySimCommands())
|
||||||
|
@ -283,6 +286,9 @@ class PysimApp(cmd2.Cmd):
|
||||||
@cmd2.with_category(CUSTOM_CATEGORY)
|
@cmd2.with_category(CUSTOM_CATEGORY)
|
||||||
def do_equip(self, opts):
|
def do_equip(self, opts):
|
||||||
"""Equip pySim-shell with card"""
|
"""Equip pySim-shell with card"""
|
||||||
|
if self.rs.profile:
|
||||||
|
for cmd_set in self.rs.profile.shell_cmdsets:
|
||||||
|
self.unregister_command_set(cmd_set)
|
||||||
rs, card = init_card(sl)
|
rs, card = init_card(sl)
|
||||||
self.equip(card, rs)
|
self.equip(card, rs)
|
||||||
|
|
||||||
|
@ -934,20 +940,6 @@ class Iso7816Commands(CommandSet):
|
||||||
fcp_dec = self._cmd.lchan.status()
|
fcp_dec = self._cmd.lchan.status()
|
||||||
self._cmd.poutput_json(fcp_dec)
|
self._cmd.poutput_json(fcp_dec)
|
||||||
|
|
||||||
suspend_uicc_parser = argparse.ArgumentParser()
|
|
||||||
suspend_uicc_parser.add_argument('--min-duration-secs', type=int, default=60,
|
|
||||||
help='Proposed minimum duration of suspension')
|
|
||||||
suspend_uicc_parser.add_argument('--max-duration-secs', type=int, default=24*60*60,
|
|
||||||
help='Proposed maximum duration of suspension')
|
|
||||||
|
|
||||||
# not ISO7816-4 but TS 102 221
|
|
||||||
@cmd2.with_argparser(suspend_uicc_parser)
|
|
||||||
def do_suspend_uicc(self, opts):
|
|
||||||
"""Perform the SUSPEND UICC command. Only supported on some UICC."""
|
|
||||||
(duration, token, sw) = self._cmd.card._scc.suspend_uicc(min_len_secs=opts.min_duration_secs,
|
|
||||||
max_len_secs=opts.max_duration_secs)
|
|
||||||
self._cmd.poutput(
|
|
||||||
'Negotiated Duration: %u secs, Token: %s, SW: %s' % (duration, token, sw))
|
|
||||||
|
|
||||||
class Proact(ProactiveHandler):
|
class Proact(ProactiveHandler):
|
||||||
def receive_fetch(self, pcmd: ProactiveCommand):
|
def receive_fetch(self, pcmd: ProactiveCommand):
|
||||||
|
|
|
@ -838,7 +838,8 @@ class CardProfileUICC(CardProfile):
|
||||||
}
|
}
|
||||||
|
|
||||||
super().__init__(name, desc='ETSI TS 102 221', cla="00",
|
super().__init__(name, desc='ETSI TS 102 221', cla="00",
|
||||||
sel_ctrl="0004", files_in_mf=files, sw=sw)
|
sel_ctrl="0004", files_in_mf=files, sw=sw,
|
||||||
|
shell_cmdsets = [self.AddlShellCommands()])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def decode_select_response(resp_hex: str) -> object:
|
def decode_select_response(resp_hex: str) -> object:
|
||||||
|
@ -852,6 +853,23 @@ class CardProfileUICC(CardProfile):
|
||||||
def match_with_card(scc: SimCardCommands) -> bool:
|
def match_with_card(scc: SimCardCommands) -> bool:
|
||||||
return match_uicc(scc)
|
return match_uicc(scc)
|
||||||
|
|
||||||
|
@with_default_category('TS 102 221 Specific Commands')
|
||||||
|
class AddlShellCommands(CommandSet):
|
||||||
|
suspend_uicc_parser = argparse.ArgumentParser()
|
||||||
|
suspend_uicc_parser.add_argument('--min-duration-secs', type=int, default=60,
|
||||||
|
help='Proposed minimum duration of suspension')
|
||||||
|
suspend_uicc_parser.add_argument('--max-duration-secs', type=int, default=24*60*60,
|
||||||
|
help='Proposed maximum duration of suspension')
|
||||||
|
|
||||||
|
# not ISO7816-4 but TS 102 221
|
||||||
|
@cmd2.with_argparser(suspend_uicc_parser)
|
||||||
|
def do_suspend_uicc(self, opts):
|
||||||
|
"""Perform the SUSPEND UICC command. Only supported on some UICC."""
|
||||||
|
(duration, token, sw) = self._cmd.card._scc.suspend_uicc(min_len_secs=opts.min_duration_secs,
|
||||||
|
max_len_secs=opts.max_duration_secs)
|
||||||
|
self._cmd.poutput(
|
||||||
|
'Negotiated Duration: %u secs, Token: %s, SW: %s' % (duration, token, sw))
|
||||||
|
|
||||||
|
|
||||||
class CardProfileUICCSIM(CardProfileUICC):
|
class CardProfileUICCSIM(CardProfileUICC):
|
||||||
"""Same as above, but including 2G SIM support"""
|
"""Same as above, but including 2G SIM support"""
|
||||||
|
|
Loading…
Reference in New Issue