FreeCalypso > hg > freecalypso-tools
comparison rvinterf/asyncshell/battery.c @ 748:b55a81ce7497
fc-shell: implement MMI_BATTERY_IND sending
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 22 Oct 2020 05:39:47 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
747:efd85963ec85 | 748:b55a81ce7497 |
---|---|
1 /* | |
2 * Functions for sending MMI_BATTERY_IND primitives with simulated | |
3 * battery actions. | |
4 */ | |
5 | |
6 #include <sys/types.h> | |
7 #include <stdio.h> | |
8 #include <ctype.h> | |
9 #include <string.h> | |
10 #include <strings.h> | |
11 #include <stdlib.h> | |
12 #include "pktmux.h" | |
13 #include "limits.h" | |
14 #include "exitcodes.h" | |
15 | |
16 static u_char mmi_battery_ind_fixedpart[24] = { | |
17 RVT_L23_HEADER, 0x97, 24, 0, | |
18 0, 0, 0, 0, | |
19 'P', 'C', 'O', ' ', | |
20 'M', 'M', 'I', ' ', | |
21 'M', 'M', 'I', ' ', | |
22 0x03, 0x4E, 0, 0 | |
23 }; | |
24 | |
25 send_mmi_battery_ind(byte1, byte2) | |
26 { | |
27 u_char pkt[28]; | |
28 | |
29 bcopy(mmi_battery_ind_fixedpart, pkt, 24); | |
30 pkt[24] = byte1; | |
31 pkt[25] = byte2; | |
32 /* 2 padding bytes */ | |
33 pkt[26] = 0; | |
34 pkt[27] = 0; | |
35 send_pkt_to_target(pkt, 28); | |
36 return(0); | |
37 } | |
38 | |
39 cmd_batt_common(argc, argv) | |
40 char **argv; | |
41 { | |
42 u_char bytes[2]; | |
43 int i; | |
44 char *endp; | |
45 | |
46 for (i = 0; i < 2; i++) { | |
47 bytes[i] = strtoul(argv[i], &endp, 0); | |
48 if (*endp) { | |
49 printf("error: invalid batt argument\n"); | |
50 return(ERROR_USAGE); | |
51 } | |
52 } | |
53 return send_mmi_battery_ind(bytes[0], bytes[1]); | |
54 } | |
55 | |
56 void | |
57 cmd_batt_interactive(argstr) | |
58 char *argstr; | |
59 { | |
60 char *argv[3]; | |
61 int argc, rc; | |
62 | |
63 rc = parse_interactive_command_into_argv(argstr, argv, 2, 2, &argc); | |
64 if (rc < 0) | |
65 return; | |
66 cmd_batt_common(argc, argv); | |
67 } | |
68 | |
69 cmd_batt_oneshot(argc, argv) | |
70 char **argv; | |
71 { | |
72 return cmd_batt_common(argc - 1, argv + 1); | |
73 } |