add sim switch and modem reset for OWHW
Change-Id: I9d395c2c7e10a0e7e5f7c84bc7d951431bfc68ba
This commit is contained in:
parent
3443dc6500
commit
d3843e5c2d
|
@ -18,6 +18,9 @@
|
|||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <linux/limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
#include <getopt.h>
|
||||
|
||||
|
@ -26,6 +29,7 @@
|
|||
#include "libusb_util.h"
|
||||
#include "simtrace.h"
|
||||
#include "simtrace_prot.h"
|
||||
#include "simtrace_usb.h"
|
||||
#include "apdu_dispatch.h"
|
||||
#include "simtrace2-discovery.h"
|
||||
|
||||
|
@ -798,6 +802,52 @@ int main(int argc, char **argv)
|
|||
goto close_exit;
|
||||
}
|
||||
|
||||
// switch modem SIM port to emulated SIM on OWHW
|
||||
if (USB_VENDOR_OPENMOKO == ifm->vendor && USB_PRODUCT_OWHW_SAM3 == ifm->product) { // we are on the OWHW
|
||||
int modem = -1;
|
||||
switch (ifm->interface) { // the USB interface indicates for which modem we want to emulate the SIM
|
||||
case 0:
|
||||
modem = 1;
|
||||
break;
|
||||
case 1:
|
||||
modem = 2;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "unknown GPIO for SIMtrace interface %d\n", ifm->interface);
|
||||
goto close_exit;
|
||||
}
|
||||
//
|
||||
char gpio_path[PATH_MAX];
|
||||
snprintf(gpio_path, sizeof(gpio_path), "/dev/gpio/connect_st_usim%d/value", modem);
|
||||
int connec_st_usim = open(gpio_path, O_WRONLY);
|
||||
if (-1 == connec_st_usim) {
|
||||
fprintf(stderr, "can't open GPIO %s to switch modem %d to emulated USIM\n", gpio_path, modem);
|
||||
goto close_exit;
|
||||
}
|
||||
if (1 != write(connec_st_usim, "1", 1)) {
|
||||
fprintf(stderr, "can't write GPIO %s to switch modem %d to emulated USIM\n", gpio_path, modem);
|
||||
goto close_exit;
|
||||
}
|
||||
printf("switched modem %d to emulated USIM\n", modem);
|
||||
|
||||
snprintf(gpio_path, sizeof(gpio_path), "/dev/gpio/mdm%d_rst/value", modem);
|
||||
int mdm_rst = open(gpio_path, O_WRONLY);
|
||||
if (-1 == mdm_rst) {
|
||||
fprintf(stderr, "can't open GPIO %s to reset modem %d\n", gpio_path, modem);
|
||||
goto close_exit;
|
||||
}
|
||||
if (1 != write(mdm_rst, "1", 1)) {
|
||||
fprintf(stderr, "can't write GPIO %s to reset modem %d\n", gpio_path, modem);
|
||||
goto close_exit;
|
||||
}
|
||||
sleep(1); // wait a bit to ensure reset is effective
|
||||
if (1 != write(mdm_rst, "0", 1)) {
|
||||
fprintf(stderr, "can't write GPIO %s to reset modem %d\n", gpio_path, modem);
|
||||
goto close_exit;
|
||||
}
|
||||
printf("modem %d reset\n", modem);
|
||||
}
|
||||
|
||||
/* simulate card-insert to modem (owhw, not qmod) */
|
||||
cardem_request_card_insert(ci, true);
|
||||
|
||||
|
|
Loading…
Reference in New Issue