diff options
author | Simon Busch <morphis@gravedo.de> | 2011-10-08 22:58:11 +0200 |
---|---|---|
committer | Simon Busch <morphis@gravedo.de> | 2011-10-08 22:58:11 +0200 |
commit | 1cec835e06ddbf9d5229ff0a080e0e36106d64f3 (patch) | |
tree | 29553b583124fb1f57e0c59e7e97e474cb6684bd /tools | |
parent | 378047169304d8415ad8c5838d0fe3fcd00f93c5 (diff) | |
download | external_libsamsung-ipc-1cec835e06ddbf9d5229ff0a080e0e36106d64f3.zip external_libsamsung-ipc-1cec835e06ddbf9d5229ff0a080e0e36106d64f3.tar.gz external_libsamsung-ipc-1cec835e06ddbf9d5229ff0a080e0e36106d64f3.tar.bz2 |
tools: modemctrl: implement bootstrap, power on/off commands
Diffstat (limited to 'tools')
-rw-r--r-- | tools/modemctrl.c | 74 |
1 files changed, 23 insertions, 51 deletions
diff --git a/tools/modemctrl.c b/tools/modemctrl.c index 41ae3e1..e7758a7 100644 --- a/tools/modemctrl.c +++ b/tools/modemctrl.c @@ -2,6 +2,7 @@ * This file is part of libsamsung-ipc. * * Copyright (C) 2010-2011 Joerie de Gram <j.de.gram@gmail.com> + * 2011 Simon Busch <morphis@gravedo.de> * * libsamsung-ipc is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,24 +16,21 @@ * * You should have received a copy of the GNU General Public License * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>. - * */ + #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <radio.h> -void handle_msg(struct ipc_response *response) +void print_help() { - if(response->command == IPC_PWR_PHONE_PWR_UP && - response->type == IPC_TYPE_NOTI) { - printf(">> received PWR_PHONE_ONLINE, requesting IMEI\n"); - - /* h1 requires a short delay for nvram to be available */ - usleep(25000); - ipc_msg_send(IPC_MISC_ME_SN, IPC_TYPE_GET, NULL, 0, 0x42); - } + printf("usage: modemctrl <command>\n"); + printf("commands:\n"); + printf("\tbootstrap bootstrap modem to be ready for processing\n"); + printf("\tpower-on power on the modem\n"); + printf("\tpower-off power off the modem\n"); } int main(int argc, char *argv[]) @@ -40,51 +38,25 @@ int main(int argc, char *argv[]) struct ipc_response response; int error; - ipc_init(IPC_CLIENT_TYPE_CRESPO); - - ipc_bootstrap(); - - printf("ipc_open\n"); - error = ipc_open(); - - if(error) { - fprintf(stderr, "ipc_open failed!\n"); - return 1; + if (argc != 2) { + print_help(); + exit(1); } - printf("ipc_power_on\n"); - ipc_power_on(); - - printf("entering recv loop...\n"); - - while(1) { - error = ipc_recv(&response); - - if(!error) { - printf("%s %s (%u/%u) type=%04x mseq=%02x aseq=%02x\n", - ipc_str(&response), ipc_response_type(&response), - (response.data_length + 7), response.data_length, - response.type, response.mseq, response.aseq); - - hex_dump(response.data, response.data_length); - printf("\n"); - - handle_msg(&response); + ipc_init(IPC_CLIENT_TYPE_CRESPO); - if(response.data) { - free(response.data); - } - } else { - fprintf(stderr, "ipc_recv failed!\n"); - return 1; - } + if (!strncmp(argv[1], "bootstrap", 9)) { + ipc_bootstrap(); } - - error = ipc_close(); - - if(error) { - fprintf(stderr, "ipc_close failed!\n"); - return 1; + else if (!strncmp(argv[1], "power-on", 8)) { + ipc_open(); + ipc_power_on(); + ipc_close(); + } + else if (!strncmp(argv[1], "power-off", 9)) { + ipc_open(); + ipc_power_off(); + ipc_close(); } return 0; |