client: request card-remove and sim-local when no bankd/slot is set

When the client leaves the OPERATIONAL state, do the inverse of what
happens when entering that state:
* request "card insert" no longer to be generated towards modem
* request switch back to local SIM
* reset the modem to notice the change

This way entering remote-sim operation due to adding a slotmap
and leaving remote-sim due to removing the slotmap should be
symmetrical.

Change-Id: Ifaa4b60474bf8585bfbe0288062f581821bd3faa
Closes: OS#5216
This commit is contained in:
Harald Welte 2021-09-08 21:38:35 +02:00
parent eb9f6e7228
commit 7b87ba1e38
5 changed files with 52 additions and 0 deletions

View File

@ -43,7 +43,9 @@ struct frontend_tpdu {
/* API from generic core to frontend (modem/cardem) */
int frontend_request_card_insert(struct bankd_client *bc);
int frontend_request_card_remove(struct bankd_client *bc);
int frontend_request_sim_remote(struct bankd_client *bc);
int frontend_request_sim_local(struct bankd_client *bc);
int frontend_request_modem_reset(struct bankd_client *bc);
int frontend_handle_card2modem(struct bankd_client *bc, const uint8_t *data, size_t len);
int frontend_handle_set_atr(struct bankd_client *bc, const uint8_t *data, size_t len);

View File

@ -208,6 +208,23 @@ static void main_st_operational_onenter(struct osmo_fsm_inst *fi, uint32_t prev_
call_script(bc, "request-modem-reset");
}
static void main_st_operational_onleave(struct osmo_fsm_inst *fi, uint32_t next_state)
{
struct bankd_client *bc = (struct bankd_client *) fi->priv;
/* Simulate a card-remval to modem */
frontend_request_card_remove(bc);
call_script(bc, "request-card-remove");
/* Select local SIM */
frontend_request_sim_local(bc);
call_script(bc, "request-sim-local");
/* Reset the modem */
frontend_request_modem_reset(bc);
call_script(bc, "request-modem-reset");
}
static void main_st_operational(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
struct bankd_client *bc = (struct bankd_client *) fi->priv;
@ -353,6 +370,7 @@ static const struct osmo_fsm_state main_fsm_states[] = {
.out_state_mask = S(MF_ST_INIT) | S(MF_ST_UNCONFIGURED) | S(MF_ST_WAIT_BANKD),
.action = main_st_operational,
.onenter = main_st_operational_onenter,
.onleave = main_st_operational_onleave,
},
};

View File

@ -156,11 +156,21 @@ int frontend_request_card_insert(struct bankd_client *bc)
return 0;
}
int frontend_request_card_remove(struct bankd_client *bc)
{
return 0;
}
int frontend_request_sim_remote(struct bankd_client *bc)
{
return 0;
}
int frontend_request_sim_local(struct bankd_client *bc)
{
return 0;
}
int frontend_request_modem_reset(struct bankd_client *bc)
{
return 0;

View File

@ -20,11 +20,21 @@ int frontend_request_card_insert(struct bankd_client *bc)
return 0;
}
int frontend_request_card_remove(struct bankd_client *bc)
{
return 0;
}
int frontend_request_sim_remote(struct bankd_client *bc)
{
return 0;
}
int frontend_request_sim_local(struct bankd_client *bc)
{
return 0;
}
int frontend_request_modem_reset(struct bankd_client *bc)
{
return 0;

View File

@ -322,12 +322,24 @@ int frontend_request_card_insert(struct bankd_client *bc)
return osmo_st2_cardem_request_card_insert(ci, true);
}
int frontend_request_card_remove(struct bankd_client *bc)
{
struct osmo_st2_cardem_inst *ci = bc->cardem;
return osmo_st2_cardem_request_card_insert(ci, false);
}
int frontend_request_sim_remote(struct bankd_client *bc)
{
struct osmo_st2_cardem_inst *ci = bc->cardem;
return osmo_st2_modem_sim_select_remote(ci->slot);
}
int frontend_request_sim_local(struct bankd_client *bc)
{
struct osmo_st2_cardem_inst *ci = bc->cardem;
return osmo_st2_modem_sim_select_local(ci->slot);
}
int frontend_request_modem_reset(struct bankd_client *bc)
{
struct osmo_st2_cardem_inst *ci = bc->cardem;