mirror of
https://github.com/sailfishos/ofono
synced 2025-11-23 19:09:44 +08:00
Compare commits
524 Commits
upgrade-3.
...
mer/1.24+g
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d87e925d57 | ||
|
|
33744c5106 | ||
|
|
1d35a2dc2d | ||
|
|
352bdf5a39 | ||
|
|
d73d3e2e7f | ||
|
|
38a83d3c18 | ||
|
|
5b175c2877 | ||
|
|
52bb7b3295 | ||
|
|
09e6f35a23 | ||
|
|
6dddf527d5 | ||
|
|
a9de07c2bb | ||
|
|
ecf14f5165 | ||
|
|
bc4c860a86 | ||
|
|
7684dd4295 | ||
|
|
f24a5be4ec | ||
|
|
c45e207f12 | ||
|
|
005f36bb89 | ||
|
|
3d01485a05 | ||
|
|
cc7b30414f | ||
|
|
1617b325de | ||
|
|
a8838c2287 | ||
|
|
c8cd552851 | ||
|
|
6995d8c42c | ||
|
|
17052d41de | ||
|
|
70a93dcc5b | ||
|
|
e3ea3abaa0 | ||
|
|
f60c44b034 | ||
|
|
a679258b4a | ||
|
|
0ed72bcffa | ||
|
|
7d5a660604 | ||
|
|
d67240c717 | ||
|
|
b12016eb45 | ||
|
|
bfec98afdf | ||
|
|
7376781211 | ||
|
|
732160519a | ||
|
|
f71d2a2b70 | ||
|
|
793e9fcae4 | ||
|
|
ae204ebf82 | ||
|
|
30b09b35af | ||
|
|
1495f222b0 | ||
|
|
b9b2765b21 | ||
|
|
29ecf1a59a | ||
|
|
f1d3367e0a | ||
|
|
7131403177 | ||
|
|
ff99f16ccb | ||
|
|
ccec9504a5 | ||
|
|
e37ca6d384 | ||
|
|
ab5b76d6cf | ||
|
|
35ef8fb8a1 | ||
|
|
d0a617d469 | ||
|
|
1ba3b32273 | ||
|
|
14b764ac64 | ||
|
|
b808bfad17 | ||
|
|
82d62a8f50 | ||
|
|
23d6263e3c | ||
|
|
ac3192204c | ||
|
|
5ad2617ecd | ||
|
|
890842b3af | ||
|
|
06de44299a | ||
|
|
77b2eec613 | ||
|
|
12ccd7cd46 | ||
|
|
8f09880d52 | ||
|
|
ee5f91221b | ||
|
|
c03c6f4215 | ||
|
|
c49e2d8723 | ||
|
|
deecd829a6 | ||
|
|
3acf91c6a9 | ||
|
|
85b61c8964 | ||
|
|
8986749585 | ||
|
|
1c0f5094a6 | ||
|
|
4208b6d9ea | ||
|
|
59e304d474 | ||
|
|
30a2424507 | ||
|
|
e4f3ec6322 | ||
|
|
95fd4efc37 | ||
|
|
ef5ee98508 | ||
|
|
4220e7d5e8 | ||
|
|
33c067a75f | ||
|
|
29616c04d0 | ||
|
|
beb997d914 | ||
|
|
cefc03e5ed | ||
|
|
85d99536ee | ||
|
|
ea36baa4c1 | ||
|
|
b95a089c00 | ||
|
|
c8dbf5494b | ||
|
|
cfb75f473d | ||
|
|
edd91c94eb | ||
|
|
af0ab142e1 | ||
|
|
dffc04d404 | ||
|
|
97b5fcbd87 | ||
|
|
d7e740347f | ||
|
|
1116ca2481 | ||
|
|
3d147843c4 | ||
|
|
c01dc63cbc | ||
|
|
297926ed24 | ||
|
|
6ef1174ea8 | ||
|
|
4ad02792db | ||
|
|
eddcb88af4 | ||
|
|
f91df7f0fd | ||
|
|
9d220ff9be | ||
|
|
deefa2c454 | ||
|
|
80224b283d | ||
|
|
07e07b6ddc | ||
|
|
bd836b4499 | ||
|
|
6c289b1432 | ||
|
|
296e46487f | ||
|
|
09e98234aa | ||
|
|
0f4cdba932 | ||
|
|
870bac93e9 | ||
|
|
246cd4e1d2 | ||
|
|
ca20b65098 | ||
|
|
8e35a047da | ||
|
|
2b4b5a224d | ||
|
|
50a5f2547e | ||
|
|
d682fcd5fe | ||
|
|
5799320480 | ||
|
|
3eea7c868e | ||
|
|
4844fc6cf9 | ||
|
|
6976366051 | ||
|
|
d3d776837b | ||
|
|
f56c8a33b0 | ||
|
|
ed2f625b8b | ||
|
|
ed62d38632 | ||
|
|
3f433c97c5 | ||
|
|
86d8149c79 | ||
|
|
f3eb9b868b | ||
|
|
4e067fa827 | ||
|
|
2ee5e4c827 | ||
|
|
1366e426be | ||
|
|
586c9b9262 | ||
|
|
83554e071a | ||
|
|
dc41c2d003 | ||
|
|
550d41ae37 | ||
|
|
60e4246d93 | ||
|
|
50619607b0 | ||
|
|
98b357f365 | ||
|
|
56c488d10c | ||
|
|
944cd603e8 | ||
|
|
77be0d5e98 | ||
|
|
d8dd20092c | ||
|
|
c7faa21172 | ||
|
|
98ffc61a03 | ||
|
|
f2b1625872 | ||
|
|
2d5a22284e | ||
|
|
9d742180ab | ||
|
|
f8b0ccc1b4 | ||
|
|
7a54bb8cbe | ||
|
|
56e0923dc3 | ||
|
|
6dfce4b5e9 | ||
|
|
4ec3568d71 | ||
|
|
9b2b7127ef | ||
|
|
1053577376 | ||
|
|
22197b5e04 | ||
|
|
3a358ddc9d | ||
|
|
53929f9f1a | ||
|
|
08bae57a2b | ||
|
|
1915aeda76 | ||
|
|
51bfb17cbc | ||
|
|
a83b553032 | ||
|
|
ec00abd62d | ||
|
|
80924d5787 | ||
|
|
2bdd05aa31 | ||
|
|
544f02e5a2 | ||
|
|
6d4638f9bf | ||
|
|
6584919e9d | ||
|
|
34fb44f4eb | ||
|
|
c98d2f41c5 | ||
|
|
b279be4528 | ||
|
|
a7912fea39 | ||
|
|
f291cea905 | ||
|
|
68f7d30b77 | ||
|
|
890a2697fe | ||
|
|
9568c8449b | ||
|
|
cf91be9742 | ||
|
|
087771dc0f | ||
|
|
645dfe47e5 | ||
|
|
68e8b02d3b | ||
|
|
aa4309e8cb | ||
|
|
cb6b24d950 | ||
|
|
6d1ab13c74 | ||
|
|
45424a3f96 | ||
|
|
4f7398e39d | ||
|
|
cd118ce70b | ||
|
|
99d4ce538e | ||
|
|
9b2c4bcf76 | ||
|
|
0122db04a3 | ||
|
|
021db194cb | ||
|
|
e0a0896205 | ||
|
|
49d0bbbb28 | ||
|
|
9193d06b77 | ||
|
|
b0cd3e4544 | ||
|
|
29cce6969b | ||
|
|
b87f666e4b | ||
|
|
1c1e4fa28b | ||
|
|
f597119845 | ||
|
|
633888932d | ||
|
|
a37f325d4a | ||
|
|
0afceac554 | ||
|
|
109751bcc0 | ||
|
|
30dfbf8fd7 | ||
|
|
c7aab2e790 | ||
|
|
412a2a0e7f | ||
|
|
f1aeedd113 | ||
|
|
639fce8eca | ||
|
|
9cfd0a195e | ||
|
|
cf2d8488cc | ||
|
|
ab0ac10abd | ||
|
|
b2df7de223 | ||
|
|
b56930a87f | ||
|
|
f65e8dd5af | ||
|
|
f2439243b2 | ||
|
|
93ff644856 | ||
|
|
08f8555d51 | ||
|
|
04b2a9b0f9 | ||
|
|
4d513b68d2 | ||
|
|
36f971dc78 | ||
|
|
8ba2d96cff | ||
|
|
a76f50be67 | ||
|
|
43227086c0 | ||
|
|
e40811fbc6 | ||
|
|
8c543b054a | ||
|
|
53233b4dc8 | ||
|
|
4458fbf844 | ||
|
|
542a086d93 | ||
|
|
1176662a81 | ||
|
|
ae29a08a76 | ||
|
|
af1a569430 | ||
|
|
a75558031b | ||
|
|
139fff2e5d | ||
|
|
12614d377a | ||
|
|
463f4f183e | ||
|
|
0ba7505f1e | ||
|
|
c1156320ac | ||
|
|
afe4fc66f0 | ||
|
|
c04b14c49a | ||
|
|
4d6aefcea5 | ||
|
|
c3c4b21c32 | ||
|
|
5ffc3fc426 | ||
|
|
690d62820a | ||
|
|
f1fbd04d66 | ||
|
|
8eaf694b9a | ||
|
|
5087fd9dd7 | ||
|
|
92aebc3ce8 | ||
|
|
c0a5b0fdf3 | ||
|
|
587879b6c2 | ||
|
|
f9ca5c30a6 | ||
|
|
3f9dff449f | ||
|
|
d554061955 | ||
|
|
3ae306ed57 | ||
|
|
6448c0c270 | ||
|
|
e521938d95 | ||
|
|
80158ea5bc | ||
|
|
bfba3e2312 | ||
|
|
e4fc7b9b0c | ||
|
|
f1ec346941 | ||
|
|
9f9bb11a66 | ||
|
|
cf3143bb69 | ||
|
|
56f46a80c0 | ||
|
|
6fb02515f0 | ||
|
|
4efb502fad | ||
|
|
842331f701 | ||
|
|
f743c89bc8 | ||
|
|
20d9835aed | ||
|
|
f4c24f5f83 | ||
|
|
6c07b110c7 | ||
|
|
6205fad90f | ||
|
|
9b7358e5e5 | ||
|
|
502cd55c4e | ||
|
|
103b20bcfd | ||
|
|
8b083e0121 | ||
|
|
8b1fc771ea | ||
|
|
7bb19531cd | ||
|
|
252df1349a | ||
|
|
5a2d64371c | ||
|
|
6995849600 | ||
|
|
69149b3039 | ||
|
|
77eb51bc39 | ||
|
|
d05b1137d5 | ||
|
|
9eae00b28b | ||
|
|
48a6492a68 | ||
|
|
443898d8ef | ||
|
|
23718794cc | ||
|
|
450c5f9b69 | ||
|
|
4f6b8b7243 | ||
|
|
3eec92ec7a | ||
|
|
4216026a7c | ||
|
|
9eb2820397 | ||
|
|
f33550f37f | ||
|
|
020dc3020e | ||
|
|
ad0b9e6303 | ||
|
|
d773d28dad | ||
|
|
4d9fea27ea | ||
|
|
c4a8186f7a | ||
|
|
2c5f1a6626 | ||
|
|
dcb057802f | ||
|
|
fd889b3fac | ||
|
|
fe3f46f29b | ||
|
|
b8eae5f967 | ||
|
|
d818544d92 | ||
|
|
dc1377eb0a | ||
|
|
06599ff36d | ||
|
|
4d2ef8b2da | ||
|
|
cc7f5796bb | ||
|
|
65d2b1306a | ||
|
|
b484003494 | ||
|
|
8a6ec5e645 | ||
|
|
fdc4b27b05 | ||
|
|
9b338c4055 | ||
|
|
fbaf86d862 | ||
|
|
d5c6316a13 | ||
|
|
bf092b518c | ||
|
|
9de95af924 | ||
|
|
5988c88968 | ||
|
|
354793cbe3 | ||
|
|
259c6e2617 | ||
|
|
aa88654d09 | ||
|
|
50499bc69d | ||
|
|
8c64f94743 | ||
|
|
0eabc3ea79 | ||
|
|
8116bd13d1 | ||
|
|
30bbccfd91 | ||
|
|
028a6ab1c7 | ||
|
|
32607771b5 | ||
|
|
d37dfc1ad1 | ||
|
|
e0bfba6fbe | ||
|
|
414791a6f0 | ||
|
|
3fa059a027 | ||
|
|
540b558147 | ||
|
|
6bfb0d07ab | ||
|
|
19a8a137c1 | ||
|
|
11913b2a44 | ||
|
|
2a1e29ab9e | ||
|
|
a64cc4d5b9 | ||
|
|
f464a7c6c1 | ||
|
|
daceb07bb1 | ||
|
|
f9ef31cd5c | ||
|
|
c3c3bab6a2 | ||
|
|
08f0bb08f1 | ||
|
|
ce2b18ede2 | ||
|
|
5f9e43c2da | ||
|
|
2ee038a457 | ||
|
|
3a4f63171f | ||
|
|
64878cced6 | ||
|
|
3f115b2d0d | ||
|
|
c66eec1b1e | ||
|
|
85d1eda7c9 | ||
|
|
08d8d5de73 | ||
|
|
172c97df83 | ||
|
|
1e3e413714 | ||
|
|
15ef3c9c0e | ||
|
|
e9eb113a22 | ||
|
|
abdfb38006 | ||
|
|
79e22d4570 | ||
|
|
aab791f2ad | ||
|
|
90c0ffddea | ||
|
|
a3149c53d9 | ||
|
|
b02a37a9c5 | ||
|
|
eecf9fde2c | ||
|
|
f2bb5d08ba | ||
|
|
d44a1af644 | ||
|
|
50fbd5351b | ||
|
|
9c8700b5c6 | ||
|
|
9221153db9 | ||
|
|
8997e02997 | ||
|
|
7121855966 | ||
|
|
0d013c3f9b | ||
|
|
e2299cbddc | ||
|
|
34cd275117 | ||
|
|
2396ead477 | ||
|
|
32dc1d1806 | ||
|
|
aed679d6da | ||
|
|
baea6fb7e9 | ||
|
|
ba64ce870f | ||
|
|
1e25fbbcbf | ||
|
|
d13339af6c | ||
|
|
890f3235cb | ||
|
|
2603419fa4 | ||
|
|
1abdcc9226 | ||
|
|
928a905cce | ||
|
|
f241580817 | ||
|
|
26826c15c9 | ||
|
|
5b3a045e6c | ||
|
|
c8a08bd815 | ||
|
|
53d1f1ce03 | ||
|
|
1aec6df272 | ||
|
|
b43df906ca | ||
|
|
1d42a2a6a9 | ||
|
|
bab1cb2479 | ||
|
|
a8be51ceef | ||
|
|
a658ec7e77 | ||
|
|
960db7cf2b | ||
|
|
842fe25bcd | ||
|
|
7aa2cbb8cb | ||
|
|
612b295eae | ||
|
|
168919770d | ||
|
|
b603be82ee | ||
|
|
bbeaadd191 | ||
|
|
99d7c4e884 | ||
|
|
9753700d58 | ||
|
|
7772c8971b | ||
|
|
13b39ba633 | ||
|
|
77ac688c5e | ||
|
|
f4bbba9547 | ||
|
|
17f5b9faa5 | ||
|
|
4b266cfbfd | ||
|
|
e56998d640 | ||
|
|
b87fb13b7b | ||
|
|
32753de8a7 | ||
|
|
331c6e98d2 | ||
|
|
69f1b7b36f | ||
|
|
ca6447102f | ||
|
|
9b3dc8143d | ||
|
|
919df873f3 | ||
|
|
7aed70b642 | ||
|
|
0776d5b19b | ||
|
|
ca4c2c4a07 | ||
|
|
eab88cd6cb | ||
|
|
0be2675072 | ||
|
|
d226729730 | ||
|
|
417bbaa963 | ||
|
|
9974013cce | ||
|
|
53e07c0932 | ||
|
|
edce8b06c6 | ||
|
|
8d72007e95 | ||
|
|
ffa0e801a3 | ||
|
|
f6c7117097 | ||
|
|
3d9013eea8 | ||
|
|
b76517559b | ||
|
|
6bdb51dc29 | ||
|
|
4f066a2133 | ||
|
|
61d87e5cf9 | ||
|
|
3d33bea585 | ||
|
|
a741db6087 | ||
|
|
f9a175b1a8 | ||
|
|
04133f8316 | ||
|
|
2e6ae0f001 | ||
|
|
432c05928b | ||
|
|
38054818ed | ||
|
|
f3e4550d67 | ||
|
|
a91c8de5c2 | ||
|
|
9c29518418 | ||
|
|
951e9439d4 | ||
|
|
7cd984aa1a | ||
|
|
06227e5e50 | ||
|
|
bba23c3095 | ||
|
|
a892edaea5 | ||
|
|
2ede8f2464 | ||
|
|
1759502c96 | ||
|
|
134efba989 | ||
|
|
9331cc1ecb | ||
|
|
7c8da34a38 | ||
|
|
a05523974e | ||
|
|
71ef390b4a | ||
|
|
717f6452aa | ||
|
|
0803c21840 | ||
|
|
095060b001 | ||
|
|
c2971da092 | ||
|
|
f07424f0aa | ||
|
|
266a52a40a | ||
|
|
eeea5476d1 | ||
|
|
e38a63d179 | ||
|
|
0ff8608ac3 | ||
|
|
5a330b9852 | ||
|
|
78a9323619 | ||
|
|
8267e206eb | ||
|
|
fac7684958 | ||
|
|
6ba3170ce2 | ||
|
|
b29730b268 | ||
|
|
e095636c97 | ||
|
|
6fef5444fb | ||
|
|
0e62e613e8 | ||
|
|
c08be69130 | ||
|
|
419caedc2c | ||
|
|
ee6a307804 | ||
|
|
412d8c3d4d | ||
|
|
0efebd16d9 | ||
|
|
7a6928c02f | ||
|
|
ec134e68d2 | ||
|
|
a8be769c87 | ||
|
|
a2d87f64c4 | ||
|
|
3ecd55a205 | ||
|
|
d8ea82b2f1 | ||
|
|
c95fe16a9b | ||
|
|
55e923250a | ||
|
|
f5653ae240 | ||
|
|
ecf23c1333 | ||
|
|
e71036f7d7 | ||
|
|
b8e8b930f8 | ||
|
|
65a3f7ee46 | ||
|
|
26c5c4bfa3 | ||
|
|
2d35e5e28d | ||
|
|
ae78d9a946 | ||
|
|
243dd7d17c | ||
|
|
acaafafbb9 | ||
|
|
4f378c806b | ||
|
|
bd33ff471c | ||
|
|
d423608e46 | ||
|
|
3b708effd9 | ||
|
|
f01722cca5 | ||
|
|
f62d53fbd0 | ||
|
|
942aee3f25 | ||
|
|
ecc83568fd | ||
|
|
c911c05fcb | ||
|
|
680979f782 | ||
|
|
250a6abb71 | ||
|
|
6c5d2ab803 | ||
|
|
bf8cb3995c | ||
|
|
8973e52e45 | ||
|
|
0e8dc3605e | ||
|
|
537a39f94a | ||
|
|
c3d93e83d7 | ||
|
|
7cdf3db124 | ||
|
|
398942c78e | ||
|
|
26e39508ad | ||
|
|
a16fcd0d37 | ||
|
|
432e700272 | ||
|
|
aa694b592f | ||
|
|
c5c8b72761 | ||
|
|
2ab7aa0f97 | ||
|
|
549fe2355f | ||
|
|
7493187e47 | ||
|
|
9a3d8d671c | ||
|
|
39eac13743 | ||
|
|
6329bb8639 |
21
ofono/.gitignore
vendored
21
ofono/.gitignore
vendored
@@ -9,7 +9,7 @@ Makefile.in
|
||||
aclocal.m4
|
||||
config.guess
|
||||
config.h
|
||||
config.h.in
|
||||
config.h.in*
|
||||
config.log
|
||||
config.status
|
||||
config.sub
|
||||
@@ -42,27 +42,34 @@ unit/test-sms-root
|
||||
unit/test-simutil
|
||||
unit/test-mux
|
||||
unit/test-caif
|
||||
unit/test-cell-info
|
||||
unit/test-cell-info-dbus
|
||||
unit/test-stkutil
|
||||
unit/test-cdmasms
|
||||
unit/test-conf
|
||||
unit/test-dbus-access
|
||||
unit/test-dbus-clients
|
||||
unit/test-dbus-queue
|
||||
unit/test-gprs-filter
|
||||
unit/test-ril_config
|
||||
unit/test-ril_ecclist
|
||||
unit/test-ril_util
|
||||
unit/test-ril_vendor
|
||||
unit/test-ril-transport
|
||||
unit/test-rilmodem-cb
|
||||
unit/test-rilmodem-cs
|
||||
unit/test-rilmodem-gprs
|
||||
unit/test-rilmodem-sms
|
||||
unit/test-sailfish_cell_info
|
||||
unit/test-sailfish_cell_info_dbus
|
||||
unit/test-sailfish_manager
|
||||
unit/test-sailfish_sim_info
|
||||
unit/test-sailfish_sim_info_dbus
|
||||
unit/test-sailfish_watch
|
||||
unit/test-sailfish_access
|
||||
unit/test-slot-manager
|
||||
unit/test-watch
|
||||
unit/test-sim-info
|
||||
unit/test-sim-info-dbus
|
||||
unit/test-sms-filter
|
||||
unit/test-voicecall-filter
|
||||
unit/test-*.log
|
||||
unit/test-*.trs
|
||||
unit/test-mbim
|
||||
|
||||
unit/test-grilreply
|
||||
unit/test-grilrequest
|
||||
|
||||
@@ -115,6 +115,7 @@ Antara Borwankar <antara.borwankar@gmail.com>
|
||||
Martin Chaplet <m.chaplet@kerlink.fr>
|
||||
Suman Mallela <suman.m@intel.com>
|
||||
Rajagopal Aravindan <rajagopalx.aravindan@intel.com>
|
||||
Ankit Navik <ankit.p.navik@intel.com>
|
||||
Antoine Aubert <a.aubert@overkiz.com>
|
||||
Djalal Harouni <djalal@endocode.com>
|
||||
Christophe Ronco <c.ronco@kerlink.fr>
|
||||
@@ -126,3 +127,11 @@ Jonas Bonn <jonas@southpole.se>
|
||||
Matthijs Kooijman <matthijs@stdin.nl>
|
||||
Clayton Craft <clayton@craftyguy.net>
|
||||
Joey Hewitt <joey@joeyhewitt.com>
|
||||
Richard Röjfors <richard.rojfors@gmail.com>
|
||||
Philippe De Swert <philippe.deswert@nomovok.com>
|
||||
Gabriel Lucas <gabriel.lucas@smile.fr>
|
||||
Mariem Cherif <mariem.cherif@ardia.com.tn>
|
||||
Bassem Boubaker <bassem.boubaker@actia.fr>
|
||||
Bob Ham <bob.ham@puri.sm>
|
||||
Varun Gargi <varun.gargi@intel.com>
|
||||
Florent Beillonnet <florent.beillonnet@gmail.com>
|
||||
|
||||
@@ -1,3 +1,34 @@
|
||||
ver 1.24:
|
||||
Fix issue with property changed signals and CDMA networks.
|
||||
Fix issue with handling SIM filesystem and SIM removal.
|
||||
Fix issue with handling PIN state and incorrect codes.
|
||||
Fix issue with handling of parsing AID type.
|
||||
Fix issue with SIM detection and QMI devices.
|
||||
Fix issue with PIN handling and QMI devices.
|
||||
Fix issue with USSD handling and QMI devices.
|
||||
Fix issue with handling USSD TERMINATED response.
|
||||
Fix issue with handling USSD reset and STK REFRESH.
|
||||
Add support for detecting Gemalto ALS3 modems.
|
||||
Add support for SIMCom based SIM7100E modems.
|
||||
|
||||
ver 1.23:
|
||||
Fix issue with handling SIM AID sessions.
|
||||
Add support for QMI LTE bearer handling.
|
||||
Add support for memory location dialing.
|
||||
|
||||
ver 1.22:
|
||||
Fix issue with GPIO handling and Nokia modems.
|
||||
Fix issue with SIM state callback and AT modems.
|
||||
Fix issue with data mode and DCD for U-Blox modems.
|
||||
Fix issue with SMS receive on QMI based Quectel EC21.
|
||||
Fix issue with HFP support and last call dialed request.
|
||||
Fix issue with PIM retires handling and Gemalto modems.
|
||||
Fix issue with atom registration and SIM state handling.
|
||||
Add support for handling SIM card AID session management.
|
||||
Add support for handling GSM/UMTS and IMS authentication.
|
||||
Add support for IP Multimedia Subsystem (IMS) atom.
|
||||
Add support for MBIM based modems.
|
||||
|
||||
ver 1.21:
|
||||
Fix issue with USSD notification received handling.
|
||||
Fix issue with crashing SIM filesystem notifications.
|
||||
|
||||
@@ -24,19 +24,16 @@ pkginclude_HEADERS = include/log.h include/plugin.h include/history.h \
|
||||
include/sim-mnclength.h \
|
||||
include/handsfree-audio.h include/siri.h \
|
||||
include/sms-filter.h include/gprs-filter.h \
|
||||
include/voicecall-filter.h \
|
||||
include/voicecall-filter.h include/dbus-access.h \
|
||||
include/ril-constants.h include/ril-transport.h \
|
||||
include/netmon.h include/lte.h \
|
||||
include/storage.h \
|
||||
gdbus/gdbus.h
|
||||
include/watch.h gdbus/gdbus.h include/dbus-clients.h \
|
||||
include/netmon.h include/lte.h include/ims.h \
|
||||
include/slot.h include/cell-info.h \
|
||||
include/storage.h include/conf.h include/misc.h \
|
||||
include/mtu-limit.h
|
||||
|
||||
nodist_pkginclude_HEADERS = include/version.h
|
||||
|
||||
if SAILFISH_MANAGER
|
||||
nodist_pkginclude_HEADERS += include/sailfish_cell_info.h \
|
||||
include/sailfish_manager.h include/sailfish_watch.h
|
||||
endif
|
||||
|
||||
local_headers = $(foreach file,$(pkginclude_HEADERS) \
|
||||
$(nodist_pkginclude_HEADERS), \
|
||||
include/ofono/$(notdir $(file)))
|
||||
@@ -68,7 +65,7 @@ endif
|
||||
builtin_modules =
|
||||
builtin_sources =
|
||||
builtin_libadd =
|
||||
builtin_cflags =
|
||||
builtin_cflags = -DSAILFISH_OS
|
||||
|
||||
noinst_LTLIBRARIES += gdbus/libgdbus-internal.la
|
||||
|
||||
@@ -124,62 +121,12 @@ builtin_modules += udevng
|
||||
builtin_sources += plugins/udevng.c
|
||||
endif
|
||||
|
||||
if SAILFISH_MANAGER
|
||||
builtin_modules += sailfish_manager
|
||||
builtin_sources += plugins/sailfish_manager/sailfish_cell_info.c \
|
||||
plugins/sailfish_manager/sailfish_cell_info_dbus.c \
|
||||
plugins/sailfish_manager/sailfish_manager.c \
|
||||
plugins/sailfish_manager/sailfish_manager_dbus.c \
|
||||
plugins/sailfish_manager/sailfish_sim_info.c \
|
||||
plugins/sailfish_manager/sailfish_sim_info_dbus.c \
|
||||
plugins/sailfish_manager/sailfish_watch.c
|
||||
if SAILFISH_ACCESS
|
||||
builtin_modules += sailfish_access
|
||||
builtin_sources += plugins/sailfish_access.c
|
||||
endif
|
||||
|
||||
if RILMODEM
|
||||
if SAILFISH_RILMODEM
|
||||
|
||||
builtin_modules += ril
|
||||
builtin_sources += drivers/ril/ril_call_barring.c \
|
||||
drivers/ril/ril_call_forward.c \
|
||||
drivers/ril/ril_call_settings.c \
|
||||
drivers/ril/ril_call_volume.c \
|
||||
drivers/ril/ril_cell_info.c \
|
||||
drivers/ril/ril_config.c \
|
||||
drivers/ril/ril_cbs.c \
|
||||
drivers/ril/ril_data.c \
|
||||
drivers/ril/ril_devinfo.c \
|
||||
drivers/ril/ril_ecclist.c \
|
||||
drivers/ril/ril_gprs.c \
|
||||
drivers/ril/ril_gprs_context.c \
|
||||
drivers/ril/ril_modem.c \
|
||||
drivers/ril/ril_netmon.c \
|
||||
drivers/ril/ril_netreg.c \
|
||||
drivers/ril/ril_network.c \
|
||||
drivers/ril/ril_oem_raw.c \
|
||||
drivers/ril/ril_phonebook.c \
|
||||
drivers/ril/ril_plugin.c \
|
||||
drivers/ril/ril_radio.c \
|
||||
drivers/ril/ril_radio_caps.c \
|
||||
drivers/ril/ril_radio_settings.c \
|
||||
drivers/ril/ril_sim.c \
|
||||
drivers/ril/ril_sim_card.c \
|
||||
drivers/ril/ril_sim_settings.c \
|
||||
drivers/ril/ril_sms.c \
|
||||
drivers/ril/ril_stk.c \
|
||||
drivers/ril/ril_ussd.c \
|
||||
drivers/ril/ril_util.c \
|
||||
drivers/ril/ril_vendor.c \
|
||||
drivers/ril/ril_voicecall.c
|
||||
|
||||
# Vendor specific extensions
|
||||
builtin_sources += drivers/ril/ril_vendor_mtk.c
|
||||
|
||||
if DATAFILES
|
||||
dist_conf_DATA += drivers/ril/ril_subscription.conf
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
builtin_sources += $(gril_sources)
|
||||
|
||||
builtin_modules += rildev
|
||||
@@ -220,7 +167,6 @@ builtin_sources += drivers/rilmodem/rilmodem.h \
|
||||
drivers/infineonmodem/infineon_constants.h \
|
||||
drivers/rilmodem/lte.c
|
||||
endif
|
||||
endif
|
||||
|
||||
if ISIMODEM
|
||||
builtin_modules += isimodem
|
||||
@@ -283,7 +229,8 @@ qmi_sources = drivers/qmimodem/qmi.h drivers/qmimodem/qmi.c \
|
||||
drivers/qmimodem/wds.h \
|
||||
drivers/qmimodem/pds.h \
|
||||
drivers/qmimodem/common.h \
|
||||
drivers/qmimodem/wda.h
|
||||
drivers/qmimodem/wda.h \
|
||||
drivers/qmimodem/voice.h
|
||||
|
||||
builtin_modules += qmimodem
|
||||
builtin_sources += $(qmi_sources) \
|
||||
@@ -299,6 +246,7 @@ builtin_sources += $(qmi_sources) \
|
||||
drivers/qmimodem/ussd.c \
|
||||
drivers/qmimodem/gprs.c \
|
||||
drivers/qmimodem/gprs-context.c \
|
||||
drivers/qmimodem/lte.c \
|
||||
drivers/qmimodem/radio-settings.c \
|
||||
drivers/qmimodem/location-reporting.c \
|
||||
drivers/qmimodem/netmon.c
|
||||
@@ -331,7 +279,6 @@ builtin_sources += drivers/atmodem/atmodem.h \
|
||||
drivers/atmodem/atutil.c \
|
||||
drivers/atmodem/gprs.c \
|
||||
drivers/atmodem/gprs-context.c \
|
||||
drivers/atmodem/sim-auth.c \
|
||||
drivers/atmodem/gnss.c \
|
||||
drivers/atmodem/lte.c
|
||||
|
||||
@@ -468,7 +415,8 @@ builtin_modules += xmm7modem
|
||||
builtin_sources += drivers/atmodem/atutil.h \
|
||||
drivers/xmm7modem/xmm7modem.h \
|
||||
drivers/xmm7modem/xmm7modem.c \
|
||||
drivers/xmm7modem/radio-settings.c
|
||||
drivers/xmm7modem/radio-settings.c \
|
||||
drivers/xmm7modem/ims.c
|
||||
|
||||
if PHONESIM
|
||||
builtin_modules += phonesim
|
||||
@@ -488,7 +436,7 @@ builtin_sources += drivers/cdmamodem/cdmamodem.h \
|
||||
drivers/cdmamodem/connman.c
|
||||
endif
|
||||
|
||||
if !RILMODEM
|
||||
if EXTRA_MODEMS
|
||||
builtin_modules += g1
|
||||
builtin_sources += plugins/g1.c
|
||||
|
||||
@@ -564,8 +512,8 @@ builtin_sources += plugins/samsung.c
|
||||
builtin_modules += sim900
|
||||
builtin_sources += plugins/sim900.c
|
||||
|
||||
builtin_modules += connman
|
||||
builtin_sources += plugins/connman.c
|
||||
builtin_modules += sim7100
|
||||
builtin_sources += plugins/sim7100.c
|
||||
|
||||
builtin_modules += telit
|
||||
builtin_sources += plugins/telit.c
|
||||
@@ -709,10 +657,39 @@ builtin_sources += plugins/smshistory.c
|
||||
builtin_modules += allowed_apns
|
||||
builtin_sources += plugins/allowed-apns.c
|
||||
|
||||
if ELL
|
||||
builtin_cflags += @ELL_CFLAGS@
|
||||
builtin_libadd += @ELL_LIBS@
|
||||
|
||||
if MBIMMODEM
|
||||
mbim_sources = drivers/mbimmodem/mbim.h \
|
||||
drivers/mbimmodem/mbim.c \
|
||||
drivers/mbimmodem/mbim-desc.h \
|
||||
drivers/mbimmodem/mbim-desc.c \
|
||||
drivers/mbimmodem/mbim-message.h \
|
||||
drivers/mbimmodem/mbim-message.c
|
||||
|
||||
builtin_modules += mbimmodem
|
||||
builtin_sources += $(mbim_sources) \
|
||||
drivers/mbimmodem/util.h \
|
||||
drivers/mbimmodem/util.c \
|
||||
drivers/mbimmodem/mbimmodem.h \
|
||||
drivers/mbimmodem/mbimmodem.c \
|
||||
drivers/mbimmodem/devinfo.c \
|
||||
drivers/mbimmodem/sim.c \
|
||||
drivers/mbimmodem/network-registration.c \
|
||||
drivers/mbimmodem/sms.c \
|
||||
drivers/mbimmodem/gprs.c \
|
||||
drivers/mbimmodem/gprs-context.c
|
||||
|
||||
builtin_modules += mbim
|
||||
builtin_sources += plugins/mbim.c
|
||||
endif
|
||||
endif
|
||||
|
||||
sbin_PROGRAMS = src/ofonod
|
||||
|
||||
src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
|
||||
src/mtu-watch.c \
|
||||
src/main.c src/ofono.h src/log.c src/plugin.c \
|
||||
src/modem.c src/common.h src/common.c \
|
||||
src/manager.c src/dbus.c src/util.h src/util.c \
|
||||
@@ -738,11 +715,16 @@ src_ofonod_SOURCES = $(builtin_sources) $(gatchat_sources) src/ofono.ver \
|
||||
src/cdma-provision.c src/handsfree.c \
|
||||
src/handsfree-audio.c src/bluetooth.h \
|
||||
src/sim-mnclength.c src/voicecallagent.c \
|
||||
src/sms-filter.c src/gprs-filter.c src/dbus-queue.c \
|
||||
src/sms-filter.c src/gprs-filter.c \
|
||||
src/dbus-clients.c src/dbus-queue.c src/dbus-access.c \
|
||||
src/voicecall-filter.c src/ril-transport.c \
|
||||
src/hfp.h src/siri.c \
|
||||
src/netmon.c src/lte.c \
|
||||
src/netmonagent.c src/netmonagent.h
|
||||
src/hfp.h src/siri.c src/watchlist.c \
|
||||
src/netmon.c src/lte.c src/ims.c \
|
||||
src/netmonagent.c src/netmonagent.h \
|
||||
src/slot-manager.c src/slot-manager-dbus.c \
|
||||
src/cell-info.c src/cell-info-dbus.c \
|
||||
src/sim-info.c src/sim-info-dbus.c \
|
||||
src/conf.c src/mtu-limit.c
|
||||
|
||||
src_ofonod_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
|
||||
@GLIB_LIBS@ @DBUS_LIBS@ -ldl
|
||||
@@ -793,7 +775,8 @@ doc_files = doc/overview.txt doc/ofono-paper.txt doc/release-faq.txt \
|
||||
doc/networkmonitor-api.txt \
|
||||
doc/allowed-apns-api.txt \
|
||||
doc/lte-api.txt \
|
||||
doc/cinterion-hardware-monitor-api.txt
|
||||
doc/cinterion-hardware-monitor-api.txt \
|
||||
doc/ims-api.txt
|
||||
|
||||
|
||||
test_scripts = test/backtrace \
|
||||
@@ -902,7 +885,10 @@ test_scripts = test/backtrace \
|
||||
test/enable-throttling \
|
||||
test/disable-throttling \
|
||||
test/set-lte-property \
|
||||
test/test-serving-cell-info
|
||||
test/test-serving-cell-info \
|
||||
test/ims-register \
|
||||
test/ims-unregister \
|
||||
test/list-applications
|
||||
|
||||
|
||||
if TEST
|
||||
@@ -925,93 +911,82 @@ unit_tests = unit/test-common unit/test-util unit/test-idmap \
|
||||
unit/test-simutil unit/test-stkutil \
|
||||
unit/test-sms unit/test-cdmasms
|
||||
|
||||
if SAILFISH_MANAGER
|
||||
unit_test_conf_SOURCES = unit/test-conf.c src/conf.c src/log.c
|
||||
unit_test_conf_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT)
|
||||
unit_test_conf_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_conf_OBJECTS)
|
||||
unit_tests += unit/test-conf
|
||||
|
||||
unit_test_sailfish_cell_info_SOURCES = unit/test-sailfish_cell_info.c \
|
||||
plugins/sailfish_manager/sailfish_cell_info.c
|
||||
unit_test_sailfish_cell_info_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
|
||||
-Iplugins/sailfish_manager
|
||||
unit_test_sailfish_cell_info_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_cell_info_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_cell_info
|
||||
unit_test_cell_info_SOURCES = unit/test-cell-info.c src/cell-info.c src/log.c
|
||||
unit_test_cell_info_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT)
|
||||
unit_test_cell_info_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_cell_info_OBJECTS)
|
||||
unit_tests += unit/test-cell-info
|
||||
|
||||
unit_test_sailfish_cell_info_dbus_SOURCES = unit/test-dbus.c \
|
||||
unit/test-sailfish_cell_info_dbus.c \
|
||||
unit/fake_sailfish_cell_info.c \
|
||||
plugins/sailfish_manager/sailfish_cell_info.c \
|
||||
plugins/sailfish_manager/sailfish_cell_info_dbus.c \
|
||||
gdbus/object.c \
|
||||
unit_test_cell_info_dbus_SOURCES = unit/test-dbus.c \
|
||||
unit/test-cell-info-dbus.c unit/fake_cell_info.c \
|
||||
src/cell-info.c src/cell-info-dbus.c \
|
||||
gdbus/object.c src/dbus-clients.c \
|
||||
src/dbus.c src/log.c
|
||||
unit_test_sailfish_cell_info_dbus_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
|
||||
@DBUS_GLIB_CFLAGS@ -Iplugins/sailfish_manager
|
||||
unit_test_sailfish_cell_info_dbus_LDADD = @DBUS_GLIB_LIBS@ @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_cell_info_dbus_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_cell_info_dbus
|
||||
unit_test_cell_info_dbus_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
|
||||
@DBUS_GLIB_CFLAGS@
|
||||
unit_test_cell_info_dbus_LDADD = @DBUS_GLIB_LIBS@ @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_cell_info_dbus_OBJECTS)
|
||||
unit_tests += unit/test-cell-info-dbus
|
||||
|
||||
unit_test_sailfish_sim_info_SOURCES = unit/test-sailfish_sim_info.c \
|
||||
unit/fake_sailfish_watch.c \
|
||||
plugins/sailfish_manager/sailfish_sim_info.c \
|
||||
src/storage.c src/watch.c src/log.c
|
||||
unit_test_sailfish_sim_info_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) \
|
||||
-DSTORAGEDIR='"/tmp/ofono"' -Iplugins/sailfish_manager
|
||||
unit_test_sailfish_sim_info_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_sim_info_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_sim_info
|
||||
unit_test_sim_info_SOURCES = unit/test-sim-info.c unit/fake_watch.c \
|
||||
src/sim-info.c src/storage.c src/watchlist.c src/log.c
|
||||
unit_test_sim_info_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) \
|
||||
-DSTORAGEDIR='"/tmp/ofono"'
|
||||
unit_test_sim_info_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sim_info_OBJECTS)
|
||||
unit_tests += unit/test-sim-info
|
||||
|
||||
unit_test_sailfish_sim_info_dbus_SOURCES = unit/test-sailfish_sim_info_dbus.c \
|
||||
unit/test-dbus.c unit/fake_sailfish_watch.c \
|
||||
plugins/sailfish_manager/sailfish_sim_info.c \
|
||||
plugins/sailfish_manager/sailfish_sim_info_dbus.c \
|
||||
unit_test_sim_info_dbus_SOURCES = unit/test-sim-info-dbus.c \
|
||||
unit/test-dbus.c unit/fake_watch.c \
|
||||
src/sim-info.c src/sim-info-dbus.c \
|
||||
gdbus/object.c \
|
||||
src/dbus.c src/storage.c src/watch.c src/log.c
|
||||
unit_test_sailfish_sim_info_dbus_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) \
|
||||
@DBUS_GLIB_CFLAGS@ -DSTORAGEDIR='"/tmp/ofono"' \
|
||||
-Iplugins/sailfish_manager
|
||||
unit_test_sailfish_sim_info_dbus_LDADD = @DBUS_GLIB_LIBS@ @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_sim_info_dbus_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_sim_info_dbus
|
||||
src/dbus.c src/storage.c src/watchlist.c src/log.c
|
||||
unit_test_sim_info_dbus_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS) \
|
||||
@DBUS_GLIB_CFLAGS@ -DSTORAGEDIR='"/tmp/ofono"'
|
||||
unit_test_sim_info_dbus_LDADD = @DBUS_GLIB_LIBS@ @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sim_info_dbus_OBJECTS)
|
||||
unit_tests += unit/test-sim-info-dbus
|
||||
|
||||
unit_test_sailfish_manager_SOURCES = unit/test-sailfish_manager.c \
|
||||
unit/fake_sailfish_watch.c \
|
||||
plugins/sailfish_manager/sailfish_manager.c \
|
||||
plugins/sailfish_manager/sailfish_cell_info.c \
|
||||
plugins/sailfish_manager/sailfish_sim_info.c \
|
||||
unit_test_slot_manager_SOURCES = unit/test-slot-manager.c unit/fake_watch.c \
|
||||
src/slot-manager.c src/cell-info.c src/sim-info.c \
|
||||
src/storage.c src/log.c
|
||||
unit_test_sailfish_manager_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
|
||||
-DSTORAGEDIR='"/tmp/ofono"' -Iplugins/sailfish_manager
|
||||
unit_test_sailfish_manager_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_manager_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_manager
|
||||
unit_test_slot_manager_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
|
||||
-DSTORAGEDIR='"/tmp/ofono"'
|
||||
unit_test_slot_manager_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_slot_manager_OBJECTS)
|
||||
unit_tests += unit/test-slot-manager
|
||||
|
||||
unit_test_sailfish_watch_SOURCES = unit/test-sailfish_watch.c \
|
||||
plugins/sailfish_manager/sailfish_watch.c \
|
||||
src/log.c src/watch.c
|
||||
unit_test_sailfish_watch_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
|
||||
-DSTORAGEDIR='"/tmp/ofono"' -Iplugins/sailfish_manager
|
||||
unit_test_sailfish_watch_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_watch_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_watch
|
||||
unit_test_watch_SOURCES = unit/test-watch.c src/watch.c \
|
||||
src/log.c src/watchlist.c
|
||||
unit_test_watch_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT) \
|
||||
-DSTORAGEDIR='"/tmp/ofono"'
|
||||
unit_test_watch_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_watch_OBJECTS)
|
||||
unit_tests += unit/test-watch
|
||||
|
||||
if SAILFISH_ACCESS
|
||||
unit_test_sailfish_access_SOURCES = unit/test-sailfish_access.c \
|
||||
plugins/sailfish_access.c src/dbus-access.c src/log.c
|
||||
unit_test_sailfish_access_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT)
|
||||
unit_test_sailfish_access_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_sailfish_access_OBJECTS)
|
||||
unit_tests += unit/test-sailfish_access
|
||||
endif
|
||||
|
||||
unit_test_dbus_access_SOURCES = unit/test-dbus-access.c src/dbus-access.c \
|
||||
src/log.c
|
||||
unit_test_dbus_access_CFLAGS = $(AM_CFLAGS) $(COVERAGE_OPT)
|
||||
unit_test_dbus_access_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_dbus_access_OBJECTS)
|
||||
unit_tests += unit/test-dbus-access
|
||||
|
||||
if RILMODEM
|
||||
if SAILFISH_RILMODEM
|
||||
|
||||
unit_test_ril_config_SOURCES = unit/test-ril_config.c drivers/ril/ril_util.c \
|
||||
drivers/ril/ril_config.c src/log.c
|
||||
unit_test_ril_config_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
|
||||
unit_test_ril_config_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_ril_config_OBJECTS)
|
||||
unit_tests += unit/test-ril_config
|
||||
|
||||
unit_test_ril_util_SOURCES = unit/test-ril_util.c drivers/ril/ril_util.c \
|
||||
src/log.c
|
||||
unit_test_ril_util_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
|
||||
unit_test_ril_util_LDADD = @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_ril_util_OBJECTS)
|
||||
unit_tests += unit/test-ril_util
|
||||
|
||||
else
|
||||
unit_tests += unit/test-rilmodem-cs \
|
||||
unit/test-rilmodem-cs \
|
||||
unit/test-rilmodem-sms \
|
||||
@@ -1019,7 +994,13 @@ unit_tests += unit/test-rilmodem-cs \
|
||||
unit/test-rilmodem-gprs
|
||||
|
||||
endif
|
||||
|
||||
if ELL
|
||||
if MBIMMODEM
|
||||
unit_tests += unit/test-mbim
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
noinst_PROGRAMS = $(unit_tests) \
|
||||
unit/test-sms-root unit/test-mux unit/test-caif
|
||||
@@ -1080,6 +1061,14 @@ unit_test_caif_CFLAGS = $(COVERAGE_OPT) $(AM_CFLAGS)
|
||||
unit_test_caif_LDADD = @GLIB_LIBS@
|
||||
unit_objects += $(unit_test_caif_OBJECTS)
|
||||
|
||||
unit_test_dbus_clients_SOURCES = unit/test-dbus-clients.c unit/test-dbus.c \
|
||||
src/dbus-clients.c gdbus/object.c \
|
||||
src/dbus.c src/log.c
|
||||
unit_test_dbus_clients_CFLAGS = @DBUS_GLIB_CFLAGS@ $(COVERAGE_OPT) $(AM_CFLAGS)
|
||||
unit_test_dbus_clients_LDADD = @DBUS_GLIB_LIBS@ @GLIB_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_dbus_clients_OBJECTS)
|
||||
unit_tests += unit/test-dbus-clients
|
||||
|
||||
unit_test_dbus_queue_SOURCES = unit/test-dbus-queue.c unit/test-dbus.c \
|
||||
src/dbus-queue.c gdbus/object.c \
|
||||
src/dbus.c src/log.c
|
||||
@@ -1163,6 +1152,12 @@ unit_test_rilmodem_gprs_LDADD = gdbus/libgdbus-internal.la $(builtin_libadd) \
|
||||
@GLIB_LIBS@ @DBUS_LIBS@ -ldl
|
||||
unit_objects += $(unit_test_rilmodem_gprs_OBJECTS)
|
||||
|
||||
unit_test_mbim_SOURCES = unit/test-mbim.c \
|
||||
drivers/mbimmodem/mbim-message.c \
|
||||
drivers/mbimmodem/mbim.c
|
||||
unit_test_mbim_LDADD = @ELL_LIBS@
|
||||
unit_objects += $(unit_test_mbim_OBJECTS)
|
||||
|
||||
TESTS = $(unit_tests)
|
||||
|
||||
if TOOLS
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
AC_PREREQ(2.60)
|
||||
AC_INIT(ofono, 1.21)
|
||||
AC_INIT(ofono, 1.24)
|
||||
|
||||
AM_INIT_AUTOMAKE([foreign subdir-objects color-tests])
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
@@ -33,7 +33,7 @@ AC_PROG_LIBTOOL
|
||||
AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization],
|
||||
[disable code optimization through compiler]), [
|
||||
if (test "${enableval}" = "no"); then
|
||||
CFLAGS="$CFLAGS -O0"
|
||||
CFLAGS="$CFLAGS -O0 -U_FORTIFY_SOURCE"
|
||||
fi
|
||||
])
|
||||
|
||||
@@ -177,37 +177,21 @@ AC_ARG_ENABLE(rilmodem, AC_HELP_STRING([--disable-rilmodem],
|
||||
[enable_rilmodem=${enableval}])
|
||||
AM_CONDITIONAL(RILMODEM, test "${enable_rilmodem}" != "no")
|
||||
|
||||
AC_ARG_ENABLE(sailfish-rilmodem, AC_HELP_STRING([--enable-sailfish-rilmodem],
|
||||
[enable Sailfish RIL modem]),
|
||||
[enable_sailfish_rilmodem=${enableval}],
|
||||
[enable_sailfish_rilmodem="no"])
|
||||
AM_CONDITIONAL(SAILFISH_RILMODEM, test "${enable_sailfish_rilmodem}" != "no")
|
||||
AC_ARG_ENABLE(extra-modems,
|
||||
AC_HELP_STRING([--enable-extra-modems],
|
||||
[enable modems not used by Sailfish OS]),
|
||||
[enable_extra_modems=${enableval}])
|
||||
AM_CONDITIONAL(EXTRA_MODEMS, test "${enable_extra_modems}" = "yes")
|
||||
|
||||
if (test "${enable_sailfish_rilmodem}" = "yes"); then
|
||||
PKG_CHECK_MODULES(GRILIO, libgrilio >= 1.0.25, dummy=yes,
|
||||
AC_MSG_ERROR(libgrilio >= 1.0.25 is required))
|
||||
PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.30, dummy=yes,
|
||||
AC_MSG_ERROR(libglibutil >= 1.0.30 is required))
|
||||
PKG_CHECK_MODULES(LIBMCE, libmce-glib >= 1.0.5, dummy=yes,
|
||||
AC_MSG_ERROR(libmce-glib >= 1.0.5 is required))
|
||||
CFLAGS="$CFLAGS $GRILIO_CFLAGS $LIBMCE_CFLAGS"
|
||||
LIBS="$LIBS $GRILIO_LIBS $LIBMCE_LIBS"
|
||||
enable_sailfish_manager=yes
|
||||
need_glibutil=yes
|
||||
fi
|
||||
PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.49, dummy=yes,
|
||||
AC_MSG_ERROR(libglibutil >= 1.0.49 is required))
|
||||
CFLAGS="$CFLAGS $GLIBUTIL_CFLAGS"
|
||||
LIBS="$LIBS $GLIBUTIL_LIBS"
|
||||
|
||||
AC_ARG_ENABLE(sailfish-manager,
|
||||
AC_HELP_STRING([--enable-sailfish-manager],
|
||||
[enable Sailfish OS modem manager plugin]),
|
||||
[enable_sailfish_manager=${enableval}])
|
||||
AM_CONDITIONAL(SAILFISH_MANAGER, test "${enable_sailfish_manager}" = "yes")
|
||||
|
||||
if (test "${enable_sailfish_manager}" = "yes"); then
|
||||
PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1, dummy=yes,
|
||||
AC_MSG_ERROR(dbus-glib is required by unit tests))
|
||||
AC_SUBST(DBUS_GLIB_CFLAGS)
|
||||
AC_SUBST(DBUS_GLIB_LIBS)
|
||||
fi
|
||||
PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1, dummy=yes,
|
||||
AC_MSG_ERROR(dbus-glib is required by unit tests))
|
||||
AC_SUBST(DBUS_GLIB_CFLAGS)
|
||||
AC_SUBST(DBUS_GLIB_LIBS)
|
||||
|
||||
AC_ARG_ENABLE(add-remove-context, AC_HELP_STRING([--disable-add-remove-context],
|
||||
[don't allow to add or remove connection context over D-Bus]), [
|
||||
@@ -292,6 +276,25 @@ AC_ARG_ENABLE(upower, AC_HELP_STRING([--disable-upower],
|
||||
[enable_upower=${enableval}])
|
||||
AM_CONDITIONAL(UPOWER, test "${enable_power}" != "no")
|
||||
|
||||
AC_ARG_ENABLE(mbimmodem, AC_HELP_STRING([--enable-mbimmodem],
|
||||
[enable MBIM based modem support]),
|
||||
[enable_mbimmodem=${enableval}])
|
||||
|
||||
AC_ARG_ENABLE(ell, AC_HELP_STRING([--enable-ell],
|
||||
[enable support for ell]),
|
||||
[enable_ell=${enableval}])
|
||||
|
||||
if (test "${enable_ell}" = "yes"); then
|
||||
AC_DEFINE(HAVE_ELL, 1, [Defined if Ell is enabled])
|
||||
PKG_CHECK_MODULES(ELL, ell >= 0.2, dummy=yes,
|
||||
AC_MSG_ERROR(ell library >= 0.2 is required))
|
||||
AC_SUBST(ELL_CFLAGS)
|
||||
AC_SUBST(ELL_LIBS)
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(MBIMMODEM, test "${enable_ell}" != "no" && test "${enable_mbimmodem}" = "yes")
|
||||
AM_CONDITIONAL(ELL, test "${enable_ell}" != "no")
|
||||
|
||||
AC_ARG_ENABLE(datafiles, AC_HELP_STRING([--disable-datafiles],
|
||||
[do not install configuration and data files]),
|
||||
[enable_datafiles=${enableval}])
|
||||
@@ -303,13 +306,23 @@ AC_ARG_ENABLE(sailfish-pushforwarder, AC_HELP_STRING([--enable-sailfish-pushforw
|
||||
[enable_sailfish_pushforwarder="no"])
|
||||
AM_CONDITIONAL(SAILFISH_PUSHFORWARDER, test "${enable_sailfish_pushforwarder}" != "no")
|
||||
if (test "${enable_sailfish_pushforwarder}" != "no"); then
|
||||
PKG_CHECK_MODULES(GLIBUTIL, libglibutil >= 1.0.15, dummy=yes,
|
||||
AC_MSG_ERROR(libglibutil >= 1.0.15 is required))
|
||||
PKG_CHECK_MODULES(WSPCODEC, libwspcodec >= 2.0, dummy=yes,
|
||||
AC_MSG_ERROR(WSP decoder is required))
|
||||
CFLAGS="$CFLAGS $WSPCODEC_CFLAGS"
|
||||
LIBS="$LIBS $WSPCODEC_LIBS"
|
||||
need_glibutil=yes
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(sailfish-access, AC_HELP_STRING([--enable-sailfish-access],
|
||||
[enable Sailfish OS access plugin]),
|
||||
[enable_sailfish_access=${enableval}],
|
||||
[enable_sailfish_access="no"])
|
||||
|
||||
AM_CONDITIONAL(SAILFISH_ACCESS, test "${enable_sailfish_access}" != "no")
|
||||
if (test "${enable_sailfish_access}" == "yes"); then
|
||||
PKG_CHECK_MODULES(DBUSACCESS, libdbusaccess, dummy=yes,
|
||||
AC_MSG_ERROR(libdbusaccess is required))
|
||||
CFLAGS="$CFLAGS $DBUSACCESS_CFLAGS"
|
||||
LIBS="$LIBS $DBUSACCESS_LIBS"
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(sailfish-debuglog, AC_HELP_STRING([--enable-sailfish-debuglog],
|
||||
@@ -324,11 +337,6 @@ if (test "${enable_sailfish_debuglog}" = "yes"); then
|
||||
LIBS="$LIBS $DBUSLOG_LIBS"
|
||||
fi
|
||||
|
||||
if (test "${need_glibutil}" = "yes"); then
|
||||
CFLAGS="$CFLAGS $GLIBUTIL_CFLAGS"
|
||||
LIBS="$LIBS $GLIBUTIL_LIBS"
|
||||
fi
|
||||
|
||||
if (test "${prefix}" = "NONE"); then
|
||||
dnl no prefix and no localstatedir, so default to /var
|
||||
if (test "$localstatedir" = '${prefix}/var'); then
|
||||
|
||||
@@ -278,6 +278,13 @@ Properties boolean Active [readwrite]
|
||||
via this proxy. All other values are left
|
||||
out in this case.
|
||||
|
||||
array{string} ProxyCSCF [readonly, optional]
|
||||
|
||||
Holds the list of P-CSCF (SIP proxy) for this
|
||||
context. Only used by IMS connections.
|
||||
|
||||
This is a Sailfish OS specific extension.
|
||||
|
||||
dict IPv6.Settings [readonly, optional]
|
||||
|
||||
Holds all the IPv6 network settings
|
||||
@@ -304,6 +311,13 @@ Properties boolean Active [readwrite]
|
||||
|
||||
Holds the gateway IP for this connection.
|
||||
|
||||
array{string} ProxyCSCF [readonly, optional]
|
||||
|
||||
Holds the list of P-CSCF (SIP proxy) for this
|
||||
context. Only used by IMS connections.
|
||||
|
||||
This is a Sailfish OS specific extension.
|
||||
|
||||
string MessageProxy [readwrite, MMS only]
|
||||
|
||||
Holds the MMS Proxy setting.
|
||||
|
||||
59
ofono/doc/ims-api.txt
Normal file
59
ofono/doc/ims-api.txt
Normal file
@@ -0,0 +1,59 @@
|
||||
IpMultimediaSystem Hierarchy
|
||||
============================
|
||||
|
||||
Service org.ofono
|
||||
Interface org.ofono.IpMultimediaSystem
|
||||
Object path [variable prefix]/{modem0,modem1,...}
|
||||
|
||||
Methods dict GetProperties()
|
||||
|
||||
Returns all IpMultimediaSystem configuration properties.
|
||||
|
||||
void SetProperty(string property, variant value)
|
||||
|
||||
Changes the value of the specified property. Only
|
||||
properties that are listed as readwrite are
|
||||
changeable. On success a PropertyChanged signal
|
||||
will be emitted.
|
||||
|
||||
Possible Errors: [service].Error.InProgress
|
||||
[service].Error.InvalidArguments
|
||||
[service].Error.Failed
|
||||
|
||||
void Register()
|
||||
|
||||
Attempts to register to IMS. A successful method return
|
||||
indicates that the registration process could be
|
||||
initiated successfully. The actual registration state
|
||||
will be reflected by the 'Registered' property.
|
||||
|
||||
Possible Errors: [service].Error.InProgress
|
||||
[service].Error.NotImplemented
|
||||
|
||||
void Unregister()
|
||||
|
||||
Attempts to unregister from IMS. A successful method
|
||||
return indicates that the unregistration process could
|
||||
be initiated successfully. The actual unregistration
|
||||
state will be reflected by the 'Registered' property.
|
||||
|
||||
Possible Errors: [service].Error.InProgress
|
||||
[service].Error.NotImplemented
|
||||
|
||||
Signals PropertyChanged(string property, variant value)
|
||||
|
||||
This signal indicates a changed value of the given
|
||||
property.
|
||||
|
||||
Properties boolean Registered [readonly]
|
||||
|
||||
Contains the current IMS registration state.
|
||||
|
||||
boolean VoiceCapable [readonly, optional]
|
||||
|
||||
Boolean representing whether voice call transfer over
|
||||
RTP (IMS) is available.
|
||||
|
||||
boolean SmsCapable [readonly, optional]
|
||||
|
||||
Boolean representing whether SMS-over-IMS is available.
|
||||
@@ -95,6 +95,13 @@ Properties boolean Powered [readwrite]
|
||||
String representing the software version number of the
|
||||
modem device.
|
||||
|
||||
string SystemPath [readonly, optional]
|
||||
|
||||
String representing the system path for the modem
|
||||
device.
|
||||
For modems detected by udev events, this corresponds to
|
||||
the modem sysfs path.
|
||||
|
||||
array{string} Features [readonly]
|
||||
|
||||
List of currently enabled features. It uses simple
|
||||
@@ -127,6 +134,8 @@ Properties boolean Powered [readwrite]
|
||||
org.ofono.CallVolume
|
||||
org.ofono.CellBroadcast
|
||||
org.ofono.Handsfree
|
||||
org.ofono.IpMultimediaSystem
|
||||
org.ofono.LongTermEvolution
|
||||
org.ofono.LocationReporting
|
||||
org.ofono.MessageManager
|
||||
org.ofono.MessageWaiting
|
||||
|
||||
@@ -200,3 +200,8 @@ Properties boolean Present [readonly]
|
||||
might have changed the retry counters, i.e. calls to
|
||||
ChangePin(), EnterPin(), ResetPin() LockPin(),
|
||||
UnlockPin().
|
||||
|
||||
string ImsPrivateIdentity [readonly, optional]
|
||||
|
||||
Contains the SIM's ImsPrivateIdentity, read from the
|
||||
ISIM.
|
||||
|
||||
104
ofono/doc/sim-auth-api.txt
Normal file
104
ofono/doc/sim-auth-api.txt
Normal file
@@ -0,0 +1,104 @@
|
||||
SimAuthentication heiarchy [experimental]
|
||||
===========================================
|
||||
|
||||
Service org.ofono
|
||||
Interface org.ofono.SimAuthentication
|
||||
Object path [variable prefix]/{modem0,modem1,...}
|
||||
|
||||
Methods array{object,dict} GetApplications()
|
||||
|
||||
Get an array of all SIM applications found during
|
||||
discovery. In the format "a{oa{sv}}" where 'o' is
|
||||
the object path for the application e.g.
|
||||
|
||||
o = "/modem1/A0000000871004FFFFFFFF8906190000"
|
||||
|
||||
Each dictionary will contain 'Type' e.g. 'Ims' and
|
||||
'Name' e.g. 'ISim'
|
||||
|
||||
For each application there will be a corresponding
|
||||
object that matches the path (o). The type will
|
||||
signify which interfaces are under that object (below).
|
||||
|
||||
type = Umts --> org.ofono.USimApplication
|
||||
type = Ims --> org.ofono.ISimApplication
|
||||
|
||||
SimAuth USIM application heiarchy [experimental]
|
||||
===========================================
|
||||
|
||||
Service org.ofono
|
||||
Interface org.ofono.USimApplication
|
||||
Object path [variable prefix]/{modem0,modem1,...}/{AID name}
|
||||
|
||||
Methods dict GetProperties()
|
||||
|
||||
Returns properties for the USimApplication. See
|
||||
properties section for available properties.
|
||||
|
||||
array{dict{string, array{byte}}}
|
||||
GsmAuthenticate(array{array{byte}} rands)
|
||||
|
||||
Run the USIM application GSM AUTHENTICATE algorithm
|
||||
with N random challenges 'rands'. This should be an
|
||||
array of an array of bytes ("aay"). The number of
|
||||
random challenges is limited to a maximum of 3.
|
||||
|
||||
Returns the derived Kc/SRES values as an array of
|
||||
dictionaries. The index of each dictionary matches
|
||||
the index of the rand value in the method call. The
|
||||
keys for each dictionary are "Kc" and "SRES" and both
|
||||
are arrays of bytes.
|
||||
|
||||
Possible Errors:
|
||||
[service].Error.NotSupported
|
||||
[service].Error.Busy
|
||||
|
||||
dict{string, array{byte}}
|
||||
UmtsAuthenticate(array{byte} rand, array{byte} autn)
|
||||
|
||||
Run the UMTS AUTHENTICATE algorithm in the 3G
|
||||
context with 'rand' and 'autn'. A dictionary will be
|
||||
returned containing 'RES', 'CK', 'IK' and possibly
|
||||
'Kc' if service 27 is available. If there was a
|
||||
sync error 'AUTS' will be returned.
|
||||
|
||||
Possible Errors: [service].Error.NotSupported
|
||||
|
||||
Properties string Type [readonly]
|
||||
|
||||
Type of application: 'Umts'
|
||||
|
||||
string Name [readonly]
|
||||
|
||||
Human readable name: 'USim'
|
||||
|
||||
SimAuth ISIM application heiarchy [experimental]
|
||||
===========================================
|
||||
|
||||
Service org.ofono
|
||||
Interface org.ofono.ISimApplication
|
||||
Object [variable prefix]/{modem0,modem1,...}/{AID name}
|
||||
|
||||
Methods dict GetProperties()
|
||||
|
||||
Returns properties for the ISimApplication. See
|
||||
the properties section for available properties.
|
||||
|
||||
dict{string, array{byte}
|
||||
ImsAuthenticate(array{byte} rand, array{byte} autn)
|
||||
|
||||
Run the UMTS AUTHENTICATE algorithm in the IMS
|
||||
context with 'rand' and 'autn'. A dictionary will be
|
||||
returned containing 'RES', 'CK', 'IK' and possibly
|
||||
'Kc' if service 27 is available. If there was a
|
||||
sync error 'AUTS' will be returned.
|
||||
|
||||
Possible Errors: [service].Error.NotSupported
|
||||
|
||||
Properties string Type [readonly]
|
||||
|
||||
Type of application: 'Ims'
|
||||
|
||||
string Name [readonly]
|
||||
|
||||
Human readable name: 'ISim'
|
||||
@@ -59,6 +59,27 @@ Methods dict GetProperties()
|
||||
[service].Error.NotImplemented
|
||||
[service].Error.Failed
|
||||
|
||||
object DialLast()
|
||||
|
||||
Initiates a new outgoing call to the last dialled number.
|
||||
|
||||
Possible Errors: [service].Error.InProgress
|
||||
[service].Error.InvalidArguments
|
||||
[service].Error.InvalidFormat
|
||||
[service].Error.NotImplemented
|
||||
[service].Error.Failed
|
||||
|
||||
object DialMemory(string memory position, string hide_callerid)
|
||||
|
||||
Initiates a new outgoing call to the number in the given memory
|
||||
position/favourite. For callerid see the Dial method.
|
||||
|
||||
Possible Errors: [service].Error.InProgress
|
||||
[service].Error.InvalidArguments
|
||||
[service].Error.InvalidFormat
|
||||
[service].Error.NotImplemented
|
||||
[service].Error.Failed
|
||||
|
||||
void Transfer()
|
||||
|
||||
Joins the currently Active (or Outgoing, depending
|
||||
|
||||
@@ -50,7 +50,6 @@ static int atmodem_init(void)
|
||||
at_call_volume_init();
|
||||
at_gprs_init();
|
||||
at_gprs_context_init();
|
||||
at_sim_auth_init();
|
||||
at_gnss_init();
|
||||
at_lte_init();
|
||||
|
||||
@@ -59,7 +58,6 @@ static int atmodem_init(void)
|
||||
|
||||
static void atmodem_exit(void)
|
||||
{
|
||||
at_sim_auth_exit();
|
||||
at_stk_exit();
|
||||
at_sim_exit();
|
||||
at_sms_exit();
|
||||
|
||||
@@ -48,6 +48,51 @@ struct cbs_data {
|
||||
unsigned int vendor;
|
||||
};
|
||||
|
||||
static void at_xmm_etw_sec_notify(GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct ofono_cbs *cbs = user_data;
|
||||
const char *hexpdu;
|
||||
int pdulen;
|
||||
GAtResultIter iter;
|
||||
unsigned char pdu[88];
|
||||
long hexpdulen;
|
||||
|
||||
DBG("");
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (!g_at_result_iter_next(&iter, "+XETWSECWARN:"))
|
||||
return;
|
||||
|
||||
if (!g_at_result_iter_next_number(&iter, &pdulen))
|
||||
return;
|
||||
|
||||
if (pdulen != 88) {
|
||||
ofono_error("Got a CBM message with invalid PDU size!");
|
||||
return;
|
||||
}
|
||||
|
||||
hexpdu = g_at_result_pdu(result);
|
||||
if (hexpdu == NULL) {
|
||||
ofono_error("Got a CBM, but no PDU. Are we in text mode?");
|
||||
return;
|
||||
}
|
||||
|
||||
DBG("Got new Cell Broadcast via XETWSECWARN: %s, %d", hexpdu, pdulen);
|
||||
|
||||
if (decode_hex_own_buf(hexpdu, -1, &hexpdulen, 0, pdu) == NULL) {
|
||||
ofono_error("Unable to hex-decode the PDU");
|
||||
return;
|
||||
}
|
||||
|
||||
if (hexpdulen != pdulen) {
|
||||
ofono_error("hexpdu length not equal to reported pdu length");
|
||||
return;
|
||||
}
|
||||
|
||||
ofono_cbs_notify(cbs, pdu, pdulen);
|
||||
}
|
||||
|
||||
static void at_cbm_notify(GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct ofono_cbs *cbs = user_data;
|
||||
@@ -124,6 +169,10 @@ static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,
|
||||
g_at_chat_send(data->chat, "AT+CSCB=0", none_prefix,
|
||||
NULL, NULL, NULL);
|
||||
break;
|
||||
case OFONO_VENDOR_XMM:
|
||||
g_at_chat_send(data->chat, "AT+XETWNTFYSTART=2", none_prefix,
|
||||
NULL, NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -151,6 +200,10 @@ static void at_cbs_clear_topics(struct ofono_cbs *cbs,
|
||||
|
||||
DBG("");
|
||||
|
||||
if (data->vendor == OFONO_VENDOR_XMM)
|
||||
g_at_chat_send(data->chat, "AT+XETWNTFYSTOP=2", none_prefix,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
if (g_at_chat_send(data->chat, "AT+CSCB=0", none_prefix,
|
||||
at_cscb_set_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
@@ -175,6 +228,10 @@ static void at_cbs_register(gboolean ok, GAtResult *result, gpointer user)
|
||||
*/
|
||||
g_at_chat_register(data->chat, "+CBM:", at_cbm_notify, TRUE, cbs, NULL);
|
||||
|
||||
if (data->vendor == OFONO_VENDOR_XMM)
|
||||
g_at_chat_register(data->chat, "+XETWSECWARN:",
|
||||
at_xmm_etw_sec_notify, TRUE, cbs, NULL);
|
||||
|
||||
ofono_cbs_register(cbs);
|
||||
}
|
||||
|
||||
@@ -223,6 +280,13 @@ static int at_cbs_probe(struct ofono_cbs *cbs, unsigned int vendor,
|
||||
|
||||
ofono_cbs_set_data(cbs, data);
|
||||
|
||||
if (vendor == OFONO_VENDOR_XMM) {
|
||||
g_at_chat_send(data->chat, "AT+XCMAS=1", cscb_prefix,
|
||||
NULL, NULL, NULL);
|
||||
g_at_chat_send(data->chat, "AT+XETWCFG=1,1,0,0; ", none_prefix,
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
g_at_chat_send(data->chat, "AT+CSCB=?", cscb_prefix,
|
||||
at_cscb_support_cb, cbs, NULL);
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ static gboolean lte_delayed_register(gpointer user_data)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int at_lte_probe(struct ofono_lte *lte, void *data)
|
||||
static int at_lte_probe(struct ofono_lte *lte, unsigned int vendor, void *data)
|
||||
{
|
||||
GAtChat *chat = data;
|
||||
struct lte_driver_data *ldd;
|
||||
|
||||
@@ -48,6 +48,7 @@ static const char *cops_prefix[] = { "+COPS:", NULL };
|
||||
static const char *csq_prefix[] = { "+CSQ:", NULL };
|
||||
static const char *cind_prefix[] = { "+CIND:", NULL };
|
||||
static const char *cmer_prefix[] = { "+CMER:", NULL };
|
||||
static const char *smoni_prefix[] = { "^SMONI:", NULL };
|
||||
static const char *zpas_prefix[] = { "+ZPAS:", NULL };
|
||||
static const char *option_tech_prefix[] = { "_OCTI:", "_OUWCTI:", NULL };
|
||||
|
||||
@@ -178,6 +179,31 @@ static int option_parse_tech(GAtResult *result)
|
||||
return tech;
|
||||
}
|
||||
|
||||
static int cinterion_parse_tech(GAtResult *result)
|
||||
{
|
||||
int tech = -1;
|
||||
GAtResultIter iter;
|
||||
const char *technology;
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (!g_at_result_iter_next(&iter, "^SMONI: "))
|
||||
return tech;
|
||||
|
||||
if (!g_at_result_iter_next_unquoted_string(&iter, &technology))
|
||||
return tech;
|
||||
|
||||
if (strcmp(technology, "2G") == 0) {
|
||||
tech = ACCESS_TECHNOLOGY_GSM_EGPRS;
|
||||
} else if (strcmp(technology, "3G") == 0) {
|
||||
tech = ACCESS_TECHNOLOGY_UTRAN;
|
||||
} else if (strcmp(technology, "4G") == 0) {
|
||||
tech = ACCESS_TECHNOLOGY_EUTRAN;
|
||||
}
|
||||
|
||||
return tech;
|
||||
}
|
||||
|
||||
static void at_creg_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
@@ -205,6 +231,18 @@ static void at_creg_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
cb(&error, status, lac, ci, tech, cbd->data);
|
||||
}
|
||||
|
||||
static void cinterion_query_tech_cb(gboolean ok, GAtResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
struct tech_query *tq = user_data;
|
||||
int tech;
|
||||
|
||||
tech = cinterion_parse_tech(result);
|
||||
|
||||
ofono_netreg_status_notify(tq->netreg,
|
||||
tq->status, tq->lac, tq->ci, tech);
|
||||
}
|
||||
|
||||
static void zte_tech_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
@@ -1518,6 +1556,12 @@ static void creg_notify(GAtResult *result, gpointer user_data)
|
||||
option_query_tech_cb, tq, g_free) > 0)
|
||||
return;
|
||||
break;
|
||||
case OFONO_VENDOR_CINTERION:
|
||||
if (g_at_chat_send(nd->chat, "AT^SMONI",
|
||||
smoni_prefix,
|
||||
cinterion_query_tech_cb, tq, g_free) > 0)
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
||||
g_free(tq);
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/sim-auth.h>
|
||||
|
||||
#include "gatchat.h"
|
||||
#include "gatresult.h"
|
||||
#include "simutil.h"
|
||||
#include "vendor.h"
|
||||
|
||||
#include "atmodem.h"
|
||||
|
||||
struct sim_auth_data {
|
||||
GAtChat *chat;
|
||||
unsigned int vendor;
|
||||
};
|
||||
|
||||
static const char *cuad_prefix[] = { "+CUAD:", NULL };
|
||||
|
||||
static void at_discover_apps_cb(gboolean ok, GAtResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
GAtResultIter iter;
|
||||
ofono_sim_list_apps_cb_t cb = cbd->cb;
|
||||
struct ofono_error error;
|
||||
const unsigned char *dataobj;
|
||||
gint linelen;
|
||||
unsigned char *buffer;
|
||||
int len;
|
||||
|
||||
decode_at_error(&error, g_at_result_final_response(result));
|
||||
|
||||
if (!ok) {
|
||||
cb(&error, NULL, 0, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
len = 0;
|
||||
while (g_at_result_iter_next(&iter, "+CUAD:")) {
|
||||
if (!g_at_result_iter_next_hexstring(&iter, NULL, &linelen))
|
||||
goto error;
|
||||
|
||||
len += linelen;
|
||||
}
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
buffer = g_malloc(len);
|
||||
len = 0;
|
||||
|
||||
while (g_at_result_iter_next(&iter, "+CUAD:")) {
|
||||
g_at_result_iter_next_hexstring(&iter, &dataobj, &linelen);
|
||||
memcpy(buffer + len, dataobj, linelen);
|
||||
len += linelen;
|
||||
}
|
||||
|
||||
cb(&error, buffer, len, cbd->data);
|
||||
|
||||
g_free(buffer);
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd->data);
|
||||
}
|
||||
|
||||
static void at_discover_apps(struct ofono_sim_auth *sa,
|
||||
ofono_sim_list_apps_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct sim_auth_data *sad = ofono_sim_auth_get_data(sa);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
|
||||
if (g_at_chat_send(sad->chat, "AT+CUAD", cuad_prefix,
|
||||
at_discover_apps_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
g_free(cbd);
|
||||
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, 0, data);
|
||||
}
|
||||
|
||||
static gboolean at_sim_auth_register(gpointer user)
|
||||
{
|
||||
struct ofono_sim_auth *sa = user;
|
||||
|
||||
ofono_sim_auth_register(sa);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int at_sim_auth_probe(struct ofono_sim_auth *sa, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
GAtChat *chat = data;
|
||||
struct sim_auth_data *sad;
|
||||
|
||||
sad = g_new0(struct sim_auth_data, 1);
|
||||
sad->chat = g_at_chat_clone(chat);
|
||||
sad->vendor = vendor;
|
||||
|
||||
ofono_sim_auth_set_data(sa, sad);
|
||||
g_idle_add(at_sim_auth_register, sa);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void at_sim_auth_remove(struct ofono_sim_auth *sa)
|
||||
{
|
||||
struct sim_auth_data *sad = ofono_sim_auth_get_data(sa);
|
||||
|
||||
g_idle_remove_by_data(sa);
|
||||
ofono_sim_auth_set_data(sa, NULL);
|
||||
|
||||
g_at_chat_unref(sad->chat);
|
||||
g_free(sad);
|
||||
}
|
||||
|
||||
static struct ofono_sim_auth_driver driver = {
|
||||
.name = "atmodem",
|
||||
.probe = at_sim_auth_probe,
|
||||
.remove = at_sim_auth_remove,
|
||||
.list_apps = at_discover_apps,
|
||||
};
|
||||
|
||||
void at_sim_auth_init(void)
|
||||
{
|
||||
ofono_sim_auth_driver_register(&driver);
|
||||
}
|
||||
|
||||
void at_sim_auth_exit(void)
|
||||
{
|
||||
ofono_sim_auth_driver_unregister(&driver);
|
||||
}
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "gatresult.h"
|
||||
#include "simutil.h"
|
||||
#include "vendor.h"
|
||||
#include "util.h"
|
||||
|
||||
#include "atmodem.h"
|
||||
|
||||
@@ -50,7 +51,6 @@
|
||||
struct sim_data {
|
||||
GAtChat *chat;
|
||||
unsigned int vendor;
|
||||
guint ready_id;
|
||||
guint passwd_type_mask;
|
||||
struct at_util_sim_state_query *sim_state_query;
|
||||
};
|
||||
@@ -65,14 +65,36 @@ static const char *pinnum_prefix[] = { "%PINNUM:", NULL };
|
||||
static const char *oercn_prefix[] = { "_OERCN:", NULL };
|
||||
static const char *cpinr_prefixes[] = { "+CPINR:", "+CPINRE:", NULL };
|
||||
static const char *epin_prefix[] = { "*EPIN:", NULL };
|
||||
static const char *spic_prefix[] = { "+SPIC:", NULL };
|
||||
static const char *simcom_spic_prefix[] = { "+SPIC:", NULL };
|
||||
static const char *cinterion_spic_prefix[] = { "^SPIC:", NULL };
|
||||
static const char *pct_prefix[] = { "#PCT:", NULL };
|
||||
static const char *pnnm_prefix[] = { "+PNNM:", NULL };
|
||||
static const char *qpinc_prefix[] = { "+QPINC:", NULL };
|
||||
static const char *upincnt_prefix[] = { "+UPINCNT:", NULL };
|
||||
static const char *cuad_prefix[] = { "+CUAD:", NULL };
|
||||
static const char *ccho_prefix[] = { "+CCHO:", NULL };
|
||||
static const char *crla_prefix[] = { "+CRLA:", NULL };
|
||||
static const char *cgla_prefix[] = { "+CGLA:", NULL };
|
||||
static const char *none_prefix[] = { NULL };
|
||||
|
||||
static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
static void append_file_path(char *buf, const unsigned char *path,
|
||||
unsigned int path_len)
|
||||
{
|
||||
if (path_len > 0) {
|
||||
*buf++ = ',';
|
||||
*buf++ = ',';
|
||||
*buf++ = '\"';
|
||||
|
||||
for (; path_len; path_len--)
|
||||
buf += sprintf(buf, "%02hhX", *path++);
|
||||
|
||||
*buf++ = '\"';
|
||||
*buf = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
static void get_response_common_cb(gboolean ok, GAtResult *result,
|
||||
gpointer user_data, const char *prefix)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
GAtResultIter iter;
|
||||
@@ -94,7 +116,7 @@ static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (!g_at_result_iter_next(&iter, "+CRSM:"))
|
||||
if (!g_at_result_iter_next(&iter, prefix))
|
||||
goto error;
|
||||
|
||||
g_at_result_iter_next_number(&iter, &sw1);
|
||||
@@ -135,6 +157,11 @@ error:
|
||||
EF_STATUS_INVALIDATED, cbd->data);
|
||||
}
|
||||
|
||||
static void at_crsm_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
get_response_common_cb(ok, result, user_data, "+CRSM:");
|
||||
}
|
||||
|
||||
static void at_sim_read_info(struct ofono_sim *sim, int fileid,
|
||||
const unsigned char *path,
|
||||
unsigned int path_len,
|
||||
@@ -176,15 +203,7 @@ static void at_sim_read_info(struct ofono_sim *sim, int fileid,
|
||||
break;
|
||||
}
|
||||
|
||||
if (path_len > 0) {
|
||||
len += sprintf(buf + len, ",,\"");
|
||||
|
||||
for (; path_len; path_len--)
|
||||
len += sprintf(buf + len, "%02hhX", *path++);
|
||||
|
||||
buf[len++] = '\"';
|
||||
buf[len] = '\0';
|
||||
}
|
||||
append_file_path(buf + len, path, path_len);
|
||||
|
||||
if (g_at_chat_send(sd->chat, buf, crsm_prefix,
|
||||
at_crsm_info_cb, cbd, g_free) > 0)
|
||||
@@ -258,17 +277,7 @@ static void at_sim_read_binary(struct ofono_sim *sim, int fileid,
|
||||
len = snprintf(buf, sizeof(buf), "AT+CRSM=176,%i,%i,%i,%i", fileid,
|
||||
start >> 8, start & 0xff, length);
|
||||
|
||||
if (path_len > 0) {
|
||||
buf[len++] = ',';
|
||||
buf[len++] = ',';
|
||||
buf[len++] = '\"';
|
||||
|
||||
for (; path_len; path_len--)
|
||||
len += sprintf(buf + len, "%02hhX", *path++);
|
||||
|
||||
buf[len++] = '\"';
|
||||
buf[len] = '\0';
|
||||
}
|
||||
append_file_path(buf + len, path, path_len);
|
||||
|
||||
if (g_at_chat_send(sd->chat, buf, crsm_prefix,
|
||||
at_crsm_read_cb, cbd, g_free) > 0)
|
||||
@@ -288,10 +297,13 @@ static void at_sim_read_record(struct ofono_sim *sim, int fileid,
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
char buf[128];
|
||||
unsigned int len;
|
||||
|
||||
snprintf(buf, sizeof(buf), "AT+CRSM=178,%i,%i,4,%i", fileid,
|
||||
len = snprintf(buf, sizeof(buf), "AT+CRSM=178,%i,%i,4,%i", fileid,
|
||||
record, length);
|
||||
|
||||
append_file_path(buf + len, path, path_len);
|
||||
|
||||
if (g_at_chat_send(sd->chat, buf, crsm_prefix,
|
||||
at_crsm_read_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
@@ -837,7 +849,7 @@ static void at_cpinr_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
cb(&error, retries, cbd->data);
|
||||
}
|
||||
|
||||
static void at_spic_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
static void simcom_spic_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
ofono_sim_pin_retries_cb_t cb = cbd->cb;
|
||||
@@ -1054,6 +1066,46 @@ error:
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
|
||||
}
|
||||
|
||||
static void cinterion_spic_cb(gboolean ok, GAtResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
struct ofono_sim *sim = cbd->user;
|
||||
ofono_sim_pin_retries_cb_t cb = cbd->cb;
|
||||
const char *final = g_at_result_final_response(result);
|
||||
GAtResultIter iter;
|
||||
struct ofono_error error;
|
||||
int retries[OFONO_SIM_PASSWORD_INVALID];
|
||||
size_t i;
|
||||
int pin_type = ofono_sim_get_password_type(sim);
|
||||
|
||||
decode_at_error(&error, final);
|
||||
|
||||
if (!ok) {
|
||||
cb(&error, NULL, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
|
||||
retries[i] = -1;
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (!g_at_result_iter_next(&iter, "^SPIC:"))
|
||||
goto error;
|
||||
|
||||
if (!g_at_result_iter_next_number(&iter, &retries[pin_type]))
|
||||
goto error;
|
||||
|
||||
DBG("Retry : %d, type : %d", retries[pin_type], pin_type);
|
||||
cb(&error, retries, cbd->data);
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
|
||||
}
|
||||
|
||||
static void at_pin_retries_query(struct ofono_sim *sim,
|
||||
ofono_sim_pin_retries_cb_t cb,
|
||||
void *data)
|
||||
@@ -1101,8 +1153,8 @@ static void at_pin_retries_query(struct ofono_sim *sim,
|
||||
return;
|
||||
break;
|
||||
case OFONO_VENDOR_SIMCOM:
|
||||
if (g_at_chat_send(sd->chat, "AT+SPIC", spic_prefix,
|
||||
at_spic_cb, cbd, g_free) > 0)
|
||||
if (g_at_chat_send(sd->chat, "AT+SPIC", simcom_spic_prefix,
|
||||
simcom_spic_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
break;
|
||||
case OFONO_VENDOR_TELIT:
|
||||
@@ -1126,6 +1178,11 @@ static void at_pin_retries_query(struct ofono_sim *sim,
|
||||
upincnt_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
break;
|
||||
case OFONO_VENDOR_CINTERION:
|
||||
if (g_at_chat_send(sd->chat, "AT^SPIC", cinterion_spic_prefix,
|
||||
cinterion_spic_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
break;
|
||||
default:
|
||||
if (g_at_chat_send(sd->chat, "AT+CPINR", cpinr_prefixes,
|
||||
at_cpinr_cb, cbd, g_free) > 0)
|
||||
@@ -1216,100 +1273,24 @@ static void at_pin_query(struct ofono_sim *sim, ofono_sim_passwd_cb_t cb,
|
||||
CALLBACK_WITH_FAILURE(cb, -1, data);
|
||||
}
|
||||
|
||||
static void at_xsim_notify(GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
struct sim_data *sd = cbd->user;
|
||||
ofono_sim_lock_unlock_cb_t cb = cbd->cb;
|
||||
struct ofono_error error = { .type = OFONO_ERROR_TYPE_NO_ERROR };
|
||||
GAtResultIter iter;
|
||||
int state;
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (!g_at_result_iter_next(&iter, "+XSIM:"))
|
||||
return;
|
||||
|
||||
if (!g_at_result_iter_next_number(&iter, &state))
|
||||
return;
|
||||
|
||||
switch (state) {
|
||||
case 3: /* PIN verified – Ready */
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
cb(&error, cbd->data);
|
||||
|
||||
g_at_chat_unregister(sd->chat, sd->ready_id);
|
||||
sd->ready_id = 0;
|
||||
}
|
||||
|
||||
static void at_epev_notify(GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
struct sim_data *sd = cbd->user;
|
||||
ofono_sim_lock_unlock_cb_t cb = cbd->cb;
|
||||
struct ofono_error error = { .type = OFONO_ERROR_TYPE_NO_ERROR };
|
||||
|
||||
cb(&error, cbd->data);
|
||||
|
||||
g_at_chat_unregister(sd->chat, sd->ready_id);
|
||||
sd->ready_id = 0;
|
||||
}
|
||||
|
||||
static void at_qss_notify(GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
struct sim_data *sd = cbd->user;
|
||||
ofono_sim_lock_unlock_cb_t cb = cbd->cb;
|
||||
struct ofono_error error = { .type = OFONO_ERROR_TYPE_NO_ERROR };
|
||||
GAtResultIter iter;
|
||||
int state;
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (!g_at_result_iter_next(&iter, "#QSS:"))
|
||||
return;
|
||||
|
||||
if (!g_at_result_iter_next_number(&iter, &state))
|
||||
return;
|
||||
|
||||
switch (state) {
|
||||
case 3: /* SIM inserted and READY. */
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
cb(&error, cbd->data);
|
||||
|
||||
g_at_chat_unregister(sd->chat, sd->ready_id);
|
||||
sd->ready_id = 0;
|
||||
}
|
||||
|
||||
static void sim_state_cb(gboolean present, gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
struct sim_data *sd = cbd->user;
|
||||
ofono_sim_lock_unlock_cb_t cb = cbd->cb;
|
||||
void *data = cbd->data;
|
||||
struct ofono_sim *sim = user_data;
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
|
||||
at_util_sim_state_query_free(sd->sim_state_query);
|
||||
sd->sim_state_query = NULL;
|
||||
|
||||
if (present == 1)
|
||||
CALLBACK_WITH_SUCCESS(cb, data);
|
||||
else
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
ofono_sim_initialized_notify(sim);
|
||||
}
|
||||
|
||||
static void at_pin_send_cb(gboolean ok, GAtResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
struct sim_data *sd = cbd->user;
|
||||
struct ofono_sim *sim = cbd->user;
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
ofono_sim_lock_unlock_cb_t cb = cbd->cb;
|
||||
struct ofono_error error;
|
||||
|
||||
@@ -1319,36 +1300,6 @@ static void at_pin_send_cb(gboolean ok, GAtResult *result,
|
||||
goto done;
|
||||
|
||||
switch (sd->vendor) {
|
||||
case OFONO_VENDOR_IFX:
|
||||
/*
|
||||
* On the IFX modem, AT+CPIN? can return READY too
|
||||
* early and so use +XSIM notification to detect
|
||||
* the ready state of the SIM.
|
||||
*/
|
||||
sd->ready_id = g_at_chat_register(sd->chat, "+XSIM",
|
||||
at_xsim_notify,
|
||||
FALSE, cbd, g_free);
|
||||
return;
|
||||
case OFONO_VENDOR_MBM:
|
||||
/*
|
||||
* On the MBM modem, AT+CPIN? keeps returning SIM PIN
|
||||
* for a moment after successful AT+CPIN="..", but then
|
||||
* sends *EPEV when that changes.
|
||||
*/
|
||||
sd->ready_id = g_at_chat_register(sd->chat, "*EPEV",
|
||||
at_epev_notify,
|
||||
FALSE, cbd, g_free);
|
||||
return;
|
||||
case OFONO_VENDOR_TELIT:
|
||||
/*
|
||||
* On the Telit modem, AT+CPIN? can return READY too
|
||||
* early and so use #QSS notification to detect
|
||||
* the ready state of the SIM.
|
||||
*/
|
||||
sd->ready_id = g_at_chat_register(sd->chat, "#QSS",
|
||||
at_qss_notify,
|
||||
FALSE, cbd, g_free);
|
||||
return;
|
||||
case OFONO_VENDOR_ZTE:
|
||||
case OFONO_VENDOR_ALCATEL:
|
||||
case OFONO_VENDOR_HUAWEI:
|
||||
@@ -1366,15 +1317,12 @@ static void at_pin_send_cb(gboolean ok, GAtResult *result,
|
||||
* state.
|
||||
*/
|
||||
sd->sim_state_query = at_util_sim_state_query_new(sd->chat,
|
||||
2, 20, sim_state_cb, cbd,
|
||||
g_free);
|
||||
return;
|
||||
2, 20, sim_state_cb, sim,
|
||||
NULL);
|
||||
}
|
||||
|
||||
done:
|
||||
cb(&error, cbd->data);
|
||||
|
||||
g_free(cbd);
|
||||
}
|
||||
|
||||
static void at_pin_send(struct ofono_sim *sim, const char *passwd,
|
||||
@@ -1385,12 +1333,12 @@ static void at_pin_send(struct ofono_sim *sim, const char *passwd,
|
||||
char buf[64];
|
||||
int ret;
|
||||
|
||||
cbd->user = sd;
|
||||
cbd->user = sim;
|
||||
|
||||
snprintf(buf, sizeof(buf), "AT+CPIN=\"%s\"", passwd);
|
||||
|
||||
ret = g_at_chat_send(sd->chat, buf, none_prefix,
|
||||
at_pin_send_cb, cbd, NULL);
|
||||
at_pin_send_cb, cbd, g_free);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
@@ -1411,12 +1359,12 @@ static void at_pin_send_puk(struct ofono_sim *sim, const char *puk,
|
||||
char buf[64];
|
||||
int ret;
|
||||
|
||||
cbd->user = sd;
|
||||
cbd->user = sim;
|
||||
|
||||
snprintf(buf, sizeof(buf), "AT+CPIN=\"%s\",\"%s\"", puk, passwd);
|
||||
|
||||
ret = g_at_chat_send(sd->chat, buf, none_prefix,
|
||||
at_pin_send_cb, cbd, NULL);
|
||||
at_pin_send_cb, cbd, g_free);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
@@ -1603,6 +1551,327 @@ done:
|
||||
ofono_sim_register(sim);
|
||||
}
|
||||
|
||||
static void at_discover_apps_cb(gboolean ok, GAtResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
GAtResultIter iter;
|
||||
ofono_sim_list_apps_cb_t cb = cbd->cb;
|
||||
struct ofono_error error;
|
||||
const unsigned char *buffer;
|
||||
int len;
|
||||
|
||||
decode_at_error(&error, g_at_result_final_response(result));
|
||||
|
||||
if (!ok) {
|
||||
cb(&error, NULL, 0, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (!g_at_result_iter_next(&iter, "+CUAD:"))
|
||||
goto error;
|
||||
|
||||
if (!g_at_result_iter_next_hexstring(&iter, &buffer, &len))
|
||||
goto error;
|
||||
|
||||
cb(&error, buffer, len, cbd->data);
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd->data);
|
||||
}
|
||||
|
||||
static void at_discover_apps(struct ofono_sim *sim,
|
||||
ofono_sim_list_apps_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
|
||||
if (g_at_chat_send(sd->chat, "AT+CUAD", cuad_prefix,
|
||||
at_discover_apps_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
g_free(cbd);
|
||||
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, 0, data);
|
||||
}
|
||||
|
||||
static void at_open_channel_cb(gboolean ok, GAtResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
GAtResultIter iter;
|
||||
ofono_sim_open_channel_cb_t cb = cbd->cb;
|
||||
struct ofono_error error;
|
||||
int session_id = -1;
|
||||
|
||||
decode_at_error(&error, g_at_result_final_response(result));
|
||||
|
||||
if (!ok)
|
||||
goto error;
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (!g_at_result_iter_next(&iter, "+CCHO:"))
|
||||
goto error;
|
||||
|
||||
if (!g_at_result_iter_next_number(&iter, &session_id))
|
||||
goto error;
|
||||
|
||||
cb(&error, session_id, cbd->data);
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
cb(&error, -1, cbd->data);
|
||||
}
|
||||
|
||||
static void at_open_channel(struct ofono_sim *sim, const unsigned char *aid,
|
||||
ofono_sim_open_channel_cb_t cb, void *data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
char cmd[43];
|
||||
int ret = 0;
|
||||
|
||||
strcpy(cmd, "AT+CCHO=\"");
|
||||
ret += 9;
|
||||
|
||||
encode_hex_own_buf(aid, 16, 0, cmd + ret);
|
||||
ret += 32;
|
||||
|
||||
strcpy(cmd + ret, "\"");
|
||||
|
||||
if (g_at_chat_send(sd->chat, cmd, ccho_prefix, at_open_channel_cb,
|
||||
cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
g_free(cbd);
|
||||
|
||||
CALLBACK_WITH_FAILURE(cb, -1, data);
|
||||
}
|
||||
|
||||
static void at_close_channel_cb(gboolean ok, GAtResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
ofono_sim_close_channel_cb_t cb = cbd->cb;
|
||||
struct ofono_error error;
|
||||
|
||||
decode_at_error(&error, g_at_result_final_response(result));
|
||||
|
||||
if (cb)
|
||||
cb(&error, cbd->data);
|
||||
}
|
||||
|
||||
static void at_close_channel(struct ofono_sim *sim, int session_id,
|
||||
ofono_sim_close_channel_cb_t cb, void *data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
char cmd[15];
|
||||
|
||||
sprintf(cmd, "AT+CCHC=%d", session_id);
|
||||
|
||||
g_at_chat_send(sd->chat, cmd, NULL, at_close_channel_cb, cbd, g_free);
|
||||
}
|
||||
|
||||
static void at_crla_read_cb(gboolean ok, GAtResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
GAtResultIter iter;
|
||||
ofono_sim_read_cb_t cb = cbd->cb;
|
||||
struct ofono_error error;
|
||||
const guint8 *response;
|
||||
gint sw1, sw2, len;
|
||||
|
||||
decode_at_error(&error, g_at_result_final_response(result));
|
||||
|
||||
if (!ok) {
|
||||
cb(&error, NULL, 0, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (!g_at_result_iter_next(&iter, "+CRLA:")) {
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
g_at_result_iter_next_number(&iter, &sw1);
|
||||
g_at_result_iter_next_number(&iter, &sw2);
|
||||
|
||||
if ((sw1 != 0x90 && sw1 != 0x91 && sw1 != 0x92 && sw1 != 0x9f) ||
|
||||
(sw1 == 0x90 && sw2 != 0x00)) {
|
||||
memset(&error, 0, sizeof(error));
|
||||
|
||||
error.type = OFONO_ERROR_TYPE_SIM;
|
||||
error.error = (sw1 << 8) | sw2;
|
||||
|
||||
cb(&error, NULL, 0, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!g_at_result_iter_next_hexstring(&iter, &response, &len)) {
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, 0, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
DBG("crla_read_cb: %02x, %02x, %d", sw1, sw2, len);
|
||||
|
||||
cb(&error, response, len, cbd->data);
|
||||
}
|
||||
|
||||
static void at_session_read_binary(struct ofono_sim *sim, int session,
|
||||
int fileid, int start, int length,
|
||||
const unsigned char *path,
|
||||
unsigned int path_len,
|
||||
ofono_sim_read_cb_t cb, void *data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
char buf[64];
|
||||
unsigned int len;
|
||||
|
||||
len = snprintf(buf, sizeof(buf), "AT+CRLA=%i,176,%i,%i,%i,%i,,",
|
||||
session, fileid, start >> 8, start & 0xff, length);
|
||||
|
||||
append_file_path(buf + len, path, path_len);
|
||||
|
||||
if (g_at_chat_send(sd->chat, buf, crla_prefix,
|
||||
at_crla_read_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
g_free(cbd);
|
||||
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, 0, data);
|
||||
}
|
||||
|
||||
static void at_session_read_record(struct ofono_sim *sim, int session_id,
|
||||
int fileid, int record, int length,
|
||||
const unsigned char *path,
|
||||
unsigned int path_len,
|
||||
ofono_sim_read_cb_t cb, void *data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
char buf[128];
|
||||
unsigned int len;
|
||||
|
||||
len = snprintf(buf, sizeof(buf), "AT+CRLA=%i,178,%i,%i,4,%i",
|
||||
session_id, fileid, record, length);
|
||||
|
||||
append_file_path(buf + len, path, path_len);
|
||||
|
||||
if (g_at_chat_send(sd->chat, buf, crla_prefix,
|
||||
at_crla_read_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
g_free(cbd);
|
||||
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, 0, data);
|
||||
}
|
||||
|
||||
static void at_crla_info_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
get_response_common_cb(ok, result, user_data, "+CRLA:");
|
||||
}
|
||||
|
||||
static void at_session_read_info(struct ofono_sim *sim, int session_id,
|
||||
int fileid, const unsigned char *path,
|
||||
unsigned int path_len,
|
||||
ofono_sim_file_info_cb_t cb, void *data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
char buf[128];
|
||||
unsigned int len;
|
||||
|
||||
len = snprintf(buf, sizeof(buf), "AT+CRLA=%i,192,%i", session_id,
|
||||
fileid);
|
||||
|
||||
append_file_path(buf + len, path, path_len);
|
||||
|
||||
if (g_at_chat_send(sd->chat, buf, crla_prefix,
|
||||
at_crla_info_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
g_free(cbd);
|
||||
|
||||
CALLBACK_WITH_FAILURE(cb, -1, -1, -1, NULL,
|
||||
EF_STATUS_INVALIDATED, data);
|
||||
}
|
||||
|
||||
static void logical_access_cb(gboolean ok, GAtResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
ofono_sim_logical_access_cb_t cb = cbd->cb;
|
||||
struct ofono_error error;
|
||||
const char *str_data;
|
||||
unsigned char *raw;
|
||||
gint len = 0;
|
||||
GAtResultIter iter;
|
||||
|
||||
decode_at_error(&error, g_at_result_final_response(result));
|
||||
|
||||
if (!ok)
|
||||
goto error;
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (!g_at_result_iter_next(&iter, "+CGLA:"))
|
||||
goto error;
|
||||
|
||||
if (!g_at_result_iter_next_number(&iter, &len))
|
||||
goto error;
|
||||
|
||||
if (!g_at_result_iter_next_string(&iter, &str_data))
|
||||
goto error;
|
||||
|
||||
raw = alloca(len / 2);
|
||||
|
||||
decode_hex_own_buf(str_data, len, NULL, 0, raw);
|
||||
|
||||
cb(&error, raw, len / 2, cbd->data);
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
cb(&error, NULL, 0, cbd->data);
|
||||
}
|
||||
|
||||
static void at_logical_access(struct ofono_sim *sim, int session_id,
|
||||
const unsigned char *pdu, unsigned int len,
|
||||
ofono_sim_logical_access_cb_t cb, void *data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
int ret = 0;
|
||||
char cmd[(len * 2) + 19];
|
||||
|
||||
ret = sprintf(cmd, "AT+CGLA=%d,%d,\"", session_id, len * 2);
|
||||
|
||||
encode_hex_own_buf(pdu, len, 0, cmd + ret);
|
||||
ret += len * 2;
|
||||
|
||||
strcpy(cmd + ret, "\"");
|
||||
|
||||
if (g_at_chat_send(sd->chat, cmd, cgla_prefix, logical_access_cb,
|
||||
cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
g_free(cbd);
|
||||
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, 0, data);
|
||||
}
|
||||
|
||||
static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
@@ -1614,9 +1883,6 @@ static int at_sim_probe(struct ofono_sim *sim, unsigned int vendor,
|
||||
sd->chat = g_at_chat_clone(chat);
|
||||
sd->vendor = vendor;
|
||||
|
||||
if (sd->vendor == OFONO_VENDOR_MBM)
|
||||
g_at_chat_send(sd->chat, "AT*EPEE=1", NULL, NULL, NULL, NULL);
|
||||
|
||||
ofono_sim_set_data(sim, sd);
|
||||
|
||||
/* <fac>s supported by default */
|
||||
@@ -1662,6 +1928,13 @@ static struct ofono_sim_driver driver = {
|
||||
.lock = at_pin_enable,
|
||||
.change_passwd = at_change_passwd,
|
||||
.query_facility_lock = at_query_clck,
|
||||
.list_apps = at_discover_apps,
|
||||
.open_channel = at_open_channel,
|
||||
.close_channel = at_close_channel,
|
||||
.session_read_binary = at_session_read_binary,
|
||||
.session_read_record = at_session_read_record,
|
||||
.session_read_info = at_session_read_info,
|
||||
.logical_access = at_logical_access
|
||||
};
|
||||
|
||||
static struct ofono_sim_driver driver_noef = {
|
||||
|
||||
@@ -104,7 +104,7 @@ static void at_csca_set(struct ofono_sms *sms,
|
||||
{
|
||||
struct sms_data *data = ofono_sms_get_data(sms);
|
||||
struct cb_data *cbd = cb_data_new(cb, user_data);
|
||||
char buf[64];
|
||||
char buf[128];
|
||||
|
||||
snprintf(buf, sizeof(buf), "AT+CSCA=\"%s\",%d", sca->number, sca->type);
|
||||
|
||||
|
||||
@@ -1120,6 +1120,7 @@ static int at_voicecall_probe(struct ofono_voicecall *vc, unsigned int vendor,
|
||||
|
||||
switch (vd->vendor) {
|
||||
case OFONO_VENDOR_QUALCOMM_MSM:
|
||||
case OFONO_VENDOR_SIMCOM:
|
||||
g_at_chat_send(vd->chat, "AT+COLP=0", NULL, NULL, NULL, NULL);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -125,6 +125,7 @@ static struct ofono_call *create_call(struct ofono_voicecall *vc, int type,
|
||||
if (clip != 2) {
|
||||
strncpy(call->phone_number.number, num,
|
||||
OFONO_MAX_PHONE_NUMBER_LENGTH);
|
||||
call->phone_number.number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0';
|
||||
call->phone_number.type = num_type;
|
||||
}
|
||||
|
||||
@@ -404,6 +405,45 @@ static void hfp_dial(struct ofono_voicecall *vc,
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
}
|
||||
|
||||
static void hfp_dial_last(struct ofono_voicecall *vc, ofono_voicecall_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
|
||||
cbd->user = vc;
|
||||
|
||||
if (g_at_chat_send(vd->chat, "AT+BLDN", none_prefix,
|
||||
atd_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
g_free(cbd);
|
||||
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
|
||||
}
|
||||
|
||||
static void hfp_dial_memory(struct ofono_voicecall *vc,
|
||||
unsigned int memory_location,
|
||||
ofono_voicecall_cb_t cb, void *data)
|
||||
{
|
||||
struct voicecall_data *vd = ofono_voicecall_get_data(vc);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
char buf[256];
|
||||
|
||||
cbd->user = vc;
|
||||
DBG("Calling memory location %d\n", memory_location);
|
||||
snprintf(buf, sizeof(buf), "ATD>%d;", memory_location);
|
||||
|
||||
if (g_at_chat_send(vd->chat, buf, none_prefix,
|
||||
atd_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
g_free(cbd);
|
||||
DBG("at_chat_failed");
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
}
|
||||
|
||||
static void hfp_template(const char *cmd, struct ofono_voicecall *vc,
|
||||
GAtResultFunc result_cb, unsigned int affected_types,
|
||||
ofono_voicecall_cb_t cb, void *data)
|
||||
@@ -1268,6 +1308,8 @@ static struct ofono_voicecall_driver driver = {
|
||||
.probe = hfp_voicecall_probe,
|
||||
.remove = hfp_voicecall_remove,
|
||||
.dial = hfp_dial,
|
||||
.dial_last = hfp_dial_last,
|
||||
.dial_memory = hfp_dial_memory,
|
||||
.answer = hfp_answer,
|
||||
.hangup_active = hfp_hangup,
|
||||
.hold_all_active = hfp_hold_all_active,
|
||||
|
||||
107
ofono/drivers/mbimmodem/devinfo.c
Normal file
107
ofono/drivers/mbimmodem/devinfo.c
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/devinfo.h>
|
||||
|
||||
#include "drivers/mbimmodem/mbimmodem.h"
|
||||
|
||||
struct devinfo_data {
|
||||
struct l_idle *delayed_register;
|
||||
};
|
||||
|
||||
static void mbim_query_revision(struct ofono_devinfo *info,
|
||||
ofono_devinfo_query_cb_t cb, void *data)
|
||||
{
|
||||
struct ofono_modem *modem = ofono_devinfo_get_modem(info);
|
||||
const char *revision = ofono_modem_get_string(modem, "FirmwareInfo");
|
||||
|
||||
if (revision)
|
||||
CALLBACK_WITH_SUCCESS(cb, revision, data);
|
||||
else
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, data);
|
||||
}
|
||||
|
||||
static void mbim_query_serial(struct ofono_devinfo *info,
|
||||
ofono_devinfo_query_cb_t cb, void *data)
|
||||
{
|
||||
struct ofono_modem *modem = ofono_devinfo_get_modem(info);
|
||||
const char *serial = ofono_modem_get_string(modem, "DeviceId");
|
||||
|
||||
if (serial)
|
||||
CALLBACK_WITH_SUCCESS(cb, serial, data);
|
||||
else
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, data);
|
||||
}
|
||||
|
||||
static void delayed_register(struct l_idle *idle, void *user_data)
|
||||
{
|
||||
struct ofono_devinfo *info = user_data;
|
||||
struct devinfo_data *dd = ofono_devinfo_get_data(info);
|
||||
|
||||
l_idle_remove(idle);
|
||||
dd->delayed_register = NULL;
|
||||
|
||||
ofono_devinfo_register(info);
|
||||
}
|
||||
|
||||
static int mbim_devinfo_probe(struct ofono_devinfo *info, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct devinfo_data *dd = l_new(struct devinfo_data, 1);
|
||||
|
||||
dd->delayed_register = l_idle_create(delayed_register, info, NULL);
|
||||
ofono_devinfo_set_data(info, dd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mbim_devinfo_remove(struct ofono_devinfo *info)
|
||||
{
|
||||
struct devinfo_data *dd = ofono_devinfo_get_data(info);
|
||||
|
||||
ofono_devinfo_set_data(info, NULL);
|
||||
l_idle_remove(dd->delayed_register);
|
||||
l_free(dd);
|
||||
}
|
||||
|
||||
static struct ofono_devinfo_driver driver = {
|
||||
.name = "mbim",
|
||||
.probe = mbim_devinfo_probe,
|
||||
.remove = mbim_devinfo_remove,
|
||||
.query_revision = mbim_query_revision,
|
||||
.query_serial = mbim_query_serial,
|
||||
};
|
||||
|
||||
void mbim_devinfo_init(void)
|
||||
{
|
||||
ofono_devinfo_driver_register(&driver);
|
||||
}
|
||||
|
||||
void mbim_devinfo_exit(void)
|
||||
{
|
||||
ofono_devinfo_driver_unregister(&driver);
|
||||
}
|
||||
464
ofono/drivers/mbimmodem/gprs-context.c
Normal file
464
ofono/drivers/mbimmodem/gprs-context.c
Normal file
@@ -0,0 +1,464 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/gprs-context.h>
|
||||
|
||||
#include "drivers/mbimmodem/mbim.h"
|
||||
#include "drivers/mbimmodem/mbim-message.h"
|
||||
#include "drivers/mbimmodem/mbimmodem.h"
|
||||
|
||||
enum state {
|
||||
STATE_IDLE,
|
||||
STATE_ENABLING,
|
||||
STATE_DISABLING,
|
||||
STATE_ACTIVE,
|
||||
};
|
||||
|
||||
struct gprs_context_data {
|
||||
struct mbim_device *device;
|
||||
unsigned int active_context;
|
||||
enum ofono_gprs_proto proto;
|
||||
enum state state;
|
||||
ofono_gprs_context_cb_t cb;
|
||||
void *cb_data;
|
||||
};
|
||||
|
||||
static uint32_t proto_to_context_ip_type(enum ofono_gprs_proto proto)
|
||||
{
|
||||
switch (proto) {
|
||||
case OFONO_GPRS_PROTO_IP:
|
||||
return 1; /* MBIMContextIPTypeIPv4 */
|
||||
case OFONO_GPRS_PROTO_IPV6:
|
||||
return 2; /* MBIMContextIPTypeIPv6 */
|
||||
case OFONO_GPRS_PROTO_IPV4V6:
|
||||
return 3; /* MBIMContextIPTypeIPv4v6 */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t auth_method_to_auth_protocol(enum ofono_gprs_auth_method method)
|
||||
{
|
||||
switch (method) {
|
||||
case OFONO_GPRS_AUTH_METHOD_CHAP:
|
||||
return 2; /* MBIMAuthProtocolChap */
|
||||
case OFONO_GPRS_AUTH_METHOD_PAP:
|
||||
return 1; /* MBIMAuthProtocolPap */
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mbim_deactivate_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct ofono_gprs_context *gc = user;
|
||||
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
|
||||
|
||||
DBG("");
|
||||
|
||||
gcd->active_context = 0;
|
||||
gcd->state = STATE_IDLE;
|
||||
|
||||
if (!gcd->cb)
|
||||
return;
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
|
||||
else
|
||||
CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
|
||||
}
|
||||
|
||||
static void mbim_gprs_deactivate_primary(struct ofono_gprs_context *gc,
|
||||
unsigned int cid,
|
||||
ofono_gprs_context_cb_t cb, void *data)
|
||||
{
|
||||
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
|
||||
struct mbim_message *message;
|
||||
|
||||
DBG("cid %u", cid);
|
||||
|
||||
gcd->state = STATE_DISABLING;
|
||||
gcd->cb = cb;
|
||||
gcd->cb_data = data;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_CONNECT,
|
||||
MBIM_COMMAND_TYPE_SET);
|
||||
mbim_message_set_arguments(message, "uusssuuu16y",
|
||||
cid, 0, NULL, NULL, NULL, 0, 0, 0,
|
||||
mbim_context_type_internet);
|
||||
|
||||
if (mbim_device_send(gcd->device, GPRS_CONTEXT_GROUP, message,
|
||||
mbim_deactivate_cb, gc, NULL) > 0)
|
||||
return;
|
||||
|
||||
mbim_message_unref(message);
|
||||
|
||||
if (cb)
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
}
|
||||
|
||||
static void mbim_ip_configuration_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct ofono_gprs_context *gc = user;
|
||||
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
|
||||
struct ofono_modem *modem = ofono_gprs_context_get_modem(gc);
|
||||
const char *interface;
|
||||
uint32_t session_id;
|
||||
uint32_t ipv4_config_available;
|
||||
uint32_t ipv6_config_available;
|
||||
uint32_t n_ipv4_addr;
|
||||
uint32_t ipv4_addr_offset;
|
||||
uint32_t n_ipv6_addr;
|
||||
uint32_t ipv6_addr_offset;
|
||||
uint32_t ipv4_gw_offset;
|
||||
uint32_t ipv6_gw_offset;
|
||||
uint32_t n_ipv4_dns;
|
||||
uint32_t ipv4_dns_offset;
|
||||
uint32_t n_ipv6_dns;
|
||||
uint32_t ipv6_dns_offset;
|
||||
uint32_t ipv4_mtu;
|
||||
uint32_t ipv6_mtu;
|
||||
|
||||
struct in6_addr ipv6;
|
||||
struct in_addr ipv4;
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
|
||||
DBG("%u", mbim_message_get_error(message));
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
goto error;
|
||||
|
||||
if (!mbim_message_get_arguments(message, "uuuuuuuuuuuuuuu",
|
||||
&session_id,
|
||||
&ipv4_config_available, &ipv6_config_available,
|
||||
&n_ipv4_addr, &ipv4_addr_offset,
|
||||
&n_ipv6_addr, &ipv6_addr_offset,
|
||||
&ipv4_gw_offset, &ipv6_gw_offset,
|
||||
&n_ipv4_dns, &ipv4_dns_offset,
|
||||
&n_ipv6_dns, &ipv6_dns_offset,
|
||||
&ipv4_mtu, &ipv6_mtu))
|
||||
goto error;
|
||||
|
||||
if (gcd->proto == OFONO_GPRS_PROTO_IPV6)
|
||||
goto ipv6;
|
||||
|
||||
if (ipv4_config_available & 0x1) { /* Address Info present */
|
||||
uint32_t prefix;
|
||||
|
||||
if (!mbim_message_get_ipv4_element(message, ipv4_addr_offset,
|
||||
&prefix, &ipv4))
|
||||
goto error;
|
||||
|
||||
inet_ntop(AF_INET, &ipv4, buf, sizeof(buf));
|
||||
ofono_gprs_context_set_ipv4_address(gc, buf, TRUE);
|
||||
ofono_gprs_context_set_ipv4_prefix_length(gc, prefix);
|
||||
} else
|
||||
ofono_gprs_context_set_ipv4_address(gc, NULL, FALSE);
|
||||
|
||||
if (ipv4_config_available & 0x2) { /* IPv4 Gateway info */
|
||||
if (!mbim_message_get_ipv4_address(message,
|
||||
ipv4_gw_offset, &ipv4))
|
||||
goto error;
|
||||
|
||||
inet_ntop(AF_INET, &ipv4, buf, sizeof(buf));
|
||||
|
||||
ofono_gprs_context_set_ipv4_gateway(gc, buf);
|
||||
}
|
||||
|
||||
if (ipv4_config_available & 0x3) { /* IPv4 DNS Info */
|
||||
const char *dns[3];
|
||||
char dns1[INET_ADDRSTRLEN];
|
||||
char dns2[INET_ADDRSTRLEN];
|
||||
|
||||
memset(dns, 0, sizeof(dns));
|
||||
|
||||
if (n_ipv4_dns > 1) { /* Grab second DNS */
|
||||
if (!mbim_message_get_ipv4_address(message,
|
||||
ipv4_dns_offset + 4,
|
||||
&ipv4))
|
||||
goto error;
|
||||
|
||||
inet_ntop(AF_INET, &ipv4, dns2, sizeof(dns2));
|
||||
dns[1] = dns2;
|
||||
}
|
||||
|
||||
if (n_ipv4_dns > 0) { /* Grab first DNS */
|
||||
if (!mbim_message_get_ipv4_address(message,
|
||||
ipv4_dns_offset,
|
||||
&ipv4))
|
||||
goto error;
|
||||
|
||||
inet_ntop(AF_INET, &ipv4, dns1, sizeof(dns1));
|
||||
dns[0] = dns1;
|
||||
|
||||
ofono_gprs_context_set_ipv4_dns_servers(gc, dns);
|
||||
}
|
||||
}
|
||||
|
||||
if (gcd->proto == OFONO_GPRS_PROTO_IP)
|
||||
goto done;
|
||||
ipv6:
|
||||
if (ipv6_config_available & 0x1) { /* Address Info present */
|
||||
uint32_t prefix;
|
||||
|
||||
if (!mbim_message_get_ipv6_element(message, ipv6_addr_offset,
|
||||
&prefix, &ipv6))
|
||||
goto error;
|
||||
|
||||
inet_ntop(AF_INET6, &ipv6, buf, sizeof(buf));
|
||||
ofono_gprs_context_set_ipv6_address(gc, buf);
|
||||
ofono_gprs_context_set_ipv6_prefix_length(gc, prefix);
|
||||
}
|
||||
|
||||
if (ipv6_config_available & 0x2) { /* IPv6 Gateway info */
|
||||
if (!mbim_message_get_ipv6_address(message,
|
||||
ipv6_gw_offset, &ipv6))
|
||||
goto error;
|
||||
|
||||
inet_ntop(AF_INET6, &ipv6, buf, sizeof(buf));
|
||||
|
||||
ofono_gprs_context_set_ipv6_gateway(gc, buf);
|
||||
}
|
||||
|
||||
if (ipv6_config_available & 0x3) { /* IPv6 DNS Info */
|
||||
const char *dns[3];
|
||||
char dns1[INET6_ADDRSTRLEN];
|
||||
char dns2[INET6_ADDRSTRLEN];
|
||||
|
||||
memset(dns, 0, sizeof(dns));
|
||||
|
||||
if (n_ipv6_dns > 1) { /* Grab second DNS */
|
||||
if (!mbim_message_get_ipv6_address(message,
|
||||
ipv6_dns_offset + 16,
|
||||
&ipv6))
|
||||
goto error;
|
||||
|
||||
inet_ntop(AF_INET6, &ipv6, dns2, sizeof(dns2));
|
||||
dns[1] = dns2;
|
||||
}
|
||||
|
||||
if (n_ipv6_dns > 0) { /* Grab first DNS */
|
||||
if (!mbim_message_get_ipv6_address(message,
|
||||
ipv6_dns_offset,
|
||||
&ipv6))
|
||||
goto error;
|
||||
|
||||
inet_ntop(AF_INET6, &ipv6, dns1, sizeof(dns1));
|
||||
dns[0] = dns1;
|
||||
|
||||
ofono_gprs_context_set_ipv6_dns_servers(gc, dns);
|
||||
}
|
||||
}
|
||||
done:
|
||||
|
||||
gcd->state = STATE_ACTIVE;
|
||||
interface = ofono_modem_get_string(modem, "NetworkInterface");
|
||||
ofono_gprs_context_set_interface(gc, interface);
|
||||
|
||||
CALLBACK_WITH_SUCCESS(gcd->cb, gcd->cb_data);
|
||||
gcd->cb = NULL;
|
||||
gcd->cb_data = NULL;
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
|
||||
gcd->state = STATE_IDLE;
|
||||
gcd->cb = NULL;
|
||||
gcd->cb_data = NULL;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_CONNECT,
|
||||
MBIM_COMMAND_TYPE_SET);
|
||||
mbim_message_set_arguments(message, "uusssuuu16y",
|
||||
gcd->active_context, 0,
|
||||
NULL, NULL, NULL, 0, 0, 0,
|
||||
mbim_context_type_internet);
|
||||
|
||||
if (!mbim_device_send(gcd->device, GPRS_CONTEXT_GROUP, message,
|
||||
NULL, NULL, NULL))
|
||||
mbim_message_unref(message);
|
||||
}
|
||||
|
||||
static void mbim_activate_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct ofono_gprs_context *gc = user;
|
||||
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
goto error;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_IP_CONFIGURATION,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
mbim_message_set_arguments(message, "uuuuuuuuuuuuuuu",
|
||||
gcd->active_context,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
||||
|
||||
if (mbim_device_send(gcd->device, GPRS_CONTEXT_GROUP, message,
|
||||
mbim_ip_configuration_cb, gc, NULL) > 0)
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
|
||||
gcd->state = STATE_IDLE;
|
||||
gcd->cb = NULL;
|
||||
gcd->cb_data = NULL;
|
||||
}
|
||||
|
||||
static void mbim_gprs_activate_primary(struct ofono_gprs_context *gc,
|
||||
const struct ofono_gprs_primary_context *ctx,
|
||||
ofono_gprs_context_cb_t cb, void *data)
|
||||
{
|
||||
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
|
||||
struct mbim_message *message;
|
||||
|
||||
DBG("cid %u", ctx->cid);
|
||||
|
||||
gcd->state = STATE_ENABLING;
|
||||
gcd->cb = cb;
|
||||
gcd->cb_data = data;
|
||||
gcd->active_context = ctx->cid;
|
||||
gcd->proto = ctx->proto;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_CONNECT,
|
||||
MBIM_COMMAND_TYPE_SET);
|
||||
mbim_message_set_arguments(message, "uusssuuu16y",
|
||||
ctx->cid,
|
||||
1, /* MBIMActivationCommandActivate */
|
||||
ctx->apn,
|
||||
ctx->username[0] ? ctx->username : NULL,
|
||||
ctx->password[0] ? ctx->password : NULL,
|
||||
0, /*MBIMCompressionNone */
|
||||
auth_method_to_auth_protocol(ctx->auth_method),
|
||||
proto_to_context_ip_type(ctx->proto),
|
||||
mbim_context_type_internet);
|
||||
|
||||
if (mbim_device_send(gcd->device, GPRS_CONTEXT_GROUP, message,
|
||||
mbim_activate_cb, gc, NULL) > 0)
|
||||
return;
|
||||
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
}
|
||||
|
||||
static void mbim_gprs_detach_shutdown(struct ofono_gprs_context *gc,
|
||||
unsigned int cid)
|
||||
{
|
||||
DBG("");
|
||||
mbim_gprs_deactivate_primary(gc, cid, NULL, NULL);
|
||||
}
|
||||
|
||||
static void mbim_connect_notify(struct mbim_message *message, void *user)
|
||||
{
|
||||
uint32_t session_id;
|
||||
uint32_t activation_state;
|
||||
uint32_t voice_call_state;
|
||||
uint32_t ip_type;
|
||||
uint8_t context_type[16];
|
||||
uint32_t nw_error;
|
||||
char uuidstr[37];
|
||||
|
||||
DBG("");
|
||||
|
||||
if (!mbim_message_get_arguments(message, "uuuu16yu",
|
||||
&session_id, &activation_state,
|
||||
&voice_call_state, &ip_type,
|
||||
context_type, &nw_error))
|
||||
return;
|
||||
|
||||
DBG("session_id: %u, activation_state: %u, ip_type: %u",
|
||||
session_id, activation_state, ip_type);
|
||||
l_uuid_to_string(context_type, uuidstr, sizeof(uuidstr));
|
||||
DBG("context_type: %s, nw_error: %u", uuidstr, nw_error);
|
||||
}
|
||||
|
||||
static int mbim_gprs_context_probe(struct ofono_gprs_context *gc,
|
||||
unsigned int vendor, void *data)
|
||||
{
|
||||
struct mbim_device *device = data;
|
||||
struct gprs_context_data *gcd;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (!mbim_device_register(device, GPRS_CONTEXT_GROUP,
|
||||
mbim_uuid_basic_connect,
|
||||
MBIM_CID_CONNECT,
|
||||
mbim_connect_notify, gc, NULL))
|
||||
return -EIO;
|
||||
|
||||
gcd = l_new(struct gprs_context_data, 1);
|
||||
gcd->device = mbim_device_ref(device);
|
||||
|
||||
ofono_gprs_context_set_data(gc, gcd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mbim_gprs_context_remove(struct ofono_gprs_context *gc)
|
||||
{
|
||||
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
|
||||
|
||||
DBG("");
|
||||
|
||||
ofono_gprs_context_set_data(gc, NULL);
|
||||
|
||||
mbim_device_cancel_group(gcd->device, GPRS_CONTEXT_GROUP);
|
||||
mbim_device_unregister_group(gcd->device, GPRS_CONTEXT_GROUP);
|
||||
mbim_device_unref(gcd->device);
|
||||
gcd->device = NULL;
|
||||
l_free(gcd);
|
||||
}
|
||||
|
||||
static struct ofono_gprs_context_driver driver = {
|
||||
.name = "mbim",
|
||||
.probe = mbim_gprs_context_probe,
|
||||
.remove = mbim_gprs_context_remove,
|
||||
.activate_primary = mbim_gprs_activate_primary,
|
||||
.deactivate_primary = mbim_gprs_deactivate_primary,
|
||||
.detach_shutdown = mbim_gprs_detach_shutdown
|
||||
};
|
||||
|
||||
void mbim_gprs_context_init(void)
|
||||
{
|
||||
ofono_gprs_context_driver_register(&driver);
|
||||
}
|
||||
|
||||
void mbim_gprs_context_exit(void)
|
||||
{
|
||||
ofono_gprs_context_driver_unregister(&driver);
|
||||
}
|
||||
299
ofono/drivers/mbimmodem/gprs.c
Normal file
299
ofono/drivers/mbimmodem/gprs.c
Normal file
@@ -0,0 +1,299 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/gprs.h>
|
||||
#include "common.h"
|
||||
|
||||
#include "drivers/mbimmodem/mbim.h"
|
||||
#include "drivers/mbimmodem/mbim-message.h"
|
||||
#include "drivers/mbimmodem/mbimmodem.h"
|
||||
|
||||
struct gprs_data {
|
||||
struct mbim_device *device;
|
||||
struct l_idle *delayed_register;
|
||||
};
|
||||
|
||||
static void mbim_packet_service_set_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
ofono_gprs_cb_t cb = cbd->cb;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
else
|
||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_gprs_set_attached(struct ofono_gprs *gprs, int attached,
|
||||
ofono_gprs_cb_t cb, void *data)
|
||||
{
|
||||
struct gprs_data *gd = ofono_gprs_get_data(gprs);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct mbim_message *message;
|
||||
|
||||
DBG("");
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_PACKET_SERVICE,
|
||||
MBIM_COMMAND_TYPE_SET);
|
||||
/*
|
||||
* MBIMPacketServiceActionAttach (0) or
|
||||
* MBIMPacketServiceActionDetach (1)
|
||||
*/
|
||||
mbim_message_set_arguments(message, "u", attached ? 0 : 1);
|
||||
|
||||
if (mbim_device_send(gd->device, GPRS_GROUP, message,
|
||||
mbim_packet_service_set_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
}
|
||||
|
||||
static void mbim_packet_service_query_cb(struct mbim_message *message,
|
||||
void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
ofono_gprs_status_cb_t cb = cbd->cb;
|
||||
uint32_t dummy;
|
||||
uint32_t state;
|
||||
|
||||
DBG("%u", mbim_message_get_error(message));
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
goto error;
|
||||
|
||||
if (!mbim_message_get_arguments(message, "uu", &dummy, &state))
|
||||
goto error;
|
||||
|
||||
if (state == 2)
|
||||
CALLBACK_WITH_SUCCESS(cb,
|
||||
NETWORK_REGISTRATION_STATUS_REGISTERED,
|
||||
cbd->data);
|
||||
else
|
||||
CALLBACK_WITH_SUCCESS(cb, NETWORK_REGISTRATION_STATUS_UNKNOWN,
|
||||
cbd->data);
|
||||
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_gprs_registration_status(struct ofono_gprs *gprs,
|
||||
ofono_gprs_status_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct gprs_data *gd = ofono_gprs_get_data(gprs);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct mbim_message *message;
|
||||
|
||||
DBG("");
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_PACKET_SERVICE,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
mbim_message_set_arguments(message, "");
|
||||
|
||||
if (mbim_device_send(gd->device, GPRS_GROUP, message,
|
||||
mbim_packet_service_query_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, -1, data);
|
||||
}
|
||||
|
||||
static void mbim_packet_service_changed(struct mbim_message *message,
|
||||
void *user)
|
||||
{
|
||||
struct ofono_gprs *gprs = user;
|
||||
uint32_t nw_error;
|
||||
uint32_t packet_service_state;
|
||||
uint32_t highest_avail_data_class;
|
||||
uint64_t uplink_speed;
|
||||
uint64_t downlink_speed;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (!mbim_message_get_arguments(message, "uuutt",
|
||||
&nw_error,
|
||||
&packet_service_state,
|
||||
&highest_avail_data_class,
|
||||
&uplink_speed,
|
||||
&downlink_speed))
|
||||
return;
|
||||
|
||||
DBG("uplink: %"PRIu64", downlink: %"PRIu64,
|
||||
uplink_speed, downlink_speed);
|
||||
DBG("nw_error: %u", nw_error);
|
||||
|
||||
if (packet_service_state == 2) {
|
||||
uint32_t bearer =
|
||||
mbim_data_class_to_tech(highest_avail_data_class);
|
||||
|
||||
ofono_gprs_status_notify(gprs,
|
||||
NETWORK_REGISTRATION_STATUS_REGISTERED);
|
||||
ofono_gprs_bearer_notify(gprs, bearer);
|
||||
} else
|
||||
ofono_gprs_status_notify(gprs,
|
||||
NETWORK_REGISTRATION_STATUS_UNKNOWN);
|
||||
}
|
||||
|
||||
static void provisioned_contexts_query_cb(struct mbim_message *message,
|
||||
void *user)
|
||||
{
|
||||
struct mbim_message_iter contexts;
|
||||
uint32_t n_contexts;
|
||||
uint32_t id;
|
||||
uint8_t type[16];
|
||||
char *apn;
|
||||
char *username;
|
||||
char *password;
|
||||
uint32_t compression;
|
||||
uint32_t auth_protocol;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
return;
|
||||
|
||||
if (!mbim_message_get_arguments(message, "a(u16ysssuu)",
|
||||
&n_contexts, &contexts))
|
||||
return;
|
||||
|
||||
DBG("n_contexts: %u", n_contexts);
|
||||
|
||||
while (mbim_message_iter_next_entry(&contexts, &id, type, &apn,
|
||||
&username, &password,
|
||||
&compression, &auth_protocol)) {
|
||||
char uuidstr[37];
|
||||
|
||||
l_uuid_to_string(type, uuidstr, sizeof(uuidstr));
|
||||
DBG("id: %u, type: %s", id, uuidstr);
|
||||
DBG("apn: %s, username: %s, password: %s",
|
||||
apn, username, password);
|
||||
DBG("compression: %u, auth_protocol: %u",
|
||||
compression, auth_protocol);
|
||||
|
||||
l_free(apn);
|
||||
l_free(username);
|
||||
l_free(password);
|
||||
}
|
||||
}
|
||||
|
||||
static void delayed_register(struct l_idle *idle, void *user_data)
|
||||
{
|
||||
struct ofono_gprs *gprs = user_data;
|
||||
struct gprs_data *gd = ofono_gprs_get_data(gprs);
|
||||
struct mbim_message *message;
|
||||
|
||||
DBG("");
|
||||
|
||||
l_idle_remove(idle);
|
||||
gd->delayed_register = NULL;
|
||||
|
||||
/* Query provisioned contexts for debugging purposes only */
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_PROVISIONED_CONTEXTS,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
mbim_message_set_arguments(message, "");
|
||||
mbim_device_send(gd->device, 0, message,
|
||||
provisioned_contexts_query_cb, gprs, NULL);
|
||||
|
||||
if (!mbim_device_register(gd->device, GPRS_GROUP,
|
||||
mbim_uuid_basic_connect,
|
||||
MBIM_CID_PACKET_SERVICE,
|
||||
mbim_packet_service_changed,
|
||||
gprs, NULL))
|
||||
goto error;
|
||||
|
||||
ofono_gprs_register(gprs);
|
||||
return;
|
||||
|
||||
error:
|
||||
ofono_gprs_remove(gprs);
|
||||
}
|
||||
|
||||
static int mbim_gprs_probe(struct ofono_gprs *gprs, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct mbim_device *device = data;
|
||||
struct gprs_data *gd;
|
||||
|
||||
DBG("");
|
||||
|
||||
gd = l_new(struct gprs_data, 1);
|
||||
gd->device = mbim_device_ref(device);
|
||||
gd->delayed_register = l_idle_create(delayed_register, gprs, NULL);
|
||||
|
||||
ofono_gprs_set_data(gprs, gd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mbim_gprs_remove(struct ofono_gprs *gprs)
|
||||
{
|
||||
struct gprs_data *gd = ofono_gprs_get_data(gprs);
|
||||
|
||||
DBG("");
|
||||
|
||||
ofono_gprs_set_data(gprs, NULL);
|
||||
|
||||
l_idle_remove(gd->delayed_register);
|
||||
mbim_device_cancel_group(gd->device, GPRS_GROUP);
|
||||
mbim_device_unregister_group(gd->device, GPRS_GROUP);
|
||||
mbim_device_unref(gd->device);
|
||||
gd->device = NULL;
|
||||
l_free(gd);
|
||||
}
|
||||
|
||||
static struct ofono_gprs_driver driver = {
|
||||
.name = "mbim",
|
||||
.probe = mbim_gprs_probe,
|
||||
.remove = mbim_gprs_remove,
|
||||
.set_attached = mbim_gprs_set_attached,
|
||||
.attached_status = mbim_gprs_registration_status,
|
||||
};
|
||||
|
||||
void mbim_gprs_init(void)
|
||||
{
|
||||
ofono_gprs_driver_register(&driver);
|
||||
}
|
||||
|
||||
void mbim_gprs_exit(void)
|
||||
{
|
||||
ofono_gprs_driver_unregister(&driver);
|
||||
}
|
||||
80
ofono/drivers/mbimmodem/mbim-desc.c
Normal file
80
ofono/drivers/mbimmodem/mbim-desc.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "mbim-desc.h"
|
||||
|
||||
/*
|
||||
* Attempts to find MBIM specific descriptors.
|
||||
*
|
||||
* Returns true if the MBIM Function descriptor was found, false otherwise.
|
||||
*/
|
||||
bool mbim_find_descriptors(const uint8_t *data, size_t data_len,
|
||||
const struct mbim_desc **out_desc,
|
||||
const struct mbim_extended_desc **out_ext_desc)
|
||||
{
|
||||
bool r = false;
|
||||
|
||||
while (data_len > 3) {
|
||||
uint8_t len = data[0];
|
||||
|
||||
if (data[1] != 0x24)
|
||||
goto next;
|
||||
|
||||
/* MBIM v1.0, Table 4-3 */
|
||||
switch (data[2]) {
|
||||
case 0x1b:
|
||||
if (!out_desc)
|
||||
break;
|
||||
|
||||
if (len != sizeof(struct mbim_desc) || data_len < len)
|
||||
break;
|
||||
|
||||
*out_desc = (const struct mbim_desc *) data;
|
||||
r = true;
|
||||
break;
|
||||
case 0x1c:
|
||||
if (!out_ext_desc)
|
||||
break;
|
||||
|
||||
if (len != sizeof(struct mbim_extended_desc) ||
|
||||
data_len < len)
|
||||
break;
|
||||
|
||||
*out_ext_desc =
|
||||
(const struct mbim_extended_desc *) data;
|
||||
break;
|
||||
}
|
||||
|
||||
next:
|
||||
data_len -= len;
|
||||
data += len;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
49
ofono/drivers/mbimmodem/mbim-desc.h
Normal file
49
ofono/drivers/mbimmodem/mbim-desc.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/* MBIM v1.0, Section 6.4: MBIM Functional Descriptor */
|
||||
struct mbim_desc {
|
||||
uint8_t bFunctionLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubtype;
|
||||
__le16 bcdMBIMVersion;
|
||||
__le16 wMaxControlMessage;
|
||||
uint8_t bNumberFilters;
|
||||
uint8_t bMaxFilterSize;
|
||||
__le16 wMaxSegmentSize;
|
||||
uint8_t bmNetworkCapabilities;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* MBIM v1.0, Section 6.5: MBIM Extended Functional Descriptor */
|
||||
struct mbim_extended_desc {
|
||||
uint8_t bFunctionLength;
|
||||
uint8_t bDescriptorType;
|
||||
uint8_t bDescriptorSubtype;
|
||||
__le16 bcdMBIMExtendedVersion;
|
||||
uint8_t bMaxOutstandingCommandMessages;
|
||||
__le16 wMTU;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
bool mbim_find_descriptors(const uint8_t *data, size_t data_len,
|
||||
const struct mbim_desc **out_desc,
|
||||
const struct mbim_extended_desc **out_ext_desc);
|
||||
1738
ofono/drivers/mbimmodem/mbim-message.c
Normal file
1738
ofono/drivers/mbimmodem/mbim-message.c
Normal file
File diff suppressed because it is too large
Load Diff
96
ofono/drivers/mbimmodem/mbim-message.h
Normal file
96
ofono/drivers/mbimmodem/mbim-message.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
|
||||
struct mbim_message;
|
||||
struct mbim_message_iter;
|
||||
|
||||
enum mbim_command_type {
|
||||
MBIM_COMMAND_TYPE_QUERY = 0,
|
||||
MBIM_COMMAND_TYPE_SET = 1,
|
||||
};
|
||||
|
||||
struct mbim_message_iter {
|
||||
const char *sig_start;
|
||||
uint8_t sig_len;
|
||||
uint8_t sig_pos;
|
||||
const struct iovec *iov;
|
||||
uint32_t n_iov;
|
||||
uint32_t cur_iov;
|
||||
size_t cur_iov_offset;
|
||||
size_t len;
|
||||
size_t pos;
|
||||
size_t base_offset;
|
||||
uint32_t n_elem;
|
||||
char container_type;
|
||||
};
|
||||
|
||||
struct mbim_message *mbim_message_new(const uint8_t *uuid, uint32_t cid,
|
||||
enum mbim_command_type type);
|
||||
struct mbim_message *mbim_message_ref(struct mbim_message *msg);
|
||||
void mbim_message_unref(struct mbim_message *msg);
|
||||
|
||||
uint32_t mbim_message_get_error(struct mbim_message *message);
|
||||
uint32_t mbim_message_get_cid(struct mbim_message *message);
|
||||
const uint8_t *mbim_message_get_uuid(struct mbim_message *message);
|
||||
bool mbim_message_get_arguments(struct mbim_message *message,
|
||||
const char *signature, ...);
|
||||
|
||||
bool mbim_message_get_ipv4_address(struct mbim_message *message,
|
||||
uint32_t offset,
|
||||
struct in_addr *addr);
|
||||
bool mbim_message_get_ipv4_element(struct mbim_message *message,
|
||||
uint32_t offset,
|
||||
uint32_t *prefix_len,
|
||||
struct in_addr *addr);
|
||||
bool mbim_message_get_ipv6_address(struct mbim_message *essage,
|
||||
uint32_t offset,
|
||||
struct in6_addr *addr);
|
||||
bool mbim_message_get_ipv6_element(struct mbim_message *message,
|
||||
uint32_t offset,
|
||||
uint32_t *prefix_len,
|
||||
struct in6_addr *addr);
|
||||
|
||||
bool mbim_message_iter_next_entry(struct mbim_message_iter *iter, ...);
|
||||
|
||||
struct mbim_message_builder *mbim_message_builder_new(struct mbim_message *msg);
|
||||
void mbim_message_builder_free(struct mbim_message_builder *builder);
|
||||
bool mbim_message_builder_append_basic(struct mbim_message_builder *builder,
|
||||
char type, const void *value);
|
||||
bool mbim_message_builder_append_bytes(struct mbim_message_builder *builder,
|
||||
size_t len, const uint8_t *bytes);
|
||||
bool mbim_message_builder_enter_struct(struct mbim_message_builder *builder,
|
||||
const char *signature);
|
||||
bool mbim_message_builder_leave_struct(struct mbim_message_builder *builder);
|
||||
bool mbim_message_builder_enter_array(struct mbim_message_builder *builder,
|
||||
const char *signature);
|
||||
bool mbim_message_builder_leave_array(struct mbim_message_builder *builder);
|
||||
bool mbim_message_builder_enter_databuf(struct mbim_message_builder *builder,
|
||||
const char *signature);
|
||||
bool mbim_message_builder_leave_databuf(struct mbim_message_builder *builder);
|
||||
struct mbim_message *mbim_message_builder_finalize(
|
||||
struct mbim_message_builder *builder);
|
||||
|
||||
bool mbim_message_set_arguments(struct mbim_message *message,
|
||||
const char *signature, ...);
|
||||
59
ofono/drivers/mbimmodem/mbim-private.h
Normal file
59
ofono/drivers/mbimmodem/mbim-private.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#define align_len(len, boundary) (((len)+(boundary)-1) & ~((boundary)-1))
|
||||
|
||||
enum mbim_control_message {
|
||||
MBIM_OPEN_MSG = 0x1,
|
||||
MBIM_CLOSE_MSG = 0x2,
|
||||
MBIM_COMMAND_MSG = 0x3,
|
||||
MBIM_HOST_ERROR_MSG = 0x4,
|
||||
MBIM_OPEN_DONE = 0x80000001,
|
||||
MBIM_CLOSE_DONE = 0x80000002,
|
||||
MBIM_COMMAND_DONE = 0x80000003,
|
||||
MBIM_FUNCTION_ERROR_MSG = 0x80000004,
|
||||
MBIM_INDICATE_STATUS_MSG = 0x80000007,
|
||||
};
|
||||
|
||||
/* MBIM v1.0, Section 9.1 */
|
||||
struct mbim_message_header {
|
||||
__le32 type;
|
||||
__le32 len;
|
||||
__le32 tid;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
/* MBIM v1.0, Section 9.1 */
|
||||
struct mbim_fragment_header {
|
||||
__le32 num_frags;
|
||||
__le32 cur_frag;
|
||||
} __attribute__ ((packed));
|
||||
|
||||
struct mbim_message *_mbim_message_build(const void *header,
|
||||
struct iovec *frags,
|
||||
uint32_t n_frags);
|
||||
struct mbim_message *_mbim_message_new_command_done(const uint8_t *uuid,
|
||||
uint32_t cid, uint32_t status);
|
||||
uint32_t _mbim_information_buffer_offset(uint32_t type);
|
||||
void _mbim_message_set_tid(struct mbim_message *message, uint32_t tid);
|
||||
void *_mbim_message_to_bytearray(struct mbim_message *message, size_t *out_len);
|
||||
void *_mbim_message_get_header(struct mbim_message *message, size_t *out_len);
|
||||
struct iovec *_mbim_message_get_body(struct mbim_message *message,
|
||||
size_t *out_n_iov, size_t *out_len);
|
||||
1218
ofono/drivers/mbimmodem/mbim.c
Normal file
1218
ofono/drivers/mbimmodem/mbim.c
Normal file
File diff suppressed because it is too large
Load Diff
149
ofono/drivers/mbimmodem/mbim.h
Normal file
149
ofono/drivers/mbimmodem/mbim.h
Normal file
@@ -0,0 +1,149 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
struct mbim_device;
|
||||
struct mbim_message;
|
||||
|
||||
#define MBIM_CID_DEVICE_CAPS 1
|
||||
#define MBIM_CID_SUBSCRIBER_READY_STATUS 2
|
||||
#define MBIM_CID_RADIO_STATE 3
|
||||
#define MBIM_CID_PIN 4
|
||||
#define MBIM_CID_PIN_LIST 5
|
||||
#define MBIM_CID_HOME_PROVIDER 6
|
||||
#define MBIM_CID_PREFERRED_PROVIDERS 7
|
||||
#define MBIM_CID_VISIBLE_PROVIDERS 8
|
||||
#define MBIM_CID_REGISTER_STATE 9
|
||||
#define MBIM_CID_PACKET_SERVICE 10
|
||||
#define MBIM_CID_SIGNAL_STATE 11
|
||||
#define MBIM_CID_CONNECT 12
|
||||
#define MBIM_CID_PROVISIONED_CONTEXTS 13
|
||||
#define MBIM_CID_SERVICE_ACTIVATION 14
|
||||
#define MBIM_CID_IP_CONFIGURATION 15
|
||||
#define MBIM_CID_DEVICE_SERVICES 16
|
||||
#define MBIM_CID_DEVICE_SERVICE_SUBSCRIBE_LIST 19
|
||||
#define MBIM_CID_PACKET_STATISTICS 20
|
||||
#define MBIM_CID_NETWORK_IDLE_HINT 21
|
||||
#define MBIM_CID_EMERGENCY_MODE 22
|
||||
#define MBIM_CID_IP_PACKET_FILTERS 23
|
||||
#define MBIM_CID_MULTICARRIER_PROVIDERS 24
|
||||
|
||||
#define MBIM_CID_SMS_CONFIGURATION 1
|
||||
#define MBIM_CID_SMS_READ 2
|
||||
#define MBIM_CID_SMS_SEND 3
|
||||
#define MBIM_CID_SMS_DELETE 4
|
||||
#define MBIM_CID_SMS_MESSAGE_STORE_STATUS 5
|
||||
|
||||
#define MBIM_CID_USSD 1
|
||||
|
||||
#define MBIM_CID_PHONEBOOK_CONFIGURATION 1
|
||||
#define MBIM_CID_PHONEBOOK_READ 2
|
||||
#define MBIM_CID_PHONEBOOK_DELETE 3
|
||||
#define MBIM_CID_PHONEBOOK_WRITE 4
|
||||
|
||||
#define MBIM_CID_STK_PAC 1
|
||||
#define MBIM_CID_STK_TERMINAL_RESPONSE 2
|
||||
#define MBIM_CID_STK_ENVELOPE 3
|
||||
|
||||
#define MBIM_CID_AKA_AUTH 1
|
||||
#define MBIM_CID_AKAP_AUTH 2
|
||||
#define MBIM_CID_SIM_AUTH 3
|
||||
|
||||
#define MBIM_CID_DSS_CONNECT 1
|
||||
|
||||
/* Table 10-11 */
|
||||
enum mbim_data_class {
|
||||
MBIM_DATA_CLASS_NONE = 0x00,
|
||||
MBIM_DATA_CLASS_GPRS = 0x01,
|
||||
MBIM_DATA_CLASS_EDGE = 0x02,
|
||||
MBIM_DATA_CLASS_UMTS = 0x04,
|
||||
MBIM_DATA_CLASS_HSDPA = 0x08,
|
||||
MBIM_DATA_CLASS_HSUPA = 0x10,
|
||||
MBIM_DATA_CLASS_LTE = 0x20,
|
||||
MBIM_DATA_CLASS_1XRTT = 0x10000,
|
||||
MBIM_DATA_CLASS_EVDO = 0x20000,
|
||||
MBIM_DATA_CLASS_EVDO_REVA = 0x40000,
|
||||
MBIM_DATA_CLASS_1XEVDV = 0x80000,
|
||||
MBIM_DATA_CLASS_3XRTT = 0x100000,
|
||||
MBIM_DATA_CLASS_1XEVDO_REVB = 0x200000,
|
||||
MBIM_DATA_CLASS_UMB = 0x400000,
|
||||
MBIM_DATA_CLASS_CUSTOM = 0x80000000,
|
||||
};
|
||||
|
||||
typedef void (*mbim_device_debug_func_t) (const char *str, void *user_data);
|
||||
typedef void (*mbim_device_disconnect_func_t) (void *user_data);
|
||||
typedef void (*mbim_device_destroy_func_t) (void *user_data);
|
||||
typedef void (*mbim_device_ready_func_t) (void *user_data);
|
||||
typedef void (*mbim_device_reply_func_t) (struct mbim_message *message,
|
||||
void *user_data);
|
||||
|
||||
extern const uint8_t mbim_uuid_basic_connect[];
|
||||
extern const uint8_t mbim_uuid_sms[];
|
||||
extern const uint8_t mbim_uuid_ussd[];
|
||||
extern const uint8_t mbim_uuid_phonebook[];
|
||||
extern const uint8_t mbim_uuid_stk[];
|
||||
extern const uint8_t mbim_uuid_auth[];
|
||||
extern const uint8_t mbim_uuid_dss[];
|
||||
|
||||
extern const uint8_t mbim_context_type_none[];
|
||||
extern const uint8_t mbim_context_type_internet[];
|
||||
extern const uint8_t mbim_context_type_vpn[];
|
||||
extern const uint8_t mbim_context_type_voice[];
|
||||
extern const uint8_t mbim_context_type_video_share[];
|
||||
extern const uint8_t mbim_context_type_purchase[];
|
||||
extern const uint8_t mbim_context_type_ims[];
|
||||
extern const uint8_t mbim_context_type_mms[];
|
||||
extern const uint8_t mbim_context_type_local[];
|
||||
|
||||
struct mbim_device *mbim_device_new(int fd, uint32_t max_segment_size);
|
||||
bool mbim_device_set_close_on_unref(struct mbim_device *device, bool do_close);
|
||||
struct mbim_device *mbim_device_ref(struct mbim_device *device);
|
||||
void mbim_device_unref(struct mbim_device *device);
|
||||
bool mbim_device_shutdown(struct mbim_device *device);
|
||||
|
||||
bool mbim_device_set_max_outstanding(struct mbim_device *device, uint32_t max);
|
||||
|
||||
bool mbim_device_set_debug(struct mbim_device *device,
|
||||
mbim_device_debug_func_t func, void *user_data,
|
||||
mbim_device_destroy_func_t destroy);
|
||||
bool mbim_device_set_disconnect_handler(struct mbim_device *device,
|
||||
mbim_device_disconnect_func_t function,
|
||||
void *user_data,
|
||||
mbim_device_destroy_func_t destroy);
|
||||
bool mbim_device_set_ready_handler(struct mbim_device *device,
|
||||
mbim_device_ready_func_t function,
|
||||
void *user_data,
|
||||
mbim_device_destroy_func_t destroy);
|
||||
|
||||
uint32_t mbim_device_send(struct mbim_device *device, uint32_t gid,
|
||||
struct mbim_message *message,
|
||||
mbim_device_reply_func_t function,
|
||||
void *user_data,
|
||||
mbim_device_destroy_func_t destroy);
|
||||
bool mbim_device_cancel(struct mbim_device *device, uint32_t tid);
|
||||
bool mbim_device_cancel_group(struct mbim_device *device, uint32_t gid);
|
||||
|
||||
uint32_t mbim_device_register(struct mbim_device *device, uint32_t gid,
|
||||
const uint8_t *uuid, uint32_t cid,
|
||||
mbim_device_reply_func_t notify,
|
||||
void *user_data,
|
||||
mbim_device_destroy_func_t destroy);
|
||||
bool mbim_device_unregister(struct mbim_device *device, uint32_t id);
|
||||
bool mbim_device_unregister_group(struct mbim_device *device, uint32_t gid);
|
||||
53
ofono/drivers/mbimmodem/mbimmodem.c
Normal file
53
ofono/drivers/mbimmodem/mbimmodem.c
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define OFONO_API_SUBJECT_TO_CHANGE
|
||||
#include <ofono/plugin.h>
|
||||
|
||||
#include "mbimmodem.h"
|
||||
|
||||
static int mbimmodem_init(void)
|
||||
{
|
||||
mbim_devinfo_init();
|
||||
mbim_sim_init();
|
||||
mbim_netreg_init();
|
||||
mbim_sms_exit();
|
||||
mbim_gprs_init();
|
||||
mbim_gprs_context_init();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mbimmodem_exit(void)
|
||||
{
|
||||
mbim_gprs_context_exit();
|
||||
mbim_gprs_exit();
|
||||
mbim_sms_exit();
|
||||
mbim_netreg_exit();
|
||||
mbim_sim_exit();
|
||||
mbim_devinfo_exit();
|
||||
}
|
||||
|
||||
OFONO_PLUGIN_DEFINE(mbimmodem, "MBIM modem driver", VERSION,
|
||||
OFONO_PLUGIN_PRIORITY_DEFAULT, mbimmodem_init, mbimmodem_exit)
|
||||
48
ofono/drivers/mbimmodem/mbimmodem.h
Normal file
48
ofono/drivers/mbimmodem/mbimmodem.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include "util.h"
|
||||
|
||||
enum MBIM_GROUP {
|
||||
SIM_GROUP = 1,
|
||||
NETREG_GROUP = 2,
|
||||
SMS_GROUP = 3,
|
||||
GPRS_GROUP = 4,
|
||||
GPRS_CONTEXT_GROUP = 101,
|
||||
};
|
||||
|
||||
extern void mbim_devinfo_init(void);
|
||||
extern void mbim_devinfo_exit(void);
|
||||
|
||||
extern void mbim_sim_init(void);
|
||||
extern void mbim_sim_exit(void);
|
||||
|
||||
extern void mbim_netreg_init(void);
|
||||
extern void mbim_netreg_exit(void);
|
||||
|
||||
extern void mbim_sms_init(void);
|
||||
extern void mbim_sms_exit(void);
|
||||
|
||||
extern void mbim_gprs_init(void);
|
||||
extern void mbim_gprs_exit(void);
|
||||
|
||||
extern void mbim_gprs_context_init(void);
|
||||
extern void mbim_gprs_context_exit(void);
|
||||
416
ofono/drivers/mbimmodem/network-registration.c
Normal file
416
ofono/drivers/mbimmodem/network-registration.c
Normal file
@@ -0,0 +1,416 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/netreg.h>
|
||||
|
||||
#include "src/common.h"
|
||||
|
||||
#include "drivers/mbimmodem/mbim.h"
|
||||
#include "drivers/mbimmodem/mbim-message.h"
|
||||
#include "drivers/mbimmodem/mbimmodem.h"
|
||||
|
||||
struct netreg_data {
|
||||
struct mbim_device *device;
|
||||
struct l_idle *delayed_register;
|
||||
};
|
||||
|
||||
static inline int register_state_to_status(uint32_t register_state)
|
||||
{
|
||||
switch (register_state) {
|
||||
case 0: /* MBIMRegisterStateUnknown */
|
||||
return NETWORK_REGISTRATION_STATUS_UNKNOWN;
|
||||
case 1: /* MBIMRegisterStateDeregistered */
|
||||
return NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
|
||||
case 2: /* MBIMRegisterStateSearching */
|
||||
return NETWORK_REGISTRATION_STATUS_SEARCHING;
|
||||
case 3: /* MBIMRegisterStateHome */
|
||||
return NETWORK_REGISTRATION_STATUS_REGISTERED;
|
||||
case 4: /* MBIMRegisterStateRoaming */
|
||||
case 5: /* MBIMRegisterStatePartner */
|
||||
return NETWORK_REGISTRATION_STATUS_ROAMING;
|
||||
case 6: /* MBIMRegisterStateDenied */
|
||||
return NETWORK_REGISTRATION_STATUS_DENIED;
|
||||
}
|
||||
|
||||
return NETWORK_REGISTRATION_STATUS_UNKNOWN;
|
||||
}
|
||||
|
||||
static void mbim_register_state_changed(struct mbim_message *message,
|
||||
void *user)
|
||||
{
|
||||
struct ofono_netreg *netreg = user;
|
||||
uint32_t nw_error;
|
||||
uint32_t register_state;
|
||||
uint32_t register_mode;
|
||||
uint32_t available_data_classes;
|
||||
int status;
|
||||
int tech;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (!mbim_message_get_arguments(message, "uuuu",
|
||||
&nw_error, ®ister_state,
|
||||
®ister_mode,
|
||||
&available_data_classes))
|
||||
return;
|
||||
|
||||
DBG("NwError: %u, RegisterMode: %u", nw_error, register_mode);
|
||||
|
||||
status = register_state_to_status(register_state);
|
||||
tech = mbim_data_class_to_tech(available_data_classes);
|
||||
|
||||
ofono_netreg_status_notify(netreg, status, -1, -1, tech);
|
||||
}
|
||||
|
||||
static void mbim_registration_status_cb(struct mbim_message *message,
|
||||
void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
ofono_netreg_status_cb_t cb = cbd->cb;
|
||||
uint32_t dummy;
|
||||
uint32_t register_state;
|
||||
uint32_t available_data_classes;
|
||||
int status;
|
||||
int tech;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
goto error;
|
||||
|
||||
if (!mbim_message_get_arguments(message, "uuuu",
|
||||
&dummy, ®ister_state,
|
||||
&dummy,
|
||||
&available_data_classes))
|
||||
goto error;
|
||||
|
||||
status = register_state_to_status(register_state);
|
||||
tech = mbim_data_class_to_tech(available_data_classes);
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, status, -1, -1, tech, cbd->data);
|
||||
return;
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, -1, -1, -1, -1, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_registration_status(struct ofono_netreg *netreg,
|
||||
ofono_netreg_status_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct netreg_data *nd = ofono_netreg_get_data(netreg);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct mbim_message *message;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_REGISTER_STATE,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
mbim_message_set_arguments(message, "");
|
||||
|
||||
if (mbim_device_send(nd->device, NETREG_GROUP, message,
|
||||
mbim_registration_status_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, -1, -1, -1, -1, data);
|
||||
}
|
||||
|
||||
static void mbim_current_operator_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
ofono_netreg_operator_cb_t cb = cbd->cb;
|
||||
struct ofono_network_operator op;
|
||||
uint32_t dummy;
|
||||
uint32_t register_state;
|
||||
uint32_t available_data_classes;
|
||||
L_AUTO_FREE_VAR(char *, provider_id) = NULL;
|
||||
L_AUTO_FREE_VAR(char *, provider_name) = NULL;
|
||||
L_AUTO_FREE_VAR(char *, roaming_text) = NULL;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
goto error;
|
||||
|
||||
if (!mbim_message_get_arguments(message, "uuuuusss",
|
||||
&dummy, ®ister_state, &dummy,
|
||||
&available_data_classes, &dummy,
|
||||
&provider_id, &provider_name,
|
||||
&roaming_text))
|
||||
goto error;
|
||||
|
||||
if (register_state < 3 || register_state > 5)
|
||||
goto error;
|
||||
|
||||
DBG("provider: %s(%s)", provider_name, provider_id);
|
||||
|
||||
/* If MBIMRegisterStateRoaming or MBIMRegisterStatePartner */
|
||||
if (register_state == 4 || register_state == 5)
|
||||
DBG("roaming text: %s", roaming_text);
|
||||
|
||||
strncpy(op.name, provider_name, OFONO_MAX_OPERATOR_NAME_LENGTH);
|
||||
op.name[OFONO_MAX_OPERATOR_NAME_LENGTH] = '\0';
|
||||
|
||||
strncpy(op.mcc, provider_id, OFONO_MAX_MCC_LENGTH);
|
||||
op.mcc[OFONO_MAX_MCC_LENGTH] = '\0';
|
||||
|
||||
strncpy(op.mnc, provider_id + OFONO_MAX_MCC_LENGTH,
|
||||
OFONO_MAX_MNC_LENGTH);
|
||||
op.mnc[OFONO_MAX_MNC_LENGTH] = '\0';
|
||||
|
||||
/* Set to current */
|
||||
op.status = 2;
|
||||
op.tech = mbim_data_class_to_tech(available_data_classes);
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, &op, cbd->data);
|
||||
return;
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_current_operator(struct ofono_netreg *netreg,
|
||||
ofono_netreg_operator_cb_t cb, void *data)
|
||||
{
|
||||
struct netreg_data *nd = ofono_netreg_get_data(netreg);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct mbim_message *message;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_REGISTER_STATE,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
mbim_message_set_arguments(message, "");
|
||||
|
||||
if (mbim_device_send(nd->device, NETREG_GROUP, message,
|
||||
mbim_current_operator_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, data);
|
||||
}
|
||||
|
||||
static void mbim_register_state_set_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
ofono_netreg_register_cb_t cb = cbd->cb;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
else
|
||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_register_auto(struct ofono_netreg *netreg,
|
||||
ofono_netreg_register_cb_t cb, void *data)
|
||||
{
|
||||
static const uint32_t data_class = MBIM_DATA_CLASS_GPRS |
|
||||
MBIM_DATA_CLASS_EDGE |
|
||||
MBIM_DATA_CLASS_UMTS |
|
||||
MBIM_DATA_CLASS_HSDPA |
|
||||
MBIM_DATA_CLASS_HSUPA |
|
||||
MBIM_DATA_CLASS_LTE;
|
||||
struct netreg_data *nd = ofono_netreg_get_data(netreg);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct mbim_message *message;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_REGISTER_STATE,
|
||||
MBIM_COMMAND_TYPE_SET);
|
||||
mbim_message_set_arguments(message, "suu", NULL, 0, data_class);
|
||||
|
||||
if (mbim_device_send(nd->device, NETREG_GROUP, message,
|
||||
mbim_register_state_set_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
}
|
||||
|
||||
static inline int convert_signal_strength(uint32_t strength)
|
||||
{
|
||||
if (strength == 99)
|
||||
return -1;
|
||||
|
||||
return strength * 100 / 31;
|
||||
}
|
||||
|
||||
static void mbim_signal_state_query_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
ofono_netreg_strength_cb_t cb = cbd->cb;
|
||||
uint32_t strength;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
goto error;
|
||||
|
||||
if (!mbim_message_get_arguments(message, "u", &strength))
|
||||
goto error;
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, convert_signal_strength(strength), cbd->data);
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_signal_strength(struct ofono_netreg *netreg,
|
||||
ofono_netreg_strength_cb_t cb, void *data)
|
||||
{
|
||||
struct netreg_data *nd = ofono_netreg_get_data(netreg);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct mbim_message *message;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_SIGNAL_STATE,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
mbim_message_set_arguments(message, "");
|
||||
|
||||
if (mbim_device_send(nd->device, NETREG_GROUP, message,
|
||||
mbim_signal_state_query_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, -1, data);
|
||||
}
|
||||
|
||||
static void mbim_signal_state_changed(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct ofono_netreg *netreg = user;
|
||||
uint32_t strength;
|
||||
uint32_t error_rate;
|
||||
uint32_t signal_strength_interval;
|
||||
uint32_t rssi_threshold;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (!mbim_message_get_arguments(message, "uuuu",
|
||||
&strength, &error_rate,
|
||||
&signal_strength_interval,
|
||||
&rssi_threshold))
|
||||
return;
|
||||
|
||||
DBG("strength: %u, error_rate: %u", strength, error_rate);
|
||||
DBG("strength interval: %u, rssi_threshold: %u",
|
||||
signal_strength_interval, rssi_threshold);
|
||||
|
||||
ofono_netreg_strength_notify(netreg, convert_signal_strength(strength));
|
||||
}
|
||||
|
||||
static void delayed_register(struct l_idle *idle, void *user_data)
|
||||
{
|
||||
struct ofono_netreg *netreg = user_data;
|
||||
struct netreg_data *nd = ofono_netreg_get_data(netreg);
|
||||
|
||||
DBG("");
|
||||
|
||||
l_idle_remove(idle);
|
||||
nd->delayed_register = NULL;
|
||||
|
||||
if (!mbim_device_register(nd->device, NETREG_GROUP,
|
||||
mbim_uuid_basic_connect,
|
||||
MBIM_CID_SIGNAL_STATE,
|
||||
mbim_signal_state_changed,
|
||||
netreg, NULL))
|
||||
goto error;
|
||||
|
||||
if (!mbim_device_register(nd->device, NETREG_GROUP,
|
||||
mbim_uuid_basic_connect,
|
||||
MBIM_CID_REGISTER_STATE,
|
||||
mbim_register_state_changed,
|
||||
netreg, NULL))
|
||||
goto error;
|
||||
|
||||
ofono_netreg_register(netreg);
|
||||
return;
|
||||
|
||||
error:
|
||||
ofono_netreg_remove(netreg);
|
||||
}
|
||||
|
||||
static int mbim_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct mbim_device *device = data;
|
||||
struct netreg_data *nd = l_new(struct netreg_data, 1);
|
||||
|
||||
DBG("");
|
||||
|
||||
nd->device = mbim_device_ref(device);
|
||||
nd->delayed_register = l_idle_create(delayed_register, netreg, NULL);
|
||||
|
||||
ofono_netreg_set_data(netreg, nd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mbim_netreg_remove(struct ofono_netreg *netreg)
|
||||
{
|
||||
struct netreg_data *nd = ofono_netreg_get_data(netreg);
|
||||
|
||||
DBG("");
|
||||
|
||||
ofono_netreg_set_data(netreg, NULL);
|
||||
|
||||
l_idle_remove(nd->delayed_register);
|
||||
mbim_device_cancel_group(nd->device, NETREG_GROUP);
|
||||
mbim_device_unregister_group(nd->device, NETREG_GROUP);
|
||||
mbim_device_unref(nd->device);
|
||||
nd->device = NULL;
|
||||
l_free(nd);
|
||||
}
|
||||
|
||||
static struct ofono_netreg_driver driver = {
|
||||
.name = "mbim",
|
||||
.probe = mbim_netreg_probe,
|
||||
.remove = mbim_netreg_remove,
|
||||
.registration_status = mbim_registration_status,
|
||||
.current_operator = mbim_current_operator,
|
||||
.register_auto = mbim_register_auto,
|
||||
.strength = mbim_signal_strength,
|
||||
};
|
||||
|
||||
void mbim_netreg_init(void)
|
||||
{
|
||||
ofono_netreg_driver_register(&driver);
|
||||
}
|
||||
|
||||
void mbim_netreg_exit(void)
|
||||
{
|
||||
ofono_netreg_driver_unregister(&driver);
|
||||
}
|
||||
533
ofono/drivers/mbimmodem/sim.c
Normal file
533
ofono/drivers/mbimmodem/sim.c
Normal file
@@ -0,0 +1,533 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/sim.h>
|
||||
|
||||
#include "drivers/mbimmodem/mbim.h"
|
||||
#include "drivers/mbimmodem/mbim-message.h"
|
||||
#include "drivers/mbimmodem/mbimmodem.h"
|
||||
|
||||
struct sim_data {
|
||||
struct mbim_device *device;
|
||||
char *iccid;
|
||||
char *imsi;
|
||||
uint32_t last_pin_type;
|
||||
bool present : 1;
|
||||
};
|
||||
|
||||
static void mbim_sim_state_changed(struct ofono_sim *sim, uint32_t ready_state)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
|
||||
DBG("ready_state: %u", ready_state);
|
||||
|
||||
switch (ready_state) {
|
||||
case 0: /* Not Initialized */
|
||||
break;
|
||||
case 1: /* Initialized */
|
||||
if (!sd->present)
|
||||
ofono_sim_inserted_notify(sim, true);
|
||||
|
||||
sd->present = true;
|
||||
ofono_sim_initialized_notify(sim);
|
||||
break;
|
||||
case 6: /* Device Locked */
|
||||
if (!sd->present)
|
||||
ofono_sim_inserted_notify(sim, true);
|
||||
|
||||
sd->present = true;
|
||||
break;
|
||||
case 2: /* Not inserted */
|
||||
case 3: /* Bad SIM */
|
||||
case 4: /* Failure */
|
||||
case 5: /* Not activated */
|
||||
if (sd->present)
|
||||
ofono_sim_inserted_notify(sim, false);
|
||||
|
||||
sd->present = false;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
};
|
||||
}
|
||||
|
||||
static void mbim_read_imsi(struct ofono_sim *sim,
|
||||
ofono_sim_imsi_cb_t cb, void *user_data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
|
||||
DBG("");
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, sd->imsi, user_data);
|
||||
}
|
||||
|
||||
static enum ofono_sim_password_type mbim_pin_type_to_sim_password(
|
||||
uint32_t pin_type)
|
||||
{
|
||||
switch (pin_type) {
|
||||
case 0: /* No Pin */
|
||||
return OFONO_SIM_PASSWORD_NONE;
|
||||
case 2: /* PIN1 key */
|
||||
return OFONO_SIM_PASSWORD_SIM_PIN;
|
||||
case 3: /* PIN2 key */
|
||||
return OFONO_SIM_PASSWORD_SIM_PIN2;
|
||||
case 4: /* device to SIM key */
|
||||
return OFONO_SIM_PASSWORD_PHSIM_PIN;
|
||||
case 5: /* device to very first SIM key */
|
||||
return OFONO_SIM_PASSWORD_PHFSIM_PIN;
|
||||
case 6: /* network personalization key */
|
||||
return OFONO_SIM_PASSWORD_PHNET_PIN;
|
||||
case 7: /* network subset personalization key */
|
||||
return OFONO_SIM_PASSWORD_PHNETSUB_PIN;
|
||||
case 8: /* service provider (SP) personalization key */
|
||||
return OFONO_SIM_PASSWORD_PHSP_PIN;
|
||||
case 9: /* corporate personalization key */
|
||||
return OFONO_SIM_PASSWORD_PHCORP_PIN;
|
||||
case 11: /* PUK1 */
|
||||
return OFONO_SIM_PASSWORD_SIM_PUK;
|
||||
case 12: /* PUK2 */
|
||||
return OFONO_SIM_PASSWORD_SIM_PUK2;
|
||||
case 13: /* device to very first SIM PIN unlock key */
|
||||
return OFONO_SIM_PASSWORD_PHFSIM_PUK;
|
||||
case 14: /* network personalization unlock key */
|
||||
return OFONO_SIM_PASSWORD_PHNET_PUK;
|
||||
case 15: /* network subset personaliation unlock key */
|
||||
return OFONO_SIM_PASSWORD_PHNETSUB_PUK;
|
||||
case 16: /* service provider (SP) personalization unlock key */
|
||||
return OFONO_SIM_PASSWORD_PHSP_PUK;
|
||||
case 17: /* corporate personalization unlock key */
|
||||
return OFONO_SIM_PASSWORD_PHCORP_PUK;
|
||||
}
|
||||
|
||||
return OFONO_SIM_PASSWORD_INVALID;
|
||||
}
|
||||
|
||||
static uint32_t mbim_pin_type_from_sim_password(
|
||||
enum ofono_sim_password_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case OFONO_SIM_PASSWORD_SIM_PIN:
|
||||
return 2; /* PIN1 key */
|
||||
case OFONO_SIM_PASSWORD_SIM_PIN2:
|
||||
return 3; /* PIN2 key */
|
||||
case OFONO_SIM_PASSWORD_PHSIM_PIN:
|
||||
return 4; /* device to SIM key */
|
||||
case OFONO_SIM_PASSWORD_PHFSIM_PIN:
|
||||
return 5; /* device to very first SIM key */
|
||||
case OFONO_SIM_PASSWORD_PHNET_PIN:
|
||||
return 6; /* network personalization key */
|
||||
case OFONO_SIM_PASSWORD_PHNETSUB_PIN:
|
||||
return 7; /* network subset personalization key */
|
||||
case OFONO_SIM_PASSWORD_PHSP_PIN:
|
||||
return 8; /* service provider (SP) personalization key */
|
||||
case OFONO_SIM_PASSWORD_PHCORP_PIN:
|
||||
return 9; /* corporate personalization key */
|
||||
case OFONO_SIM_PASSWORD_SIM_PUK:
|
||||
return 11; /* PUK1 */
|
||||
case OFONO_SIM_PASSWORD_SIM_PUK2:
|
||||
return 12; /* PUK2 */
|
||||
case OFONO_SIM_PASSWORD_PHFSIM_PUK:
|
||||
return 13; /* device to very first SIM PIN unlock key */
|
||||
case OFONO_SIM_PASSWORD_PHNET_PUK:
|
||||
return 14; /* network personalization unlock key */
|
||||
case OFONO_SIM_PASSWORD_PHNETSUB_PUK:
|
||||
return 15; /* network subset personaliation unlock key */
|
||||
case OFONO_SIM_PASSWORD_PHSP_PUK:
|
||||
return 16; /* service provider (SP) personalization unlock key */
|
||||
case OFONO_SIM_PASSWORD_PHCORP_PUK:
|
||||
return 17; /* corporate personalization unlock key */
|
||||
case OFONO_SIM_PASSWORD_NONE:
|
||||
case OFONO_SIM_PASSWORD_INVALID:
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mbim_pin_query_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
struct sim_data *sd = cbd->user;
|
||||
ofono_sim_passwd_cb_t cb = cbd->cb;
|
||||
uint32_t pin_type;
|
||||
uint32_t pin_state;
|
||||
enum ofono_sim_password_type sim_password;
|
||||
bool r;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
goto error;
|
||||
|
||||
r = mbim_message_get_arguments(message, "uu",
|
||||
&pin_type, &pin_state);
|
||||
if (!r)
|
||||
goto error;
|
||||
|
||||
sim_password = mbim_pin_type_to_sim_password(pin_type);
|
||||
if (sim_password == OFONO_SIM_PASSWORD_INVALID)
|
||||
goto error;
|
||||
|
||||
if (pin_state == 0)
|
||||
sim_password = OFONO_SIM_PASSWORD_NONE;
|
||||
|
||||
sd->last_pin_type = pin_type;
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, sim_password, cbd->data);
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_pin_query(struct ofono_sim *sim,
|
||||
ofono_sim_passwd_cb_t cb, void *user_data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct cb_data *cbd = cb_data_new(cb, user_data);
|
||||
struct mbim_message *message;
|
||||
|
||||
DBG("");
|
||||
|
||||
cbd->user = sd;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_PIN,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
mbim_message_set_arguments(message, "");
|
||||
|
||||
if (mbim_device_send(sd->device, SIM_GROUP, message,
|
||||
mbim_pin_query_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, -1, user_data);
|
||||
}
|
||||
|
||||
static void mbim_pin_retries_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
ofono_sim_pin_retries_cb_t cb = cbd->cb;
|
||||
int retries[OFONO_SIM_PASSWORD_INVALID];
|
||||
size_t i;
|
||||
uint32_t pin_type;
|
||||
uint32_t pin_state;
|
||||
uint32_t remaining;
|
||||
enum ofono_sim_password_type sim_password;
|
||||
bool r;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
goto error;
|
||||
|
||||
r = mbim_message_get_arguments(message, "uuu",
|
||||
&pin_type, &pin_state, &remaining);
|
||||
if (!r)
|
||||
goto error;
|
||||
|
||||
sim_password = mbim_pin_type_to_sim_password(pin_type);
|
||||
if (sim_password == OFONO_SIM_PASSWORD_INVALID)
|
||||
goto error;
|
||||
|
||||
for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
|
||||
retries[i] = -1;
|
||||
|
||||
if (pin_state == 0 || sim_password == OFONO_SIM_PASSWORD_NONE) {
|
||||
CALLBACK_WITH_SUCCESS(cb, retries, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
if (remaining == 0xffffffff)
|
||||
retries[sim_password] = -1;
|
||||
else
|
||||
retries[sim_password] = remaining;
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, retries, cbd->data);
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_pin_retries_query(struct ofono_sim *sim,
|
||||
ofono_sim_pin_retries_cb_t cb, void *user_data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct cb_data *cbd = cb_data_new(cb, user_data);
|
||||
struct mbim_message *message;
|
||||
|
||||
DBG("");
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_PIN,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
mbim_message_set_arguments(message, "");
|
||||
|
||||
if (mbim_device_send(sd->device, SIM_GROUP, message,
|
||||
mbim_pin_retries_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, user_data);
|
||||
}
|
||||
|
||||
static void mbim_pin_set_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
ofono_sim_lock_unlock_cb_t cb = cbd->cb;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
else
|
||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_pin_set(struct ofono_sim *sim, uint32_t pin_type,
|
||||
uint32_t pin_operation,
|
||||
const char *old_passwd,
|
||||
const char *new_passwd,
|
||||
ofono_sim_lock_unlock_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct mbim_message *message;
|
||||
|
||||
DBG("%u %u %s %s", pin_type, pin_operation, old_passwd, new_passwd);
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_PIN,
|
||||
MBIM_COMMAND_TYPE_SET);
|
||||
mbim_message_set_arguments(message, "uuss", pin_type, pin_operation,
|
||||
old_passwd, new_passwd);
|
||||
|
||||
if (mbim_device_send(sd->device, SIM_GROUP, message,
|
||||
mbim_pin_set_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
}
|
||||
|
||||
static void mbim_pin_enter(struct ofono_sim *sim, const char *passwd,
|
||||
ofono_sim_lock_unlock_cb_t cb, void *data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
|
||||
/* Use MBIMPinOperationEnter (0) and NULL second PIN */
|
||||
mbim_pin_set(sim, sd->last_pin_type, 0, passwd, NULL, cb, data);
|
||||
}
|
||||
|
||||
static void mbim_puk_enter(struct ofono_sim *sim, const char *puk,
|
||||
const char *passwd,
|
||||
ofono_sim_lock_unlock_cb_t cb, void *data)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
|
||||
/* Use MBIMPinOperationEnter (0) and second PIN */
|
||||
mbim_pin_set(sim, sd->last_pin_type, 0, puk, passwd, cb, data);
|
||||
}
|
||||
|
||||
static void mbim_pin_enable(struct ofono_sim *sim,
|
||||
enum ofono_sim_password_type passwd_type,
|
||||
int enable, const char *passwd,
|
||||
ofono_sim_lock_unlock_cb_t cb, void *data)
|
||||
{
|
||||
uint32_t pin_type = mbim_pin_type_from_sim_password(passwd_type);
|
||||
|
||||
if (pin_type == 0) {
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Use MBIMPinOperationEnable (1) or MBIMPinOperationDisable (2) */
|
||||
mbim_pin_set(sim, pin_type, enable ? 1 : 2, passwd, NULL, cb, data);
|
||||
}
|
||||
|
||||
static void mbim_pin_change(struct ofono_sim *sim,
|
||||
enum ofono_sim_password_type passwd_type,
|
||||
const char *old_passwd, const char *new_passwd,
|
||||
ofono_sim_lock_unlock_cb_t cb, void *data)
|
||||
{
|
||||
uint32_t pin_type = mbim_pin_type_from_sim_password(passwd_type);
|
||||
|
||||
if (pin_type == 0) {
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Use MBIMPinOperationChange (3) */
|
||||
mbim_pin_set(sim, pin_type, 3, old_passwd, new_passwd, cb, data);
|
||||
}
|
||||
|
||||
static void mbim_subscriber_ready_status_changed(struct mbim_message *message,
|
||||
void *user)
|
||||
{
|
||||
struct ofono_sim *sim = user;
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
uint32_t ready_state;
|
||||
char *imsi;
|
||||
char *iccid;
|
||||
uint32_t ready_info;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (!mbim_message_get_arguments(message, "ussu",
|
||||
&ready_state, &imsi,
|
||||
&iccid, &ready_info))
|
||||
return;
|
||||
|
||||
l_free(sd->iccid);
|
||||
sd->iccid = iccid;
|
||||
|
||||
l_free(sd->imsi);
|
||||
sd->imsi = imsi;
|
||||
|
||||
DBG("%s %s", iccid, imsi);
|
||||
|
||||
mbim_sim_state_changed(sim, ready_state);
|
||||
}
|
||||
|
||||
static void mbim_subscriber_ready_status_cb(struct mbim_message *message,
|
||||
void *user)
|
||||
{
|
||||
struct ofono_sim *sim = user;
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
uint32_t ready_state;
|
||||
char *imsi;
|
||||
char *iccid;
|
||||
uint32_t ready_info;
|
||||
bool r;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
goto error;
|
||||
|
||||
/* We don't bother parsing MSISDN/MDN array */
|
||||
r = mbim_message_get_arguments(message, "ussu",
|
||||
&ready_state, &imsi,
|
||||
&iccid, &ready_info);
|
||||
if (!r)
|
||||
goto error;
|
||||
|
||||
sd->iccid = iccid;
|
||||
sd->imsi = imsi;
|
||||
|
||||
if (!mbim_device_register(sd->device, SIM_GROUP,
|
||||
mbim_uuid_basic_connect,
|
||||
MBIM_CID_SUBSCRIBER_READY_STATUS,
|
||||
mbim_subscriber_ready_status_changed,
|
||||
sim, NULL))
|
||||
goto error;
|
||||
|
||||
ofono_sim_register(sim);
|
||||
DBG("%s %s", iccid, imsi);
|
||||
mbim_sim_state_changed(sim, ready_state);
|
||||
return;
|
||||
|
||||
error:
|
||||
ofono_sim_remove(sim);
|
||||
}
|
||||
|
||||
static int mbim_sim_probe(struct ofono_sim *sim, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct mbim_device *device = data;
|
||||
struct mbim_message *message;
|
||||
struct sim_data *sd;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_basic_connect,
|
||||
MBIM_CID_SUBSCRIBER_READY_STATUS,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
if (!message)
|
||||
return -ENOMEM;
|
||||
|
||||
mbim_message_set_arguments(message, "");
|
||||
|
||||
if (!mbim_device_send(device, SIM_GROUP, message,
|
||||
mbim_subscriber_ready_status_cb, sim, NULL)) {
|
||||
mbim_message_unref(message);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
sd = l_new(struct sim_data, 1);
|
||||
sd->device = mbim_device_ref(device);
|
||||
ofono_sim_set_data(sim, sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mbim_sim_remove(struct ofono_sim *sim)
|
||||
{
|
||||
struct sim_data *sd = ofono_sim_get_data(sim);
|
||||
|
||||
ofono_sim_set_data(sim, NULL);
|
||||
|
||||
mbim_device_cancel_group(sd->device, SIM_GROUP);
|
||||
mbim_device_unregister_group(sd->device, SIM_GROUP);
|
||||
mbim_device_unref(sd->device);
|
||||
sd->device = NULL;
|
||||
|
||||
l_free(sd->iccid);
|
||||
l_free(sd->imsi);
|
||||
l_free(sd);
|
||||
}
|
||||
|
||||
static struct ofono_sim_driver driver = {
|
||||
.name = "mbim",
|
||||
.probe = mbim_sim_probe,
|
||||
.remove = mbim_sim_remove,
|
||||
.read_imsi = mbim_read_imsi,
|
||||
.query_passwd_state = mbim_pin_query,
|
||||
.query_pin_retries = mbim_pin_retries_query,
|
||||
.send_passwd = mbim_pin_enter,
|
||||
.reset_passwd = mbim_puk_enter,
|
||||
.change_passwd = mbim_pin_change,
|
||||
.lock = mbim_pin_enable,
|
||||
};
|
||||
|
||||
void mbim_sim_init(void)
|
||||
{
|
||||
ofono_sim_driver_register(&driver);
|
||||
}
|
||||
|
||||
void mbim_sim_exit(void)
|
||||
{
|
||||
ofono_sim_driver_unregister(&driver);
|
||||
}
|
||||
516
ofono/drivers/mbimmodem/sms.c
Normal file
516
ofono/drivers/mbimmodem/sms.c
Normal file
@@ -0,0 +1,516 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/sms.h>
|
||||
#include "common.h"
|
||||
|
||||
#include "drivers/mbimmodem/mbim.h"
|
||||
#include "drivers/mbimmodem/mbim-message.h"
|
||||
#include "drivers/mbimmodem/mbimmodem.h"
|
||||
|
||||
struct sms_data {
|
||||
struct mbim_device *device;
|
||||
uint32_t configuration_notify_id;
|
||||
};
|
||||
|
||||
static void mbim_sca_set_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
ofono_sms_sca_set_cb_t cb = cbd->cb;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
else
|
||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_sca_set(struct ofono_sms *sms,
|
||||
const struct ofono_phone_number *sca,
|
||||
ofono_sms_sca_set_cb_t cb, void *data)
|
||||
{
|
||||
struct sms_data *sd = ofono_sms_get_data(sms);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct mbim_message *message;
|
||||
const char *numberstr = phone_number_to_string(sca);
|
||||
|
||||
message = mbim_message_new(mbim_uuid_sms,
|
||||
MBIM_CID_SMS_CONFIGURATION,
|
||||
MBIM_COMMAND_TYPE_SET);
|
||||
mbim_message_set_arguments(message, "us", 0, numberstr);
|
||||
|
||||
if (mbim_device_send(sd->device, SMS_GROUP, message,
|
||||
mbim_sca_set_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
}
|
||||
|
||||
static void mbim_sca_query_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
ofono_sms_sca_query_cb_t cb = cbd->cb;
|
||||
struct ofono_phone_number sca;
|
||||
uint32_t dummy;
|
||||
L_AUTO_FREE_VAR(char *, number) = NULL;
|
||||
const char *p;
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
goto error;
|
||||
|
||||
if (!mbim_message_get_arguments(message, "uuuus",
|
||||
&dummy, &dummy, &dummy, &dummy,
|
||||
&number))
|
||||
goto error;
|
||||
|
||||
if (number[0] == '+') {
|
||||
p = number + 1;
|
||||
sca.type = 145;
|
||||
} else {
|
||||
p = number;
|
||||
sca.type = 129;
|
||||
}
|
||||
|
||||
strncpy(sca.number, p, OFONO_MAX_PHONE_NUMBER_LENGTH);
|
||||
sca.number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0';
|
||||
CALLBACK_WITH_SUCCESS(cb, &sca, cbd->data);
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_sca_query(struct ofono_sms *sms, ofono_sms_sca_query_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct sms_data *sd = ofono_sms_get_data(sms);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct mbim_message *message;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_sms,
|
||||
MBIM_CID_SMS_CONFIGURATION,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
mbim_message_set_arguments(message, "");
|
||||
|
||||
if (mbim_device_send(sd->device, SMS_GROUP, message,
|
||||
mbim_sca_query_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, data);
|
||||
}
|
||||
|
||||
static void mbim_delete_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
DBG("%u", mbim_message_get_error(message));
|
||||
}
|
||||
|
||||
static void mbim_sms_send_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct cb_data *cbd = user;
|
||||
struct sms_data *sd = cbd->user;
|
||||
ofono_sms_submit_cb_t cb = cbd->cb;
|
||||
uint32_t mr;
|
||||
struct mbim_message *delete;
|
||||
|
||||
DBG("%u", mbim_message_get_error(message));
|
||||
|
||||
if (mbim_message_get_error(message) != 0)
|
||||
goto error;
|
||||
|
||||
if (!mbim_message_get_arguments(message, "u", &mr))
|
||||
goto error;
|
||||
|
||||
/* Just in case, send an SMS DELETE command for Sent messages */
|
||||
delete = mbim_message_new(mbim_uuid_sms,
|
||||
MBIM_CID_SMS_DELETE,
|
||||
MBIM_COMMAND_TYPE_SET);
|
||||
mbim_message_set_arguments(delete, "uu", 4, 0);
|
||||
|
||||
if (!mbim_device_send(sd->device, SMS_GROUP, delete,
|
||||
mbim_delete_cb, NULL, NULL))
|
||||
mbim_message_unref(delete);
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, mr, cbd->data);
|
||||
return;
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
|
||||
}
|
||||
|
||||
static void mbim_submit(struct ofono_sms *sms, const unsigned char *pdu,
|
||||
int pdu_len, int tpdu_len, int mms,
|
||||
ofono_sms_submit_cb_t cb, void *data)
|
||||
{
|
||||
struct sms_data *sd = ofono_sms_get_data(sms);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct mbim_message *message;
|
||||
|
||||
DBG("pdu_len: %d tpdu_len: %d mms: %d", pdu_len, tpdu_len, mms);
|
||||
|
||||
cbd->user = sd;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_sms,
|
||||
MBIM_CID_SMS_SEND,
|
||||
MBIM_COMMAND_TYPE_SET);
|
||||
mbim_message_set_arguments(message, "ud", 0, "ay", pdu_len, pdu);
|
||||
|
||||
if (mbim_device_send(sd->device, SMS_GROUP, message,
|
||||
mbim_sms_send_cb, cbd, l_free) > 0)
|
||||
return;
|
||||
|
||||
l_free(cbd);
|
||||
mbim_message_unref(message);
|
||||
CALLBACK_WITH_FAILURE(cb, -1, data);
|
||||
}
|
||||
|
||||
static void mbim_sms_send_delete(struct sms_data *sd, uint32_t index)
|
||||
{
|
||||
struct mbim_message *delete;
|
||||
|
||||
DBG("%u", index);
|
||||
|
||||
delete = mbim_message_new(mbim_uuid_sms,
|
||||
MBIM_CID_SMS_DELETE,
|
||||
MBIM_COMMAND_TYPE_SET);
|
||||
mbim_message_set_arguments(delete, "uu", 1, index);
|
||||
|
||||
if (!mbim_device_send(sd->device, SMS_GROUP, delete,
|
||||
mbim_delete_cb, NULL, NULL))
|
||||
mbim_message_unref(delete);
|
||||
}
|
||||
|
||||
static void mbim_parse_sms_read_info(struct mbim_message *message,
|
||||
struct ofono_sms *sms)
|
||||
{
|
||||
struct sms_data *sd = ofono_sms_get_data(sms);
|
||||
uint32_t format;
|
||||
uint32_t n_sms;
|
||||
struct mbim_message_iter array;
|
||||
struct mbim_message_iter bytes;
|
||||
uint32_t index;
|
||||
uint32_t status;
|
||||
uint32_t pdu_len;
|
||||
|
||||
if (!mbim_message_get_arguments(message, "ua(uuay)",
|
||||
&format, &n_sms, &array))
|
||||
return;
|
||||
|
||||
if (format != 0)
|
||||
return;
|
||||
|
||||
while (mbim_message_iter_next_entry(&array, &index, &status,
|
||||
&pdu_len, &bytes)) {
|
||||
int i = 0;
|
||||
|
||||
/* Ignore Draft (2) and Sent (3) messages */
|
||||
if (status == 0 || status == 1) {
|
||||
uint8_t pdu[176];
|
||||
uint32_t tpdu_len;
|
||||
|
||||
while (mbim_message_iter_next_entry(&bytes, pdu + i))
|
||||
i++;
|
||||
|
||||
tpdu_len = pdu_len - pdu[0] - 1;
|
||||
ofono_sms_deliver_notify(sms, pdu, pdu_len, tpdu_len);
|
||||
}
|
||||
|
||||
mbim_sms_send_delete(sd, index);
|
||||
}
|
||||
}
|
||||
|
||||
static void mbim_sms_read_notify(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct ofono_sms *sms = user;
|
||||
|
||||
DBG("");
|
||||
|
||||
mbim_parse_sms_read_info(message, sms);
|
||||
}
|
||||
|
||||
static void mbim_sms_read_new_query_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct ofono_sms *sms = user;
|
||||
|
||||
DBG("");
|
||||
|
||||
mbim_parse_sms_read_info(message, sms);
|
||||
}
|
||||
|
||||
static void mbim_sms_message_store_status_changed(struct mbim_message *message,
|
||||
void *user)
|
||||
{
|
||||
struct ofono_sms *sms = user;
|
||||
struct sms_data *sd = ofono_sms_get_data(sms);
|
||||
uint32_t flag;
|
||||
uint32_t index;
|
||||
struct mbim_message *read_query;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (!mbim_message_get_arguments(message, "uu", &flag, &index))
|
||||
return;
|
||||
|
||||
DBG("%u %u", flag, index);
|
||||
|
||||
/* MBIM_SMS_FLAG_NEW_MESSAGE not set */
|
||||
if ((flag & 2) == 0)
|
||||
return;
|
||||
|
||||
read_query = mbim_message_new(mbim_uuid_sms,
|
||||
MBIM_CID_SMS_READ,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
if (!read_query)
|
||||
return;
|
||||
|
||||
/* Query using MBIMSmsFormatPdu(0) and MBIMSmsFlagNew (2) */
|
||||
mbim_message_set_arguments(read_query, "uuu", 0, 2, 0);
|
||||
|
||||
if (!mbim_device_send(sd->device, SMS_GROUP, read_query,
|
||||
mbim_sms_read_new_query_cb, sms, NULL))
|
||||
mbim_message_unref(read_query);
|
||||
}
|
||||
|
||||
static void mbim_sms_read_all_query_cb(struct mbim_message *message, void *user)
|
||||
{
|
||||
struct ofono_sms *sms = user;
|
||||
struct sms_data *sd = ofono_sms_get_data(sms);
|
||||
|
||||
DBG("");
|
||||
|
||||
mbim_parse_sms_read_info(message, sms);
|
||||
|
||||
mbim_device_register(sd->device, SMS_GROUP, mbim_uuid_sms,
|
||||
MBIM_CID_SMS_MESSAGE_STORE_STATUS,
|
||||
mbim_sms_message_store_status_changed,
|
||||
sms, NULL);
|
||||
}
|
||||
|
||||
static bool mbim_sms_finish_init(struct ofono_sms *sms)
|
||||
{
|
||||
struct sms_data *sd = ofono_sms_get_data(sms);
|
||||
struct mbim_message *message;
|
||||
|
||||
/*
|
||||
* Class 0 SMS comes via SMS_READ notification, so register for these
|
||||
* here. After that we send an SMS_READ request to retrieve any new
|
||||
* SMS messages. In the callback we will register to
|
||||
* MESSAGE_STORE_STATUS to receive notification that new SMS messages
|
||||
* have arrived
|
||||
*/
|
||||
if (!mbim_device_register(sd->device, SMS_GROUP,
|
||||
mbim_uuid_sms,
|
||||
MBIM_CID_SMS_READ,
|
||||
mbim_sms_read_notify, sms, NULL))
|
||||
return false;
|
||||
|
||||
message = mbim_message_new(mbim_uuid_sms,
|
||||
MBIM_CID_SMS_READ,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
if (!message)
|
||||
return false;
|
||||
|
||||
/* Query using MBIMSmsFormatPdu(0) and MBIMSmsFlagAll (0) */
|
||||
mbim_message_set_arguments(message, "uuu", 0, 0, 0);
|
||||
|
||||
if (!mbim_device_send(sd->device, SMS_GROUP, message,
|
||||
mbim_sms_read_all_query_cb, sms, NULL)) {
|
||||
mbim_message_unref(message);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static void mbim_sms_configuration_changed(struct mbim_message *message,
|
||||
void *user)
|
||||
{
|
||||
struct ofono_sms *sms = user;
|
||||
struct sms_data *sd = ofono_sms_get_data(sms);
|
||||
uint32_t storage_state;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (!mbim_message_get_arguments(message, "u", &storage_state))
|
||||
goto error;
|
||||
|
||||
if (storage_state != 1)
|
||||
return;
|
||||
|
||||
mbim_device_unregister(sd->device, sd->configuration_notify_id);
|
||||
sd->configuration_notify_id = 0;
|
||||
|
||||
if (!mbim_sms_finish_init(sms))
|
||||
goto error;
|
||||
|
||||
ofono_sms_register(sms);
|
||||
return;
|
||||
|
||||
error:
|
||||
ofono_sms_remove(sms);
|
||||
}
|
||||
|
||||
static void mbim_sms_configuration_query_cb(struct mbim_message *message,
|
||||
void *user)
|
||||
{
|
||||
struct ofono_sms *sms = user;
|
||||
struct sms_data *sd = ofono_sms_get_data(sms);
|
||||
uint32_t error;
|
||||
uint32_t storage_state;
|
||||
uint32_t format;
|
||||
uint32_t max_messages;
|
||||
|
||||
DBG("");
|
||||
|
||||
error = mbim_message_get_error(message);
|
||||
|
||||
/*
|
||||
* SUBSCRIBER_READY_STATUS tells us that a SIM is in ReadyState,
|
||||
* unfortunately that seems to be not enough to know that the SMS
|
||||
* state is initialized. Handle this here, if we get an error 14
|
||||
* 'MBIM_STATUS_NOT_INITIALIZED', then listen for the
|
||||
* SMS_CONFIGURATION notification. Why some devices return an error
|
||||
* here instead of responding with a 0 storage state is a mystery
|
||||
*/
|
||||
switch (error) {
|
||||
case 14: /* Seems SIM ReadyState is sometimes not enough */
|
||||
goto setup_notification;
|
||||
case 0:
|
||||
break;
|
||||
default:
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* We don't bother parsing CdmaShortMessageSize or ScAddress array */
|
||||
if (!mbim_message_get_arguments(message, "uuu",
|
||||
&storage_state, &format, &max_messages))
|
||||
goto error;
|
||||
|
||||
DBG("storage_state: %u, format: %u, max_messages: %u",
|
||||
storage_state, format, max_messages);
|
||||
|
||||
if (format != 0) {
|
||||
DBG("Unsupported SMS Format, expect 0 (PDU)");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (storage_state == 1) {
|
||||
if (!mbim_sms_finish_init(sms))
|
||||
goto error;
|
||||
|
||||
ofono_sms_register(sms);
|
||||
return;
|
||||
}
|
||||
|
||||
setup_notification:
|
||||
/* Wait for storage_state to go to Initialized before registering */
|
||||
sd->configuration_notify_id = mbim_device_register(sd->device,
|
||||
SMS_GROUP,
|
||||
mbim_uuid_sms,
|
||||
MBIM_CID_SMS_CONFIGURATION,
|
||||
mbim_sms_configuration_changed,
|
||||
sms, NULL);
|
||||
if (sd->configuration_notify_id > 0)
|
||||
return;
|
||||
|
||||
error:
|
||||
ofono_sms_remove(sms);
|
||||
}
|
||||
|
||||
static int mbim_sms_probe(struct ofono_sms *sms, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct mbim_device *device = data;
|
||||
struct sms_data *sd;
|
||||
struct mbim_message *message;
|
||||
|
||||
DBG("");
|
||||
|
||||
message = mbim_message_new(mbim_uuid_sms,
|
||||
MBIM_CID_SMS_CONFIGURATION,
|
||||
MBIM_COMMAND_TYPE_QUERY);
|
||||
if (!message)
|
||||
return -ENOMEM;
|
||||
|
||||
mbim_message_set_arguments(message, "");
|
||||
|
||||
if (!mbim_device_send(device, SMS_GROUP, message,
|
||||
mbim_sms_configuration_query_cb, sms, NULL)) {
|
||||
mbim_message_unref(message);
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
sd = l_new(struct sms_data, 1);
|
||||
sd->device = mbim_device_ref(device);
|
||||
ofono_sms_set_data(sms, sd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void mbim_sms_remove(struct ofono_sms *sms)
|
||||
{
|
||||
struct sms_data *sd = ofono_sms_get_data(sms);
|
||||
|
||||
DBG("");
|
||||
|
||||
ofono_sms_set_data(sms, NULL);
|
||||
|
||||
mbim_device_cancel_group(sd->device, SMS_GROUP);
|
||||
mbim_device_unregister_group(sd->device, SMS_GROUP);
|
||||
mbim_device_unref(sd->device);
|
||||
sd->device = NULL;
|
||||
l_free(sd);
|
||||
}
|
||||
|
||||
static struct ofono_sms_driver driver = {
|
||||
.name = "mbim",
|
||||
.probe = mbim_sms_probe,
|
||||
.remove = mbim_sms_remove,
|
||||
.sca_query = mbim_sca_query,
|
||||
.sca_set = mbim_sca_set,
|
||||
.submit = mbim_submit,
|
||||
};
|
||||
|
||||
void mbim_sms_init(void)
|
||||
{
|
||||
ofono_sms_driver_register(&driver);
|
||||
}
|
||||
|
||||
void mbim_sms_exit(void)
|
||||
{
|
||||
ofono_sms_driver_unregister(&driver);
|
||||
}
|
||||
54
ofono/drivers/mbimmodem/util.c
Normal file
54
ofono/drivers/mbimmodem/util.c
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "src/common.h"
|
||||
#include "mbim.h"
|
||||
#include "util.h"
|
||||
|
||||
int mbim_data_class_to_tech(uint32_t n)
|
||||
{
|
||||
if (n & MBIM_DATA_CLASS_LTE)
|
||||
return ACCESS_TECHNOLOGY_EUTRAN;
|
||||
|
||||
if (n & (MBIM_DATA_CLASS_HSUPA | MBIM_DATA_CLASS_HSDPA))
|
||||
return ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA;
|
||||
|
||||
if (n & MBIM_DATA_CLASS_HSUPA)
|
||||
return ACCESS_TECHNOLOGY_UTRAN_HSUPA;
|
||||
|
||||
if (n & MBIM_DATA_CLASS_HSDPA)
|
||||
return ACCESS_TECHNOLOGY_UTRAN_HSDPA;
|
||||
|
||||
if (n & MBIM_DATA_CLASS_UMTS)
|
||||
return ACCESS_TECHNOLOGY_UTRAN;
|
||||
|
||||
if (n & MBIM_DATA_CLASS_EDGE)
|
||||
return ACCESS_TECHNOLOGY_GSM_EGPRS;
|
||||
|
||||
if (n & MBIM_DATA_CLASS_GPRS)
|
||||
return ACCESS_TECHNOLOGY_GSM;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
59
ofono/drivers/mbimmodem/util.h
Normal file
59
ofono/drivers/mbimmodem/util.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 Intel Corporation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#include <ell/ell.h>
|
||||
|
||||
struct cb_data {
|
||||
void *cb;
|
||||
void *data;
|
||||
void *user;
|
||||
};
|
||||
|
||||
static inline struct cb_data *cb_data_new(void *cb, void *data)
|
||||
{
|
||||
struct cb_data *ret;
|
||||
|
||||
ret = l_new(struct cb_data, 1);
|
||||
ret->cb = cb;
|
||||
ret->data = data;
|
||||
ret->user = NULL;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define CALLBACK_WITH_FAILURE(cb, args...) \
|
||||
do { \
|
||||
struct ofono_error cb_e; \
|
||||
cb_e.type = OFONO_ERROR_TYPE_FAILURE; \
|
||||
cb_e.error = 0; \
|
||||
\
|
||||
cb(&cb_e, ##args); \
|
||||
} while (0) \
|
||||
|
||||
#define CALLBACK_WITH_SUCCESS(f, args...) \
|
||||
do { \
|
||||
struct ofono_error e; \
|
||||
e.type = OFONO_ERROR_TYPE_NO_ERROR; \
|
||||
e.error = 0; \
|
||||
f(&e, ##args); \
|
||||
} while (0)
|
||||
|
||||
int mbim_data_class_to_tech(uint32_t n);
|
||||
@@ -129,6 +129,7 @@ static void get_ids_cb(struct qmi_result *result, void *user_data)
|
||||
str = qmi_result_get_string(result, QMI_DMS_RESULT_ESN);
|
||||
/* Telit qmi modems return a "0" string when ESN is not available. */
|
||||
if (!str || strcmp(str, "0") == 0) {
|
||||
qmi_free(str);
|
||||
str = qmi_result_get_string(result, QMI_DMS_RESULT_IMEI);
|
||||
if (!str) {
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
|
||||
|
||||
@@ -29,12 +29,16 @@
|
||||
|
||||
#include "qmi.h"
|
||||
#include "nas.h"
|
||||
#include "wds.h"
|
||||
|
||||
#include "src/common.h"
|
||||
#include "qmimodem.h"
|
||||
|
||||
struct gprs_data {
|
||||
struct qmi_device *dev;
|
||||
struct qmi_service *nas;
|
||||
struct qmi_service *wds;
|
||||
unsigned int last_auto_context_id;
|
||||
};
|
||||
|
||||
static bool extract_ss_info(struct qmi_result *result, int *status, int *tech)
|
||||
@@ -64,8 +68,124 @@ static bool extract_ss_info(struct qmi_result *result, int *status, int *tech)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void get_lte_attach_param_cb(struct qmi_result *result, void *user_data)
|
||||
{
|
||||
struct ofono_gprs *gprs = user_data;
|
||||
struct gprs_data *data = ofono_gprs_get_data(gprs);
|
||||
char *apn = NULL;
|
||||
uint16_t error;
|
||||
uint8_t iptype;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (qmi_result_set_error(result, &error)) {
|
||||
ofono_error("Failed to query LTE attach params: %hd", error);
|
||||
goto noapn;
|
||||
}
|
||||
|
||||
/* APN */
|
||||
apn = qmi_result_get_string(result, 0x10);
|
||||
if (!apn) {
|
||||
DBG("Default profile has no APN setting");
|
||||
goto noapn;
|
||||
}
|
||||
|
||||
if (qmi_result_get_uint8(result, 0x11, &iptype))
|
||||
ofono_info("LTE attach IP type: %hhd", iptype);
|
||||
|
||||
ofono_gprs_cid_activated(gprs, data->last_auto_context_id, apn);
|
||||
g_free(apn);
|
||||
|
||||
return;
|
||||
|
||||
noapn:
|
||||
data->last_auto_context_id = 0;
|
||||
ofono_error("LTE bearer established but APN not set");
|
||||
}
|
||||
|
||||
static void get_default_profile_cb(struct qmi_result *result, void *user_data)
|
||||
{
|
||||
struct ofono_gprs* gprs = user_data;
|
||||
struct gprs_data *data = ofono_gprs_get_data(gprs);
|
||||
uint16_t error;
|
||||
uint8_t index;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (qmi_result_set_error(result, &error)) {
|
||||
ofono_error("Get default profile error: %hd", error);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Profile index */
|
||||
if (!qmi_result_get_uint8(result, 0x01, &index)) {
|
||||
ofono_error("Failed query default profile");
|
||||
goto error;
|
||||
}
|
||||
|
||||
DBG("Default profile index: %hhd", index);
|
||||
|
||||
data->last_auto_context_id = index;
|
||||
|
||||
/* Get LTE Attach Parameters */
|
||||
if (qmi_service_send(data->wds, 0x85, NULL,
|
||||
get_lte_attach_param_cb, gprs, NULL) > 0)
|
||||
return;
|
||||
|
||||
error:
|
||||
data->last_auto_context_id = 0;
|
||||
ofono_error("LTE bearer established but APN not set");
|
||||
}
|
||||
|
||||
/*
|
||||
* Query the settings in effect on the default bearer. These may be
|
||||
* implicit or may even be something other than requested as the gateway
|
||||
* is allowed to override whatever was requested by the user.
|
||||
*/
|
||||
static void get_lte_attach_params(struct ofono_gprs* gprs)
|
||||
{
|
||||
struct gprs_data *data = ofono_gprs_get_data(gprs);
|
||||
struct {
|
||||
uint8_t type;
|
||||
uint8_t family;
|
||||
} __attribute((packed)) p = {
|
||||
.type = 0, /* 3GPP */
|
||||
.family = 0, /* embedded */
|
||||
};
|
||||
struct qmi_param *param;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (data->last_auto_context_id != 0)
|
||||
return; /* Established or in progress */
|
||||
|
||||
/* Set query in progress */
|
||||
data->last_auto_context_id = -1;
|
||||
|
||||
/* First we query the default profile in order to find out which
|
||||
* context the modem has activated.
|
||||
*/
|
||||
param = qmi_param_new();
|
||||
if (!param)
|
||||
goto error;
|
||||
|
||||
/* Profile type */
|
||||
qmi_param_append(param, 0x1, sizeof(p), &p);
|
||||
|
||||
/* Get default profile */
|
||||
if (qmi_service_send(data->wds, 0x49, param,
|
||||
get_default_profile_cb, gprs, NULL) > 0)
|
||||
return;
|
||||
|
||||
qmi_param_free(param);
|
||||
|
||||
error:
|
||||
ofono_warn("Unable to query LTE APN... will not activate context");
|
||||
}
|
||||
|
||||
static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs)
|
||||
{
|
||||
struct gprs_data *data = ofono_gprs_get_data(gprs);
|
||||
int status;
|
||||
int tech;
|
||||
|
||||
@@ -74,17 +194,20 @@ static int handle_ss_info(struct qmi_result *result, struct ofono_gprs *gprs)
|
||||
if (!extract_ss_info(result, &status, &tech))
|
||||
return -1;
|
||||
|
||||
if (status == NETWORK_REGISTRATION_STATUS_REGISTERED)
|
||||
if (status == NETWORK_REGISTRATION_STATUS_REGISTERED) {
|
||||
if (tech == ACCESS_TECHNOLOGY_EUTRAN) {
|
||||
/* On LTE we are effectively always attached; and
|
||||
* the default bearer is established as soon as the
|
||||
* network is joined.
|
||||
* network is joined. We just need to query the
|
||||
* parameters in effect on the default bearer and
|
||||
* let the ofono core know about the activated
|
||||
* context.
|
||||
*/
|
||||
/* FIXME: query default profile number and APN
|
||||
* instead of assuming profile 1 and ""
|
||||
*/
|
||||
ofono_gprs_cid_activated(gprs, 1 , "automatic");
|
||||
get_lte_attach_params(gprs);
|
||||
}
|
||||
} else {
|
||||
data->last_auto_context_id = 0;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@@ -198,7 +321,7 @@ static void qmi_attached_status(struct ofono_gprs *gprs,
|
||||
g_free(cbd);
|
||||
}
|
||||
|
||||
static void create_nas_cb(struct qmi_service *service, void *user_data)
|
||||
static void create_wds_cb(struct qmi_service *service, void *user_data)
|
||||
{
|
||||
struct ofono_gprs *gprs = user_data;
|
||||
struct gprs_data *data = ofono_gprs_get_data(gprs);
|
||||
@@ -206,12 +329,12 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)
|
||||
DBG("");
|
||||
|
||||
if (!service) {
|
||||
ofono_error("Failed to request NAS service");
|
||||
ofono_error("Failed to request WDS service");
|
||||
ofono_gprs_remove(gprs);
|
||||
return;
|
||||
}
|
||||
|
||||
data->nas = qmi_service_ref(service);
|
||||
data->wds = qmi_service_ref(service);
|
||||
|
||||
/*
|
||||
* First get the SS info - the modem may already be connected,
|
||||
@@ -228,6 +351,25 @@ static void create_nas_cb(struct qmi_service *service, void *user_data)
|
||||
ofono_gprs_register(gprs);
|
||||
}
|
||||
|
||||
static void create_nas_cb(struct qmi_service *service, void *user_data)
|
||||
{
|
||||
struct ofono_gprs *gprs = user_data;
|
||||
struct gprs_data *data = ofono_gprs_get_data(gprs);
|
||||
|
||||
DBG("");
|
||||
|
||||
if (!service) {
|
||||
ofono_error("Failed to request NAS service");
|
||||
ofono_gprs_remove(gprs);
|
||||
return;
|
||||
}
|
||||
|
||||
data->nas = qmi_service_ref(service);
|
||||
|
||||
qmi_service_create_shared(data->dev, QMI_SERVICE_WDS,
|
||||
create_wds_cb, gprs, NULL);
|
||||
}
|
||||
|
||||
static int qmi_gprs_probe(struct ofono_gprs *gprs,
|
||||
unsigned int vendor, void *user_data)
|
||||
{
|
||||
@@ -240,6 +382,8 @@ static int qmi_gprs_probe(struct ofono_gprs *gprs,
|
||||
|
||||
ofono_gprs_set_data(gprs, data);
|
||||
|
||||
data->dev = device;
|
||||
|
||||
qmi_service_create_shared(device, QMI_SERVICE_NAS,
|
||||
create_nas_cb, gprs, NULL);
|
||||
|
||||
@@ -254,6 +398,9 @@ static void qmi_gprs_remove(struct ofono_gprs *gprs)
|
||||
|
||||
ofono_gprs_set_data(gprs, NULL);
|
||||
|
||||
qmi_service_unregister_all(data->wds);
|
||||
qmi_service_unref(data->wds);
|
||||
|
||||
qmi_service_unregister_all(data->nas);
|
||||
|
||||
qmi_service_unref(data->nas);
|
||||
|
||||
265
ofono/drivers/qmimodem/lte.c
Normal file
265
ofono/drivers/qmimodem/lte.c
Normal file
@@ -0,0 +1,265 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2018 Jonas Bonn. All rights reserved.
|
||||
* Copyright (C) 2018 Norrbonn AB. All rights reserved.
|
||||
* Copyright (C) 2018 Data Respons ASA. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/gprs-context.h>
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/lte.h>
|
||||
|
||||
#include "qmi.h"
|
||||
#include "wds.h"
|
||||
|
||||
#include "qmimodem.h"
|
||||
|
||||
struct lte_data {
|
||||
struct qmi_service *wds;
|
||||
uint8_t default_profile;
|
||||
};
|
||||
|
||||
static void modify_profile_cb(struct qmi_result *result, void *user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
ofono_lte_cb_t cb = cbd->cb;
|
||||
uint16_t error;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (qmi_result_set_error(result, &error)) {
|
||||
DBG("Failed to modify profile: %d", error);
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
||||
}
|
||||
|
||||
static void qmimodem_lte_set_default_attach_info(const struct ofono_lte *lte,
|
||||
const struct ofono_lte_default_attach_info *info,
|
||||
ofono_lte_cb_t cb, void *data)
|
||||
{
|
||||
struct lte_data *ldd = ofono_lte_get_data(lte);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct qmi_param* param;
|
||||
struct {
|
||||
uint8_t type;
|
||||
uint8_t index;
|
||||
} __attribute__((packed)) p = {
|
||||
.type = 0, /* 3GPP */
|
||||
};
|
||||
|
||||
DBG("");
|
||||
|
||||
p.index = ldd->default_profile;
|
||||
|
||||
param = qmi_param_new();
|
||||
if (!param)
|
||||
goto error;
|
||||
|
||||
/* Profile selector */
|
||||
qmi_param_append(param, 0x01, sizeof(p), &p);
|
||||
|
||||
/* WDS APN Name */
|
||||
qmi_param_append(param, QMI_WDS_PARAM_APN,
|
||||
strlen(info->apn), info->apn);
|
||||
|
||||
/* Modify profile */
|
||||
if (qmi_service_send(ldd->wds, 0x28, param,
|
||||
modify_profile_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
qmi_param_free(param);
|
||||
|
||||
error:
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
}
|
||||
|
||||
static void reset_profile_cb(struct qmi_result *result, void *user_data)
|
||||
{
|
||||
struct ofono_lte *lte = user_data;
|
||||
uint16_t error;
|
||||
|
||||
DBG("");
|
||||
|
||||
if (qmi_result_set_error(result, &error))
|
||||
ofono_error("Reset profile error: %hd", error);
|
||||
|
||||
ofono_lte_register(lte);
|
||||
}
|
||||
|
||||
static void get_default_profile_cb(struct qmi_result *result, void *user_data)
|
||||
{
|
||||
struct ofono_lte *lte = user_data;
|
||||
struct lte_data *ldd = ofono_lte_get_data(lte);
|
||||
uint16_t error;
|
||||
uint8_t index;
|
||||
struct qmi_param *param;
|
||||
struct {
|
||||
uint8_t type;
|
||||
uint8_t index;
|
||||
} __attribute__((packed)) p = {
|
||||
.type = 0, /* 3GPP */
|
||||
};
|
||||
|
||||
DBG("");
|
||||
|
||||
if (qmi_result_set_error(result, &error)) {
|
||||
ofono_error("Get default profile error: %hd", error);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/* Profile index */
|
||||
if (!qmi_result_get_uint8(result, 0x01, &index)) {
|
||||
ofono_error("Failed query default profile");
|
||||
goto error;
|
||||
}
|
||||
|
||||
DBG("Default profile index: %hhd", index);
|
||||
|
||||
ldd->default_profile = index;
|
||||
|
||||
p.index = index;
|
||||
|
||||
param = qmi_param_new();
|
||||
if (!param)
|
||||
goto error;
|
||||
|
||||
/* Profile selector */
|
||||
qmi_param_append(param, 0x01, sizeof(p), &p);
|
||||
|
||||
/* Reset profile */
|
||||
if (qmi_service_send(ldd->wds, 0x4b, param,
|
||||
reset_profile_cb, lte, NULL) > 0)
|
||||
return;
|
||||
|
||||
qmi_param_free(param);
|
||||
|
||||
error:
|
||||
ofono_error("Failed to reset profile %hhd", index);
|
||||
ofono_lte_remove(lte);
|
||||
}
|
||||
|
||||
static void create_wds_cb(struct qmi_service *service, void *user_data)
|
||||
{
|
||||
struct ofono_lte *lte = user_data;
|
||||
struct lte_data *ldd = ofono_lte_get_data(lte);
|
||||
struct qmi_param *param;
|
||||
struct {
|
||||
uint8_t type;
|
||||
uint8_t family;
|
||||
} __attribute((packed)) p = {
|
||||
.type = 0, /* 3GPP */
|
||||
.family = 0, /* embedded */
|
||||
};
|
||||
|
||||
DBG("");
|
||||
|
||||
if (!service) {
|
||||
ofono_error("Failed to request WDS service");
|
||||
ofono_lte_remove(lte);
|
||||
return;
|
||||
}
|
||||
|
||||
ldd->wds = qmi_service_ref(service);
|
||||
|
||||
/* Query the default profile */
|
||||
param = qmi_param_new();
|
||||
if (!param)
|
||||
goto error;
|
||||
|
||||
/* Profile type */
|
||||
qmi_param_append(param, 0x1, sizeof(p), &p);
|
||||
|
||||
/* Get default profile */
|
||||
if (qmi_service_send(ldd->wds, 0x49, param,
|
||||
get_default_profile_cb, lte, NULL) > 0)
|
||||
return;
|
||||
|
||||
qmi_param_free(param);
|
||||
|
||||
error:
|
||||
ofono_error("Failed to query default profile");
|
||||
ofono_lte_register(lte);
|
||||
}
|
||||
|
||||
static int qmimodem_lte_probe(struct ofono_lte *lte,
|
||||
unsigned int vendor, void *data)
|
||||
{
|
||||
struct qmi_device *device = data;
|
||||
struct lte_data *ldd;
|
||||
|
||||
DBG("qmimodem lte probe");
|
||||
|
||||
ldd = g_try_new0(struct lte_data, 1);
|
||||
if (!ldd)
|
||||
return -ENOMEM;
|
||||
|
||||
ofono_lte_set_data(lte, ldd);
|
||||
|
||||
qmi_service_create_shared(device, QMI_SERVICE_WDS,
|
||||
create_wds_cb, lte, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void qmimodem_lte_remove(struct ofono_lte *lte)
|
||||
{
|
||||
struct lte_data *ldd = ofono_lte_get_data(lte);
|
||||
|
||||
DBG("");
|
||||
|
||||
ofono_lte_set_data(lte, NULL);
|
||||
|
||||
qmi_service_unregister_all(ldd->wds);
|
||||
|
||||
qmi_service_unref(ldd->wds);
|
||||
|
||||
g_free(ldd);
|
||||
}
|
||||
|
||||
static struct ofono_lte_driver driver = {
|
||||
.name = "qmimodem",
|
||||
.probe = qmimodem_lte_probe,
|
||||
.remove = qmimodem_lte_remove,
|
||||
.set_default_attach_info = qmimodem_lte_set_default_attach_info,
|
||||
};
|
||||
|
||||
void qmi_lte_init(void)
|
||||
{
|
||||
ofono_lte_driver_register(&driver);
|
||||
}
|
||||
|
||||
void qmi_lte_exit(void)
|
||||
{
|
||||
ofono_lte_driver_unregister(&driver);
|
||||
}
|
||||
@@ -332,6 +332,7 @@ static void register_net_cb(struct qmi_result *result, void *user_data)
|
||||
struct cb_data *cbd = user_data;
|
||||
ofono_netreg_register_cb_t cb = cbd->cb;
|
||||
uint16_t error;
|
||||
int cme_error;
|
||||
|
||||
DBG("");
|
||||
|
||||
@@ -341,7 +342,8 @@ static void register_net_cb(struct qmi_result *result, void *user_data)
|
||||
goto done;
|
||||
}
|
||||
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
cme_error = qmi_error_to_ofono_cme(error);
|
||||
CALLBACK_WITH_CME_ERROR(cb, cme_error, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,13 @@ struct discovery {
|
||||
qmi_destroy_func_t destroy;
|
||||
};
|
||||
|
||||
struct qmi_version {
|
||||
uint8_t type;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
struct qmi_device {
|
||||
int ref_count;
|
||||
int fd;
|
||||
@@ -80,7 +87,6 @@ struct qmi_device {
|
||||
struct qmi_service {
|
||||
int ref_count;
|
||||
struct qmi_device *device;
|
||||
bool shared;
|
||||
uint8_t type;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
@@ -161,25 +167,25 @@ void qmi_free(void *ptr)
|
||||
|
||||
static struct qmi_request *__request_alloc(uint8_t service,
|
||||
uint8_t client, uint16_t message,
|
||||
uint16_t headroom, const void *data,
|
||||
const void *data,
|
||||
uint16_t length, qmi_message_func_t func,
|
||||
void *user_data, void **head)
|
||||
void *user_data)
|
||||
{
|
||||
struct qmi_request *req;
|
||||
struct qmi_mux_hdr *hdr;
|
||||
struct qmi_message_hdr *msg;
|
||||
uint16_t headroom;
|
||||
|
||||
req = g_try_new0(struct qmi_request, 1);
|
||||
if (!req)
|
||||
return NULL;
|
||||
req = g_new0(struct qmi_request, 1);
|
||||
|
||||
if (service == QMI_SERVICE_CONTROL)
|
||||
headroom = QMI_CONTROL_HDR_SIZE;
|
||||
else
|
||||
headroom = QMI_SERVICE_HDR_SIZE;
|
||||
|
||||
req->len = QMI_MUX_HDR_SIZE + headroom + QMI_MESSAGE_HDR_SIZE + length;
|
||||
|
||||
req->buf = g_try_malloc(req->len);
|
||||
if (!req->buf) {
|
||||
g_free(req);
|
||||
return NULL;
|
||||
}
|
||||
req->buf = g_malloc(req->len);
|
||||
|
||||
req->client = client;
|
||||
|
||||
@@ -203,8 +209,6 @@ static struct qmi_request *__request_alloc(uint8_t service,
|
||||
req->callback = func;
|
||||
req->user_data = user_data;
|
||||
|
||||
*head = req->buf + QMI_MUX_HDR_SIZE;
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
@@ -256,9 +260,6 @@ static gboolean __service_compare_shared(gpointer key, gpointer value,
|
||||
struct qmi_service *service = value;
|
||||
uint8_t type = GPOINTER_TO_UINT(user_data);
|
||||
|
||||
if (!service->shared)
|
||||
return FALSE;
|
||||
|
||||
if (service->type == type)
|
||||
return TRUE;
|
||||
|
||||
@@ -476,6 +477,17 @@ static const char *__error_to_string(uint16_t error)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int qmi_error_to_ofono_cme(int qmi_error) {
|
||||
switch (qmi_error) {
|
||||
case 0x0019:
|
||||
return 4; /* Not Supported */
|
||||
case 0x0052:
|
||||
return 32; /* Access Denied */
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void __debug_msg(const char dir, const void *buf, size_t len,
|
||||
qmi_debug_func_t function, void *user_data)
|
||||
{
|
||||
@@ -684,14 +696,37 @@ static void wakeup_writer(struct qmi_device *device)
|
||||
can_write_data, device, write_watch_destroy);
|
||||
}
|
||||
|
||||
static void __request_submit(struct qmi_device *device,
|
||||
struct qmi_request *req, uint16_t transaction)
|
||||
static uint16_t __request_submit(struct qmi_device *device,
|
||||
struct qmi_request *req)
|
||||
{
|
||||
req->tid = transaction;
|
||||
struct qmi_mux_hdr *mux;
|
||||
|
||||
mux = req->buf;
|
||||
|
||||
if (mux->service == QMI_SERVICE_CONTROL) {
|
||||
struct qmi_control_hdr *hdr;
|
||||
|
||||
hdr = req->buf + QMI_MUX_HDR_SIZE;
|
||||
hdr->type = 0x00;
|
||||
hdr->transaction = device->next_control_tid++;
|
||||
if (device->next_control_tid == 0)
|
||||
device->next_control_tid = 1;
|
||||
req->tid = hdr->transaction;
|
||||
} else {
|
||||
struct qmi_service_hdr *hdr;
|
||||
hdr = req->buf + QMI_MUX_HDR_SIZE;
|
||||
hdr->type = 0x00;
|
||||
hdr->transaction = device->next_service_tid++;
|
||||
if (device->next_service_tid < 256)
|
||||
device->next_service_tid = 256;
|
||||
req->tid = hdr->transaction;
|
||||
}
|
||||
|
||||
g_queue_push_tail(device->req_queue, req);
|
||||
|
||||
wakeup_writer(device);
|
||||
|
||||
return req->tid;
|
||||
}
|
||||
|
||||
static void service_notify(gpointer key, gpointer value, gpointer user_data)
|
||||
@@ -950,6 +985,9 @@ struct qmi_device *qmi_device_new(int fd)
|
||||
device->service_list = g_hash_table_new_full(g_direct_hash,
|
||||
g_direct_equal, NULL, service_destroy);
|
||||
|
||||
device->next_control_tid = 1;
|
||||
device->next_service_tid = 256;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
@@ -1067,12 +1105,48 @@ static const void *tlv_get(const void *data, uint16_t size,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool qmi_device_get_service_version(struct qmi_device *device, uint8_t type,
|
||||
uint16_t *major, uint16_t *minor)
|
||||
{
|
||||
struct qmi_version *info;
|
||||
int i;
|
||||
|
||||
for (i = 0, info = device->version_list;
|
||||
i < device->version_count;
|
||||
i++, info++) {
|
||||
if (info->type == type) {
|
||||
*major = info->major;
|
||||
*minor = info->minor;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool qmi_device_has_service(struct qmi_device *device, uint8_t type)
|
||||
{
|
||||
struct qmi_version *info;
|
||||
int i;
|
||||
|
||||
for (i = 0, info = device->version_list;
|
||||
i < device->version_count;
|
||||
i++, info++) {
|
||||
if (info->type == type) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
struct discover_data {
|
||||
struct discovery super;
|
||||
struct qmi_device *device;
|
||||
qmi_discover_func_t func;
|
||||
void *user_data;
|
||||
qmi_destroy_func_t destroy;
|
||||
uint8_t tid;
|
||||
guint timeout;
|
||||
};
|
||||
|
||||
@@ -1133,6 +1207,13 @@ static void discover_callback(uint16_t message, uint16_t length,
|
||||
uint8_t type = service_list->services[i].type;
|
||||
const char *name = __service_type_to_string(type);
|
||||
|
||||
if (name)
|
||||
__debug_device(device, "found service [%s %d.%d]",
|
||||
name, major, minor);
|
||||
else
|
||||
__debug_device(device, "found service [%d %d.%d]",
|
||||
type, major, minor);
|
||||
|
||||
if (type == QMI_SERVICE_CONTROL) {
|
||||
device->control_major = major;
|
||||
device->control_minor = minor;
|
||||
@@ -1145,13 +1226,6 @@ static void discover_callback(uint16_t message, uint16_t length,
|
||||
list[count].name = name;
|
||||
|
||||
count++;
|
||||
|
||||
if (name)
|
||||
__debug_device(device, "found service [%s %d.%d]",
|
||||
name, major, minor);
|
||||
else
|
||||
__debug_device(device, "found service [%d %d.%d]",
|
||||
type, major, minor);
|
||||
}
|
||||
|
||||
ptr = tlv_get(buffer, length, 0x10, &len);
|
||||
@@ -1160,19 +1234,12 @@ static void discover_callback(uint16_t message, uint16_t length,
|
||||
|
||||
device->version_str = strndup(ptr + 1, *((uint8_t *) ptr));
|
||||
|
||||
service_list = ptr + *((uint8_t *) ptr) + 1;
|
||||
|
||||
for (i = 0; i < service_list->count; i++) {
|
||||
if (service_list->services[i].type == QMI_SERVICE_CONTROL)
|
||||
continue;
|
||||
}
|
||||
|
||||
done:
|
||||
device->version_list = list;
|
||||
device->version_count = count;
|
||||
|
||||
if (data->func)
|
||||
data->func(count, list, data->user_data);
|
||||
data->func(data->user_data);
|
||||
|
||||
__qmi_device_discovery_complete(data->device, &data->super);
|
||||
}
|
||||
@@ -1181,14 +1248,37 @@ static gboolean discover_reply(gpointer user_data)
|
||||
{
|
||||
struct discover_data *data = user_data;
|
||||
struct qmi_device *device = data->device;
|
||||
unsigned int tid = data->tid;
|
||||
GList *list;
|
||||
struct qmi_request *req = NULL;
|
||||
|
||||
data->timeout = 0;
|
||||
|
||||
/* remove request from queues */
|
||||
if (tid != 0) {
|
||||
list = g_queue_find_custom(device->req_queue,
|
||||
GUINT_TO_POINTER(tid), __request_compare);
|
||||
|
||||
if (list) {
|
||||
req = list->data;
|
||||
g_queue_delete_link(device->req_queue, list);
|
||||
} else {
|
||||
list = g_queue_find_custom(device->control_queue,
|
||||
GUINT_TO_POINTER(tid), __request_compare);
|
||||
|
||||
if (list) {
|
||||
req = list->data;
|
||||
g_queue_delete_link(device->control_queue,
|
||||
list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data->func)
|
||||
data->func(device->version_count,
|
||||
device->version_list, data->user_data);
|
||||
data->func(data->user_data);
|
||||
|
||||
__qmi_device_discovery_complete(data->device, &data->super);
|
||||
__request_free(req, NULL);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1198,7 +1288,7 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
|
||||
{
|
||||
struct discover_data *data;
|
||||
struct qmi_request *req;
|
||||
struct qmi_control_hdr *hdr;
|
||||
uint8_t tid;
|
||||
|
||||
if (!device)
|
||||
return false;
|
||||
@@ -1222,20 +1312,12 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
|
||||
}
|
||||
|
||||
req = __request_alloc(QMI_SERVICE_CONTROL, 0x00,
|
||||
QMI_CTL_GET_VERSION_INFO, QMI_CONTROL_HDR_SIZE,
|
||||
NULL, 0, discover_callback, data, (void **) &hdr);
|
||||
if (!req) {
|
||||
g_free(data);
|
||||
return false;
|
||||
}
|
||||
QMI_CTL_GET_VERSION_INFO,
|
||||
NULL, 0, discover_callback, data);
|
||||
|
||||
if (device->next_control_tid < 1)
|
||||
device->next_control_tid = 1;
|
||||
tid = __request_submit(device, req);
|
||||
|
||||
hdr->type = 0x00;
|
||||
hdr->transaction = device->next_control_tid++;
|
||||
|
||||
__request_submit(device, req, hdr->transaction);
|
||||
data->tid = tid;
|
||||
|
||||
data->timeout = g_timeout_add_seconds(5, discover_reply, data);
|
||||
__qmi_device_discovery_started(device, &data->super);
|
||||
@@ -1249,24 +1331,13 @@ static void release_client(struct qmi_device *device,
|
||||
{
|
||||
unsigned char release_req[] = { 0x01, 0x02, 0x00, type, client_id };
|
||||
struct qmi_request *req;
|
||||
struct qmi_control_hdr *hdr;
|
||||
|
||||
req = __request_alloc(QMI_SERVICE_CONTROL, 0x00,
|
||||
QMI_CTL_RELEASE_CLIENT_ID, QMI_CONTROL_HDR_SIZE,
|
||||
QMI_CTL_RELEASE_CLIENT_ID,
|
||||
release_req, sizeof(release_req),
|
||||
func, user_data, (void **) &hdr);
|
||||
if (!req) {
|
||||
func(0x0000, 0x0000, NULL, user_data);
|
||||
return;
|
||||
}
|
||||
func, user_data);
|
||||
|
||||
if (device->next_control_tid < 1)
|
||||
device->next_control_tid = 1;
|
||||
|
||||
hdr->type = 0x00;
|
||||
hdr->transaction = device->next_control_tid++;
|
||||
|
||||
__request_submit(device, req, hdr->transaction);
|
||||
__request_submit(device, req);
|
||||
}
|
||||
|
||||
static void shutdown_destroy(gpointer user_data)
|
||||
@@ -1323,6 +1394,58 @@ bool qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func,
|
||||
return true;
|
||||
}
|
||||
|
||||
struct sync_data {
|
||||
qmi_sync_func_t func;
|
||||
void *user_data;
|
||||
};
|
||||
|
||||
static void qmi_device_sync_callback(uint16_t message, uint16_t length,
|
||||
const void *buffer, void *user_data)
|
||||
{
|
||||
struct sync_data *data = user_data;
|
||||
|
||||
if (data->func)
|
||||
data->func(data->user_data);
|
||||
|
||||
g_free(data);
|
||||
}
|
||||
|
||||
/* sync will release all previous clients */
|
||||
bool qmi_device_sync(struct qmi_device *device,
|
||||
qmi_sync_func_t func, void *user_data)
|
||||
{
|
||||
struct qmi_request *req;
|
||||
struct sync_data *func_data;
|
||||
|
||||
if (!device)
|
||||
return false;
|
||||
|
||||
__debug_device(device, "Sending sync to reset QMI");
|
||||
|
||||
func_data = g_new0(struct sync_data, 1);
|
||||
func_data->func = func;
|
||||
func_data->user_data = user_data;
|
||||
|
||||
req = __request_alloc(QMI_SERVICE_CONTROL, 0x00,
|
||||
QMI_CTL_SYNC,
|
||||
NULL, 0,
|
||||
qmi_device_sync_callback, func_data);
|
||||
|
||||
__request_submit(device, req);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* if the device support the QMI call SYNC over the CTL interface */
|
||||
bool qmi_device_is_sync_supported(struct qmi_device *device)
|
||||
{
|
||||
if (device == NULL)
|
||||
return false;
|
||||
|
||||
return (device->control_major > 1 ||
|
||||
(device->control_major == 1 && device->control_minor >= 5));
|
||||
}
|
||||
|
||||
static bool get_device_file_name(struct qmi_device *device,
|
||||
char *file_name, int size)
|
||||
{
|
||||
@@ -1809,7 +1932,6 @@ bool qmi_result_get_uint64(struct qmi_result *result, uint8_t type,
|
||||
struct service_create_data {
|
||||
struct discovery super;
|
||||
struct qmi_device *device;
|
||||
bool shared;
|
||||
uint8_t type;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
@@ -1880,7 +2002,6 @@ static void service_create_callback(uint16_t message, uint16_t length,
|
||||
|
||||
service->ref_count = 1;
|
||||
service->device = data->device;
|
||||
service->shared = data->shared;
|
||||
|
||||
service->type = data->type;
|
||||
service->major = data->major;
|
||||
@@ -1903,100 +2024,52 @@ done:
|
||||
__qmi_device_discovery_complete(data->device, &data->super);
|
||||
}
|
||||
|
||||
static void service_create_discover(uint8_t count,
|
||||
const struct qmi_version *list, void *user_data)
|
||||
{
|
||||
struct service_create_data *data = user_data;
|
||||
struct qmi_device *device = data->device;
|
||||
struct qmi_request *req;
|
||||
struct qmi_control_hdr *hdr;
|
||||
unsigned char client_req[] = { 0x01, 0x01, 0x00, data->type };
|
||||
unsigned int i;
|
||||
|
||||
__debug_device(device, "service create [type=%d]", data->type);
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (list[i].type == data->type) {
|
||||
data->major = list[i].major;
|
||||
data->minor = list[i].minor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
req = __request_alloc(QMI_SERVICE_CONTROL, 0x00,
|
||||
QMI_CTL_GET_CLIENT_ID, QMI_CONTROL_HDR_SIZE,
|
||||
client_req, sizeof(client_req),
|
||||
service_create_callback, data, (void **) &hdr);
|
||||
if (!req) {
|
||||
if (data->timeout > 0)
|
||||
g_source_remove(data->timeout);
|
||||
|
||||
data->timeout = g_timeout_add_seconds(0,
|
||||
service_create_reply, data);
|
||||
__qmi_device_discovery_started(device, &data->super);
|
||||
return;
|
||||
}
|
||||
|
||||
if (device->next_control_tid < 1)
|
||||
device->next_control_tid = 1;
|
||||
|
||||
hdr->type = 0x00;
|
||||
hdr->transaction = device->next_control_tid++;
|
||||
|
||||
__request_submit(device, req, hdr->transaction);
|
||||
}
|
||||
|
||||
static bool service_create(struct qmi_device *device, bool shared,
|
||||
static bool service_create(struct qmi_device *device,
|
||||
uint8_t type, qmi_create_func_t func,
|
||||
void *user_data, qmi_destroy_func_t destroy)
|
||||
{
|
||||
struct service_create_data *data;
|
||||
unsigned char client_req[] = { 0x01, 0x01, 0x00, type };
|
||||
struct qmi_request *req;
|
||||
int i;
|
||||
|
||||
data = g_try_new0(struct service_create_data, 1);
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
if (!device->version_list)
|
||||
return false;
|
||||
|
||||
data->super.destroy = service_create_data_free;
|
||||
data->device = device;
|
||||
data->shared = shared;
|
||||
data->type = type;
|
||||
data->func = func;
|
||||
data->user_data = user_data;
|
||||
data->destroy = destroy;
|
||||
|
||||
if (device->version_list) {
|
||||
service_create_discover(device->version_count,
|
||||
device->version_list, data);
|
||||
goto done;
|
||||
__debug_device(device, "service create [type=%d]", type);
|
||||
|
||||
for (i = 0; i < device->version_count; i++) {
|
||||
if (device->version_list[i].type == data->type) {
|
||||
data->major = device->version_list[i].major;
|
||||
data->minor = device->version_list[i].minor;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (qmi_device_discover(device, service_create_discover, data, NULL))
|
||||
goto done;
|
||||
req = __request_alloc(QMI_SERVICE_CONTROL, 0x00,
|
||||
QMI_CTL_GET_CLIENT_ID,
|
||||
client_req, sizeof(client_req),
|
||||
service_create_callback, data);
|
||||
|
||||
g_free(data);
|
||||
__request_submit(device, req);
|
||||
|
||||
return false;
|
||||
|
||||
done:
|
||||
data->timeout = g_timeout_add_seconds(8, service_create_reply, data);
|
||||
__qmi_device_discovery_started(device, &data->super);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool qmi_service_create(struct qmi_device *device,
|
||||
uint8_t type, qmi_create_func_t func,
|
||||
void *user_data, qmi_destroy_func_t destroy)
|
||||
{
|
||||
if (!device || !func)
|
||||
return false;
|
||||
|
||||
if (type == QMI_SERVICE_CONTROL)
|
||||
return false;
|
||||
|
||||
return service_create(device, false, type, func, user_data, destroy);
|
||||
}
|
||||
|
||||
struct service_create_shared_data {
|
||||
struct discovery super;
|
||||
struct qmi_service *service;
|
||||
@@ -2072,7 +2145,15 @@ bool qmi_service_create_shared(struct qmi_device *device,
|
||||
return 0;
|
||||
}
|
||||
|
||||
return service_create(device, true, type, func, user_data, destroy);
|
||||
return service_create(device, type, func, user_data, destroy);
|
||||
}
|
||||
|
||||
bool qmi_service_create(struct qmi_device *device,
|
||||
uint8_t type, qmi_create_func_t func,
|
||||
void *user_data, qmi_destroy_func_t destroy)
|
||||
{
|
||||
return qmi_service_create_shared(device, type, func,
|
||||
user_data, destroy);
|
||||
}
|
||||
|
||||
static void service_release_callback(uint16_t message, uint16_t length,
|
||||
@@ -2149,8 +2230,6 @@ bool qmi_service_get_version(struct qmi_service *service,
|
||||
}
|
||||
|
||||
struct service_send_data {
|
||||
struct qmi_service *service;
|
||||
struct qmi_param *param;
|
||||
qmi_result_func_t func;
|
||||
void *user_data;
|
||||
qmi_destroy_func_t destroy;
|
||||
@@ -2161,8 +2240,6 @@ static void service_send_free(struct service_send_data *data)
|
||||
if (data->destroy)
|
||||
data->destroy(data->user_data);
|
||||
|
||||
qmi_param_free(data->param);
|
||||
|
||||
g_free(data);
|
||||
}
|
||||
|
||||
@@ -2203,7 +2280,7 @@ uint16_t qmi_service_send(struct qmi_service *service,
|
||||
struct qmi_device *device;
|
||||
struct service_send_data *data;
|
||||
struct qmi_request *req;
|
||||
struct qmi_service_hdr *hdr;
|
||||
uint16_t tid;
|
||||
|
||||
if (!service)
|
||||
return 0;
|
||||
@@ -2219,31 +2296,21 @@ uint16_t qmi_service_send(struct qmi_service *service,
|
||||
if (!data)
|
||||
return 0;
|
||||
|
||||
data->service = service;
|
||||
data->param = param;
|
||||
data->func = func;
|
||||
data->user_data = user_data;
|
||||
data->destroy = destroy;
|
||||
|
||||
req = __request_alloc(service->type, service->client_id,
|
||||
message, QMI_SERVICE_HDR_SIZE,
|
||||
data->param ? data->param->data : NULL,
|
||||
data->param ? data->param->length : 0,
|
||||
service_send_callback, data, (void **) &hdr);
|
||||
if (!req) {
|
||||
g_free(data);
|
||||
return 0;
|
||||
}
|
||||
message,
|
||||
param ? param->data : NULL,
|
||||
param ? param->length : 0,
|
||||
service_send_callback, data);
|
||||
|
||||
if (device->next_service_tid < 256)
|
||||
device->next_service_tid = 256;
|
||||
qmi_param_free(param);
|
||||
|
||||
hdr->type = 0x00;
|
||||
hdr->transaction = device->next_service_tid++;
|
||||
tid = __request_submit(device, req);
|
||||
|
||||
__request_submit(device, req, hdr->transaction);
|
||||
|
||||
return hdr->transaction;
|
||||
return tid;
|
||||
}
|
||||
|
||||
bool qmi_service_cancel(struct qmi_service *service, uint16_t id)
|
||||
|
||||
@@ -61,13 +61,6 @@ enum qmi_device_expected_data_format {
|
||||
QMI_DEVICE_EXPECTED_DATA_FORMAT_RAW_IP,
|
||||
};
|
||||
|
||||
struct qmi_version {
|
||||
uint8_t type;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
void qmi_free(void *ptr);
|
||||
|
||||
typedef void (*qmi_destroy_func_t)(void *user_data);
|
||||
@@ -76,10 +69,9 @@ typedef void (*qmi_destroy_func_t)(void *user_data);
|
||||
struct qmi_device;
|
||||
|
||||
typedef void (*qmi_debug_func_t)(const char *str, void *user_data);
|
||||
|
||||
typedef void (*qmi_sync_func_t)(void *user_data);
|
||||
typedef void (*qmi_shutdown_func_t)(void *user_data);
|
||||
typedef void (*qmi_discover_func_t)(uint8_t count,
|
||||
const struct qmi_version *list, void *user_data);
|
||||
typedef void (*qmi_discover_func_t)(void *user_data);
|
||||
|
||||
struct qmi_device *qmi_device_new(int fd);
|
||||
|
||||
@@ -96,6 +88,14 @@ bool qmi_device_discover(struct qmi_device *device, qmi_discover_func_t func,
|
||||
bool qmi_device_shutdown(struct qmi_device *device, qmi_shutdown_func_t func,
|
||||
void *user_data, qmi_destroy_func_t destroy);
|
||||
|
||||
bool qmi_device_has_service(struct qmi_device *device, uint8_t type);
|
||||
bool qmi_device_get_service_version(struct qmi_device *device, uint8_t type,
|
||||
uint16_t *major, uint16_t *minor);
|
||||
|
||||
bool qmi_device_sync(struct qmi_device *device,
|
||||
qmi_sync_func_t func, void *user_data);
|
||||
bool qmi_device_is_sync_supported(struct qmi_device *device);
|
||||
|
||||
enum qmi_device_expected_data_format qmi_device_get_expected_data_format(
|
||||
struct qmi_device *device);
|
||||
bool qmi_device_set_expected_data_format(struct qmi_device *device,
|
||||
@@ -140,6 +140,8 @@ bool qmi_result_get_uint64(struct qmi_result *result, uint8_t type,
|
||||
uint64_t *value);
|
||||
void qmi_result_print_tlvs(struct qmi_result *result);
|
||||
|
||||
int qmi_error_to_ofono_cme(int qmi_error);
|
||||
|
||||
struct qmi_service;
|
||||
|
||||
typedef void (*qmi_result_func_t)(struct qmi_result *result, void *user_data);
|
||||
|
||||
@@ -39,6 +39,7 @@ static int qmimodem_init(void)
|
||||
qmi_ussd_init();
|
||||
qmi_gprs_init();
|
||||
qmi_gprs_context_init();
|
||||
qmi_lte_init();
|
||||
qmi_radio_settings_init();
|
||||
qmi_location_reporting_init();
|
||||
qmi_netmon_init();
|
||||
@@ -51,6 +52,7 @@ static void qmimodem_exit(void)
|
||||
qmi_netmon_exit();
|
||||
qmi_location_reporting_exit();
|
||||
qmi_radio_settings_exit();
|
||||
qmi_lte_exit();
|
||||
qmi_gprs_context_exit();
|
||||
qmi_gprs_exit();
|
||||
qmi_ussd_exit();
|
||||
|
||||
@@ -48,6 +48,9 @@ extern void qmi_gprs_exit(void);
|
||||
extern void qmi_gprs_context_init(void);
|
||||
extern void qmi_gprs_context_exit(void);
|
||||
|
||||
extern void qmi_lte_init(void);
|
||||
extern void qmi_lte_exit(void);
|
||||
|
||||
extern void qmi_radio_settings_init(void);
|
||||
extern void qmi_radio_settings_exit(void);
|
||||
|
||||
|
||||
@@ -277,6 +277,9 @@ static void qmi_radio_settings_remove(struct ofono_radio_settings *rs)
|
||||
|
||||
ofono_radio_settings_set_data(rs, NULL);
|
||||
|
||||
qmi_service_unregister_all(data->dms);
|
||||
qmi_service_unref(data->dms);
|
||||
|
||||
qmi_service_unregister_all(data->nas);
|
||||
|
||||
qmi_service_unref(data->nas);
|
||||
|
||||
@@ -493,8 +493,15 @@ static bool get_card_status(const struct qmi_uim_slot_info *slot,
|
||||
case 0x03: /* PUK1 or PUK for UPIN is required */
|
||||
sim_stat->passwd_state = OFONO_SIM_PASSWORD_SIM_PUK;
|
||||
break;
|
||||
case 0x00: /* Unknown */
|
||||
case 0x01: /* Detected */
|
||||
case 0x04: /* Personalization state must be checked. */
|
||||
/* This is temporary, we could retry and get another result */
|
||||
case 0x05: /* PIN1 blocked */
|
||||
case 0x06: /* Illegal */
|
||||
/*
|
||||
* This could be temporary, we should retry and
|
||||
* expect another result
|
||||
*/
|
||||
sim_stat->passwd_state = OFONO_SIM_PASSWORD_INVALID;
|
||||
need_retry = true;
|
||||
break;
|
||||
@@ -557,7 +564,7 @@ static enum get_card_status_result handle_get_card_status_result(
|
||||
|
||||
index = GUINT16_FROM_LE(status->index_gw_pri);
|
||||
|
||||
if ((index & 0xff) == i && (index >> 8) == n) {
|
||||
if ((index & 0xff) == n && (index >> 8) == i) {
|
||||
if (get_card_status(slot, info1, info2,
|
||||
sim_stat))
|
||||
res = GET_CARD_STATUS_RESULT_TEMP_ERROR;
|
||||
@@ -595,20 +602,32 @@ static void query_passwd_state_cb(struct qmi_result *result,
|
||||
struct sim_status sim_stat;
|
||||
enum get_card_status_result res;
|
||||
struct cb_data *retry_cbd;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
|
||||
sim_stat.retries[i] = -1;
|
||||
|
||||
res = handle_get_card_status_result(result, &sim_stat);
|
||||
switch (res) {
|
||||
case GET_CARD_STATUS_RESULT_OK:
|
||||
DBG("passwd state %d", sim_stat.passwd_state);
|
||||
data->retry_count = 0;
|
||||
CALLBACK_WITH_SUCCESS(cb, sim_stat.passwd_state, cbd->data);
|
||||
if (sim_stat.passwd_state == OFONO_SIM_PASSWORD_INVALID) {
|
||||
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
|
||||
ofono_sim_inserted_notify(sim, FALSE);
|
||||
} else
|
||||
CALLBACK_WITH_SUCCESS(cb, sim_stat.passwd_state,
|
||||
cbd->data);
|
||||
break;
|
||||
case GET_CARD_STATUS_RESULT_TEMP_ERROR:
|
||||
data->retry_count++;
|
||||
if (data->retry_count > MAX_RETRY_COUNT) {
|
||||
DBG("Failed after %d attempts", data->retry_count);
|
||||
DBG("Failed after %d attempts. Card state:%d",
|
||||
data->retry_count,
|
||||
sim_stat.card_state);
|
||||
data->retry_count = 0;
|
||||
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
|
||||
ofono_sim_inserted_notify(sim, FALSE);
|
||||
} else {
|
||||
DBG("Retry command");
|
||||
retry_cbd = cb_data_new(cb, cbd->data);
|
||||
@@ -622,6 +641,7 @@ static void query_passwd_state_cb(struct qmi_result *result,
|
||||
DBG("Command failed");
|
||||
data->retry_count = 0;
|
||||
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
|
||||
ofono_sim_inserted_notify(sim, FALSE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -650,9 +670,13 @@ static void query_pin_retries_cb(struct qmi_result *result, void *user_data)
|
||||
struct cb_data *cbd = user_data;
|
||||
ofono_sim_pin_retries_cb_t cb = cbd->cb;
|
||||
struct sim_status sim_stat;
|
||||
unsigned int i;
|
||||
|
||||
DBG("");
|
||||
|
||||
for (i = 0; i < OFONO_SIM_PASSWORD_INVALID; i++)
|
||||
sim_stat.retries[i] = -1;
|
||||
|
||||
if (handle_get_card_status_result(result, &sim_stat) !=
|
||||
GET_CARD_STATUS_RESULT_OK) {
|
||||
CALLBACK_WITH_FAILURE(cb, NULL, cbd->data);
|
||||
|
||||
@@ -334,9 +334,38 @@ error:
|
||||
g_free(cbd);
|
||||
}
|
||||
|
||||
static void raw_read_cb(struct qmi_result *result, void *user_data)
|
||||
{
|
||||
struct ofono_sms *sms = user_data;
|
||||
const struct qmi_wms_raw_message* msg;
|
||||
uint16_t len;
|
||||
uint16_t error;
|
||||
|
||||
if (qmi_result_set_error(result, &error)) {
|
||||
DBG("Raw read error: %d (%s)", error,
|
||||
qmi_result_get_error(result));
|
||||
return;
|
||||
}
|
||||
|
||||
/* Raw message data */
|
||||
msg = qmi_result_get(result, 0x01, &len);
|
||||
if (msg) {
|
||||
uint16_t plen;
|
||||
uint16_t tpdu_len;
|
||||
|
||||
plen = GUINT16_FROM_LE(msg->msg_length);
|
||||
tpdu_len = plen - msg->msg_data[0] - 1;
|
||||
|
||||
ofono_sms_deliver_notify(sms, msg->msg_data, plen, tpdu_len);
|
||||
} else {
|
||||
DBG("No message data available at requested position");
|
||||
}
|
||||
}
|
||||
|
||||
static void event_notify(struct qmi_result *result, void *user_data)
|
||||
{
|
||||
struct ofono_sms *sms = user_data;
|
||||
struct sms_data *data = ofono_sms_get_data(sms);
|
||||
const struct qmi_wms_result_new_msg_notify *notify;
|
||||
const struct qmi_wms_result_message *message;
|
||||
uint16_t len;
|
||||
@@ -360,6 +389,34 @@ static void event_notify(struct qmi_result *result, void *user_data)
|
||||
DBG("msg format %d PDU length %d", message->msg_format, plen);
|
||||
|
||||
ofono_sms_deliver_notify(sms, message->msg_data, plen, plen);
|
||||
} else {
|
||||
/* The Quectel EC21, at least, does not provide the
|
||||
* message data in the event notification, so a 'raw read'
|
||||
* needs to be issued in order to query the message itself
|
||||
*/
|
||||
struct qmi_param *param;
|
||||
|
||||
param = qmi_param_new();
|
||||
if (!param)
|
||||
return;
|
||||
|
||||
/* Message memory storage ID */
|
||||
qmi_param_append(param, 0x01, sizeof(*notify), notify);
|
||||
/* The 'message mode' parameter is documented as optional,
|
||||
* but the Quectel EC21 errors out with error 17 (missing
|
||||
* argument) if it is not provided... we default to 3GPP
|
||||
* here because that's what works for me and it's not clear
|
||||
* how to actually query what this should be otherwise...
|
||||
*/
|
||||
/* Message mode */
|
||||
qmi_param_append_uint8(param, 0x10,
|
||||
QMI_WMS_MESSAGE_MODE_GSMWCDMA);
|
||||
|
||||
if (qmi_service_send(data->wms, QMI_WMS_RAW_READ, param,
|
||||
raw_read_cb, sms, NULL) > 0)
|
||||
return;
|
||||
|
||||
qmi_param_free(param);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2011-2012 Intel Corporation. All rights reserved.
|
||||
* Copyright (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
@@ -23,20 +24,103 @@
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#define _GNU_SOURCE
|
||||
#include <string.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <ofono/log.h>
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/ussd.h>
|
||||
|
||||
#include <smsutil.h>
|
||||
#include "qmi.h"
|
||||
|
||||
#include "qmimodem.h"
|
||||
|
||||
#include "voice.h"
|
||||
|
||||
struct ussd_data {
|
||||
struct qmi_service *voice;
|
||||
uint16_t major;
|
||||
uint16_t minor;
|
||||
};
|
||||
|
||||
static int validate_ussd_data(const struct qmi_ussd_data *data, uint16_t size)
|
||||
{
|
||||
if (data == NULL)
|
||||
return 1;
|
||||
|
||||
if (size < sizeof(*data))
|
||||
return 1;
|
||||
|
||||
if (size < sizeof(*data) + data->length)
|
||||
return 1;
|
||||
|
||||
if (data->dcs < QMI_USSD_DCS_ASCII || data->dcs > QMI_USSD_DCS_UCS2)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int convert_qmi_dcs_gsm_dcs(int qmi_dcs, int *gsm_dcs)
|
||||
{
|
||||
switch (qmi_dcs) {
|
||||
case QMI_USSD_DCS_ASCII:
|
||||
*gsm_dcs = USSD_DCS_8BIT;
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void async_orig_ind(struct qmi_result *result, void *user_data)
|
||||
{
|
||||
struct ofono_ussd *ussd = user_data;
|
||||
const struct qmi_ussd_data *qmi_ussd;
|
||||
uint16_t error = 0;
|
||||
uint16_t len;
|
||||
int gsm_dcs;
|
||||
|
||||
DBG("");
|
||||
|
||||
qmi_result_get_uint16(result, QMI_VOICE_PARAM_ASYNC_USSD_ERROR, &error);
|
||||
|
||||
switch (error) {
|
||||
case 0:
|
||||
/* no error */
|
||||
break;
|
||||
case 92:
|
||||
qmi_result_get_uint16(result,
|
||||
QMI_VOICE_PARAM_ASYNC_USSD_FAILURE_CASE,
|
||||
&error);
|
||||
DBG("Failure Cause: 0x%04x", error);
|
||||
goto error;
|
||||
default:
|
||||
DBG("USSD Error 0x%04x", error);
|
||||
goto error;
|
||||
}
|
||||
|
||||
qmi_ussd = qmi_result_get(result, QMI_VOICE_PARAM_ASYNC_USSD_DATA,
|
||||
&len);
|
||||
if (qmi_ussd == NULL)
|
||||
return;
|
||||
|
||||
if (validate_ussd_data(qmi_ussd, len))
|
||||
goto error;
|
||||
|
||||
if (convert_qmi_dcs_gsm_dcs(qmi_ussd->dcs, &gsm_dcs))
|
||||
goto error;
|
||||
|
||||
ofono_ussd_notify(ussd, OFONO_USSD_STATUS_NOTIFY, gsm_dcs,
|
||||
qmi_ussd->data, qmi_ussd->length);
|
||||
return;
|
||||
|
||||
error:
|
||||
ofono_ussd_notify(ussd, OFONO_USSD_STATUS_TERMINATED, 0, NULL, 0);
|
||||
}
|
||||
|
||||
static void create_voice_cb(struct qmi_service *service, void *user_data)
|
||||
{
|
||||
struct ofono_ussd *ussd = user_data;
|
||||
@@ -44,7 +128,7 @@ static void create_voice_cb(struct qmi_service *service, void *user_data)
|
||||
|
||||
DBG("");
|
||||
|
||||
if (!service) {
|
||||
if (service == NULL) {
|
||||
ofono_error("Failed to request Voice service");
|
||||
ofono_ussd_remove(ussd);
|
||||
return;
|
||||
@@ -58,6 +142,9 @@ static void create_voice_cb(struct qmi_service *service, void *user_data)
|
||||
|
||||
data->voice = qmi_service_ref(service);
|
||||
|
||||
qmi_service_register(data->voice, QMI_VOICE_ASYNC_ORIG_USSD,
|
||||
async_orig_ind, ussd, NULL);
|
||||
|
||||
ofono_ussd_register(ussd);
|
||||
}
|
||||
|
||||
@@ -77,7 +164,6 @@ static int qmi_ussd_probe(struct ofono_ussd *ussd,
|
||||
create_voice_cb, ussd, NULL);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static void qmi_ussd_remove(struct ofono_ussd *ussd)
|
||||
@@ -93,10 +179,103 @@ static void qmi_ussd_remove(struct ofono_ussd *ussd)
|
||||
g_free(data);
|
||||
}
|
||||
|
||||
static void qmi_ussd_cancel(struct ofono_ussd *ussd,
|
||||
ofono_ussd_cb_t cb, void *user_data)
|
||||
{
|
||||
struct ussd_data *ud = ofono_ussd_get_data(ussd);
|
||||
|
||||
DBG("");
|
||||
|
||||
if (qmi_service_send(ud->voice, QMI_VOICE_CANCEL_USSD, NULL,
|
||||
NULL, NULL, NULL) > 0)
|
||||
CALLBACK_WITH_SUCCESS(cb, user_data);
|
||||
else
|
||||
CALLBACK_WITH_FAILURE(cb, user_data);
|
||||
}
|
||||
|
||||
/*
|
||||
* The cb is called when the request (on modem layer) reports success or
|
||||
* failure. It doesn't contain a network result. We get the network answer
|
||||
* via VOICE_IND.
|
||||
*/
|
||||
static void qmi_ussd_request_cb(struct qmi_result *result, void *user_data)
|
||||
{
|
||||
struct cb_data *cbd = user_data;
|
||||
ofono_ussd_cb_t cb = cbd->cb;
|
||||
|
||||
DBG("");
|
||||
|
||||
qmi_result_print_tlvs(result);
|
||||
|
||||
if (qmi_result_set_error(result, NULL)) {
|
||||
CALLBACK_WITH_FAILURE(cb, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
CALLBACK_WITH_SUCCESS(cb, cbd->data);
|
||||
}
|
||||
|
||||
static void qmi_ussd_request(struct ofono_ussd *ussd, int dcs,
|
||||
const unsigned char *pdu, int len,
|
||||
ofono_ussd_cb_t cb, void *data)
|
||||
{
|
||||
struct ussd_data *ud = ofono_ussd_get_data(ussd);
|
||||
struct cb_data *cbd = cb_data_new(cb, data);
|
||||
struct qmi_ussd_data *qmi_ussd;
|
||||
struct qmi_param *param;
|
||||
char *utf8 = NULL;
|
||||
long utf8_len = 0;
|
||||
|
||||
DBG("");
|
||||
|
||||
switch (dcs) {
|
||||
case 0xf: /* 7bit GSM unspecific */
|
||||
utf8 = ussd_decode(dcs, len, pdu);
|
||||
if (!utf8)
|
||||
goto error;
|
||||
|
||||
utf8_len = strlen(utf8);
|
||||
break;
|
||||
default:
|
||||
DBG("Unsupported USSD Data Coding Scheme 0x%x", dcs);
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* So far only DCS_ASCII works.
|
||||
* DCS_8BIT and DCS_UCS2 is broken, because the modem firmware
|
||||
* (least on a EC20) encodes those in-correctly onto the air interface,
|
||||
* resulting in wrong decoded USSD data.
|
||||
*/
|
||||
qmi_ussd = alloca(sizeof(struct qmi_ussd_data) + utf8_len);
|
||||
qmi_ussd->dcs = QMI_USSD_DCS_ASCII;
|
||||
qmi_ussd->length = len;
|
||||
memcpy(qmi_ussd->data, utf8, utf8_len);
|
||||
g_free(utf8);
|
||||
|
||||
param = qmi_param_new();
|
||||
if (param == NULL)
|
||||
goto error;
|
||||
|
||||
qmi_param_append(param, QMI_VOICE_PARAM_USS_DATA,
|
||||
sizeof(struct qmi_ussd_data) + utf8_len, qmi_ussd);
|
||||
|
||||
if (qmi_service_send(ud->voice, QMI_VOICE_ASYNC_ORIG_USSD, param,
|
||||
qmi_ussd_request_cb, cbd, g_free) > 0)
|
||||
return;
|
||||
|
||||
qmi_param_free(param);
|
||||
error:
|
||||
g_free(cbd);
|
||||
CALLBACK_WITH_FAILURE(cb, data);
|
||||
}
|
||||
|
||||
static struct ofono_ussd_driver driver = {
|
||||
.name = "qmimodem",
|
||||
.probe = qmi_ussd_probe,
|
||||
.remove = qmi_ussd_remove,
|
||||
.request = qmi_ussd_request,
|
||||
.cancel = qmi_ussd_cancel
|
||||
};
|
||||
|
||||
void qmi_ussd_init(void)
|
||||
|
||||
@@ -39,6 +39,15 @@ static inline struct cb_data *cb_data_new(void *cb, void *data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define CALLBACK_WITH_CME_ERROR(cb, err, args...) \
|
||||
do { \
|
||||
struct ofono_error cb_e; \
|
||||
cb_e.type = OFONO_ERROR_TYPE_CME; \
|
||||
cb_e.error = err; \
|
||||
\
|
||||
cb(&cb_e, ##args); \
|
||||
} while (0) \
|
||||
|
||||
#define CALLBACK_WITH_FAILURE(cb, args...) \
|
||||
do { \
|
||||
struct ofono_error cb_e; \
|
||||
|
||||
62
ofono/drivers/qmimodem/voice.h
Normal file
62
ofono/drivers/qmimodem/voice.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
*
|
||||
* oFono - Open Source Telephony
|
||||
*
|
||||
* Copyright (C) 2017 by sysmocom s.f.m.c. GmbH <info@sysmocom.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
*/
|
||||
|
||||
#define QMI_VOICE_PARAM_USS_DATA 0x01
|
||||
|
||||
#define QMI_VOICE_PARAM_ASYNC_USSD_ERROR 0x10
|
||||
#define QMI_VOICE_PARAM_ASYNC_USSD_FAILURE_CASE 0x11
|
||||
#define QMI_VOICE_PARAM_ASYNC_USSD_DATA 0x12
|
||||
|
||||
#define QMI_VOICE_PARAM_USSD_IND_USER_ACTION 0x01
|
||||
#define QMI_VOICE_PARAM_USSD_IND_DATA 0x10
|
||||
#define QMI_VOICE_PARAM_USSD_IND_UCS2 0x11
|
||||
|
||||
/* according to GSM TS 23.038 section 5
|
||||
* coding group 1111, No message class, 8 bit data
|
||||
*/
|
||||
#define USSD_DCS_8BIT 0xf4
|
||||
/* coding group 01xx, Class 0, UCS2 (16 bit) */
|
||||
#define USSD_DCS_UCS2 0x48
|
||||
/* default alphabet Language unspecific */
|
||||
#define USSD_DCS_UNSPECIFIC 0x0f
|
||||
|
||||
/* based on qmi ussd definition */
|
||||
enum qmi_ussd_dcs {
|
||||
QMI_USSD_DCS_ASCII = 0x1,
|
||||
QMI_USSD_DCS_8BIT,
|
||||
QMI_USSD_DCS_UCS2,
|
||||
};
|
||||
|
||||
enum qmi_ussd_user_required {
|
||||
QMI_USSD_NO_USER_ACTION_REQUIRED = 0x1,
|
||||
QMI_USSD_USER_ACTION_REQUIRED,
|
||||
};
|
||||
|
||||
/* QMI service voice. Using an enum to prevent doublicated entries */
|
||||
enum voice_commands {
|
||||
QMI_VOICE_CANCEL_USSD = 0x3c,
|
||||
QMI_VOICE_USSD_RELEASE_IND = 0x3d,
|
||||
QMI_VOICE_USSD_IND = 0x3e,
|
||||
QMI_VOICE_SUPS_IND = 0x42,
|
||||
QMI_VOICE_ASYNC_ORIG_USSD = 0x43,
|
||||
};
|
||||
|
||||
struct qmi_ussd_data {
|
||||
uint8_t dcs;
|
||||
uint8_t length;
|
||||
uint8_t data[0];
|
||||
} __attribute__((__packed__));
|
||||
@@ -25,6 +25,8 @@
|
||||
|
||||
#define QMI_WMS_RAW_SEND 32 /* Send a raw message */
|
||||
|
||||
#define QMI_WMS_RAW_READ 34 /* Read raw message from storage*/
|
||||
|
||||
#define QMI_WMS_GET_MSG_LIST 49 /* Get list of messages from the device */
|
||||
#define QMI_WMS_SET_ROUTES 50 /* Set routes for message memory storage */
|
||||
#define QMI_WMS_GET_ROUTES 51 /* Get routes for message memory storage */
|
||||
@@ -66,6 +68,13 @@ struct qmi_wms_param_message {
|
||||
|
||||
#define QMI_WMS_MESSAGE_MODE_GSMWCDMA 1
|
||||
|
||||
struct qmi_wms_raw_message {
|
||||
uint8_t msg_tag;
|
||||
uint8_t msg_format;
|
||||
uint16_t msg_length;
|
||||
uint8_t msg_data[0];
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/* Get routes for message memory storage */
|
||||
#define QMI_WMS_RESULT_ROUTE_LIST 0x01
|
||||
#define QMI_WMS_PARAM_ROUTE_LIST 0x01
|
||||
|
||||
@@ -1,280 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_sim_card.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/* See 3GPP 27.007 7.4 for possible values */
|
||||
#define RIL_MAX_SERVICE_LENGTH 3
|
||||
|
||||
/*
|
||||
* ril.h does not state that string count must be given, but that is
|
||||
* still expected by the modem
|
||||
*/
|
||||
#define RIL_SET_STRING_COUNT 5
|
||||
#define RIL_SET_PW_STRING_COUNT 3
|
||||
|
||||
struct ril_call_barring {
|
||||
struct ril_sim_card *card;
|
||||
GRilIoQueue *q;
|
||||
guint timer_id;
|
||||
};
|
||||
|
||||
struct ril_call_barring_cbd {
|
||||
struct ril_call_barring *bd;
|
||||
union _ofono_call_barring_cb {
|
||||
ofono_call_barring_query_cb_t query;
|
||||
ofono_call_barring_set_cb_t set;
|
||||
gpointer ptr;
|
||||
} cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
#define ril_call_barring_cbd_free g_free
|
||||
|
||||
static inline struct ril_call_barring *ril_call_barring_get_data(
|
||||
struct ofono_call_barring *b)
|
||||
{
|
||||
return ofono_call_barring_get_data(b);
|
||||
}
|
||||
|
||||
static struct ril_call_barring_cbd *ril_call_barring_cbd_new(
|
||||
struct ril_call_barring *bd, void *cb, void *data)
|
||||
{
|
||||
struct ril_call_barring_cbd *cbd;
|
||||
|
||||
cbd = g_new0(struct ril_call_barring_cbd, 1);
|
||||
cbd->bd = bd;
|
||||
cbd->cb.ptr = cb;
|
||||
cbd->data = data;
|
||||
return cbd;
|
||||
}
|
||||
|
||||
static inline void ril_call_barring_submit_request(struct ril_call_barring *bd,
|
||||
GRilIoRequest* req, guint code, GRilIoChannelResponseFunc response,
|
||||
void *cb, void *data)
|
||||
{
|
||||
grilio_queue_send_request_full(bd->q, req, code, response,
|
||||
ril_call_barring_cbd_free,
|
||||
ril_call_barring_cbd_new(bd, cb, data));
|
||||
}
|
||||
|
||||
static void ril_call_barring_query_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_call_barring_cbd *cbd = user_data;
|
||||
ofono_call_barring_query_cb_t cb = cbd->cb.query;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
int bearer_class = 0;
|
||||
GRilIoParser rilp;
|
||||
|
||||
/*
|
||||
* Services for which the specified barring facility is active.
|
||||
* "0" means "disabled for all, -1 if unknown"
|
||||
*/
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
grilio_parser_get_int32(&rilp, NULL); /* count */
|
||||
grilio_parser_get_int32(&rilp, &bearer_class);
|
||||
DBG("Active services: %d", bearer_class);
|
||||
cb(ril_error_ok(&error), bearer_class, cbd->data);
|
||||
} else {
|
||||
ofono_error("Call Barring query error %d", status);
|
||||
cb(ril_error_failure(&error), 0, cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_call_barring_query(struct ofono_call_barring *b,
|
||||
const char *lock, int cls,
|
||||
ofono_call_barring_query_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_call_barring *bd = ofono_call_barring_get_data(b);
|
||||
char cls_textual[RIL_MAX_SERVICE_LENGTH];
|
||||
GRilIoRequest *req;
|
||||
|
||||
DBG("lock: %s, services to query: %d", lock, cls);
|
||||
|
||||
/*
|
||||
* RIL modems do not support 7 as default bearer class. According to
|
||||
* the 22.030 Annex C: When service code is not given it corresponds to
|
||||
* "All tele and bearer services"
|
||||
*/
|
||||
if (cls == BEARER_CLASS_DEFAULT) {
|
||||
cls = SERVICE_CLASS_NONE;
|
||||
}
|
||||
|
||||
sprintf(cls_textual, "%d", cls);
|
||||
|
||||
/*
|
||||
* See 3GPP 27.007 7.4 for parameter descriptions.
|
||||
*/
|
||||
req = grilio_request_array_utf8_new(4, lock, "", cls_textual,
|
||||
ril_sim_card_app_aid(bd->card));
|
||||
ril_call_barring_submit_request(bd, req,
|
||||
RIL_REQUEST_QUERY_FACILITY_LOCK,
|
||||
ril_call_barring_query_cb, cb, data);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_call_barring_set_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_call_barring_cbd *cbd = user_data;
|
||||
ofono_call_barring_set_cb_t cb = cbd->cb.set;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
cb(ril_error_ok(&error), cbd->data);
|
||||
} else {
|
||||
ofono_error("Call Barring Set error %d", status);
|
||||
cb(ril_error_failure(&error), cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_call_barring_set(struct ofono_call_barring *b,
|
||||
const char *lock, int enable, const char *passwd, int cls,
|
||||
ofono_call_barring_set_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_call_barring *bd = ofono_call_barring_get_data(b);
|
||||
char cls_textual[RIL_MAX_SERVICE_LENGTH];
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
DBG("lock: %s, enable: %i, bearer class: %i", lock, enable, cls);
|
||||
|
||||
/*
|
||||
* RIL modem does not support 7 as default bearer class. According to
|
||||
* the 22.030 Annex C: When service code is not given it corresponds to
|
||||
* "All tele and bearer services"
|
||||
*/
|
||||
if (cls == BEARER_CLASS_DEFAULT) {
|
||||
cls = SERVICE_CLASS_NONE;
|
||||
}
|
||||
|
||||
sprintf(cls_textual, "%d", cls);
|
||||
|
||||
/* See 3GPP 27.007 7.4 for parameter descriptions */
|
||||
grilio_request_append_int32(req, RIL_SET_STRING_COUNT);
|
||||
grilio_request_append_utf8(req, lock); /* Facility code */
|
||||
grilio_request_append_utf8(req, enable ?
|
||||
RIL_FACILITY_LOCK :
|
||||
RIL_FACILITY_UNLOCK);
|
||||
grilio_request_append_utf8(req, passwd);
|
||||
grilio_request_append_utf8(req, cls_textual);
|
||||
grilio_request_append_utf8(req, ril_sim_card_app_aid(bd->card));
|
||||
|
||||
ril_call_barring_submit_request(bd, req,
|
||||
RIL_REQUEST_SET_FACILITY_LOCK,
|
||||
ril_call_barring_set_cb, cb, data);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_call_barring_set_passwd_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_call_barring_cbd *cbd = user_data;
|
||||
ofono_call_barring_set_cb_t cb = cbd->cb.set;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
cb(ril_error_ok(&error), cbd->data);
|
||||
} else {
|
||||
ofono_error("Call Barring Set PW error %d", status);
|
||||
cb(ril_error_failure(&error), cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_call_barring_set_passwd(struct ofono_call_barring *b,
|
||||
const char *lock, const char *old_passwd,
|
||||
const char *new_passwd, ofono_call_barring_set_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct ril_call_barring *bd = ofono_call_barring_get_data(b);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
DBG("");
|
||||
grilio_request_append_int32(req, RIL_SET_PW_STRING_COUNT);
|
||||
grilio_request_append_utf8(req, lock); /* Facility code */
|
||||
grilio_request_append_utf8(req, old_passwd);
|
||||
grilio_request_append_utf8(req, new_passwd);
|
||||
|
||||
ril_call_barring_submit_request(bd, req,
|
||||
RIL_REQUEST_CHANGE_BARRING_PASSWORD,
|
||||
ril_call_barring_set_passwd_cb, cb, data);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static gboolean ril_call_barring_register(gpointer user_data)
|
||||
{
|
||||
struct ofono_call_barring *b = user_data;
|
||||
struct ril_call_barring *bd = ril_call_barring_get_data(b);
|
||||
|
||||
GASSERT(bd->timer_id);
|
||||
bd->timer_id = 0;
|
||||
ofono_call_barring_register(b);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int ril_call_barring_probe(struct ofono_call_barring *b,
|
||||
unsigned int vendor, void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_call_barring *bd = g_new0(struct ril_call_barring, 1);
|
||||
|
||||
DBG("");
|
||||
bd->card = ril_sim_card_ref(modem->sim_card);
|
||||
bd->q = grilio_queue_new(ril_modem_io(modem));
|
||||
bd->timer_id = g_idle_add(ril_call_barring_register, b);
|
||||
ofono_call_barring_set_data(b, bd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_call_barring_remove(struct ofono_call_barring *b)
|
||||
{
|
||||
struct ril_call_barring *bd = ril_call_barring_get_data(b);
|
||||
|
||||
DBG("");
|
||||
ofono_call_barring_set_data(b, NULL);
|
||||
|
||||
if (bd->timer_id > 0) {
|
||||
g_source_remove(bd->timer_id);
|
||||
}
|
||||
|
||||
ril_sim_card_unref(bd->card);
|
||||
grilio_queue_cancel_all(bd->q, FALSE);
|
||||
grilio_queue_unref(bd->q);
|
||||
g_free(bd);
|
||||
}
|
||||
|
||||
const struct ofono_call_barring_driver ril_call_barring_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_call_barring_probe,
|
||||
.remove = ril_call_barring_remove,
|
||||
.query = ril_call_barring_query,
|
||||
.set = ril_call_barring_set,
|
||||
.set_passwd = ril_call_barring_set_passwd
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,274 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
struct ril_call_forward {
|
||||
GRilIoQueue *q;
|
||||
guint timer_id;
|
||||
};
|
||||
|
||||
enum ril_call_forward_action {
|
||||
CF_ACTION_DISABLE,
|
||||
CF_ACTION_ENABLE,
|
||||
CF_ACTION_INTERROGATE,
|
||||
CF_ACTION_REGISTRATION,
|
||||
CF_ACTION_ERASURE
|
||||
};
|
||||
|
||||
#define CF_TIME_DEFAULT (0)
|
||||
|
||||
struct ril_call_forward_cbd {
|
||||
struct ril_call_forward *fd;
|
||||
union _ofono_call_forward_cb {
|
||||
ofono_call_forwarding_query_cb_t query;
|
||||
ofono_call_forwarding_set_cb_t set;
|
||||
gpointer ptr;
|
||||
} cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
static inline struct ril_call_forward *ril_call_forward_get_data(
|
||||
struct ofono_call_forwarding *cf)
|
||||
{
|
||||
return ofono_call_forwarding_get_data(cf);
|
||||
}
|
||||
|
||||
static void ril_call_forward_cbd_free(gpointer cbd)
|
||||
{
|
||||
g_slice_free(struct ril_call_forward_cbd, cbd);
|
||||
}
|
||||
|
||||
static struct ril_call_forward_cbd *ril_call_forward_cbd_new(void *cb,
|
||||
void *data)
|
||||
{
|
||||
struct ril_call_forward_cbd *cbd;
|
||||
|
||||
cbd = g_slice_new0(struct ril_call_forward_cbd);
|
||||
cbd->cb.ptr = cb;
|
||||
cbd->data = data;
|
||||
return cbd;
|
||||
}
|
||||
|
||||
static GRilIoRequest *ril_call_forward_req(enum ril_call_forward_action action,
|
||||
int type, int cls, const struct ofono_phone_number *number, int time)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
/*
|
||||
* Modem seems to respond with error to all requests
|
||||
* made with bearer class BEARER_CLASS_DEFAULT.
|
||||
*/
|
||||
if (cls == BEARER_CLASS_DEFAULT) {
|
||||
cls = SERVICE_CLASS_NONE;
|
||||
}
|
||||
|
||||
grilio_request_append_int32(req, action);
|
||||
grilio_request_append_int32(req, type);
|
||||
grilio_request_append_int32(req, cls); /* Service class */
|
||||
if (number) {
|
||||
grilio_request_append_int32(req, number->type);
|
||||
grilio_request_append_utf8(req, number->number);
|
||||
} else {
|
||||
grilio_request_append_int32(req, 0x81); /* TOA unknown */
|
||||
grilio_request_append_utf8(req, NULL); /* No number */
|
||||
}
|
||||
grilio_request_append_int32(req, time);
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
static void ril_call_forward_set_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_call_forward_cbd *cbd = user_data;
|
||||
ofono_call_forwarding_set_cb_t cb = cbd->cb.set;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
cb(ril_error_ok(&error), cbd->data);
|
||||
} else {
|
||||
ofono_error("CF setting failed");
|
||||
cb(ril_error_failure(&error), cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_call_forward_set(struct ofono_call_forwarding *cf,
|
||||
enum ril_call_forward_action cmd, int type, int cls,
|
||||
const struct ofono_phone_number *number, int time,
|
||||
ofono_call_forwarding_set_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_call_forward *fd = ril_call_forward_get_data(cf);
|
||||
GRilIoRequest *req = ril_call_forward_req(cmd, type, cls, number, time);
|
||||
|
||||
grilio_queue_send_request_full(fd->q, req, RIL_REQUEST_SET_CALL_FORWARD,
|
||||
ril_call_forward_set_cb, ril_call_forward_cbd_free,
|
||||
ril_call_forward_cbd_new(cb, data));
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_call_forward_registration(struct ofono_call_forwarding *cf,
|
||||
int type, int cls, const struct ofono_phone_number *number,
|
||||
int time, ofono_call_forwarding_set_cb_t cb, void *data)
|
||||
{
|
||||
ofono_info("cf registration");
|
||||
ril_call_forward_set(cf, CF_ACTION_REGISTRATION, type, cls,
|
||||
number, time, cb, data);
|
||||
}
|
||||
|
||||
static void ril_call_forward_erasure(struct ofono_call_forwarding *cf,
|
||||
int type, int cls, ofono_call_forwarding_set_cb_t cb, void *data)
|
||||
{
|
||||
ofono_info("cf erasure");
|
||||
ril_call_forward_set(cf, CF_ACTION_ERASURE, type, cls,
|
||||
NULL, CF_TIME_DEFAULT, cb, data);
|
||||
}
|
||||
|
||||
static void ril_call_forward_deactivate(struct ofono_call_forwarding *cf,
|
||||
int type, int cls, ofono_call_forwarding_set_cb_t cb, void *data)
|
||||
{
|
||||
ofono_info("cf disable");
|
||||
ril_call_forward_set(cf, CF_ACTION_DISABLE, type, cls,
|
||||
NULL, CF_TIME_DEFAULT, cb, data);
|
||||
}
|
||||
|
||||
static void ril_call_forward_activate(struct ofono_call_forwarding *cf,
|
||||
int type, int cls, ofono_call_forwarding_set_cb_t cb, void *data)
|
||||
{
|
||||
ofono_info("cf enable");
|
||||
ril_call_forward_set(cf, CF_ACTION_ENABLE, type, cls,
|
||||
NULL, CF_TIME_DEFAULT, cb, data);
|
||||
}
|
||||
|
||||
static void ril_call_forward_query_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_call_forward_cbd *cbd = user_data;
|
||||
ofono_call_forwarding_query_cb_t cb = cbd->cb.query;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
struct ofono_call_forwarding_condition *list = NULL;
|
||||
GRilIoParser rilp;
|
||||
int count = 0;
|
||||
int i;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
grilio_parser_get_int32(&rilp, &count);
|
||||
|
||||
list = g_new0(struct ofono_call_forwarding_condition, count);
|
||||
for (i = 0; i < count; i++) {
|
||||
struct ofono_call_forwarding_condition *fw = list + i;
|
||||
char *str;
|
||||
|
||||
grilio_parser_get_int32(&rilp, &fw->status);
|
||||
grilio_parser_get_int32(&rilp, NULL);
|
||||
grilio_parser_get_int32(&rilp, &fw->cls);
|
||||
grilio_parser_get_int32(&rilp, &fw->phone_number.type);
|
||||
str = grilio_parser_get_utf8(&rilp);
|
||||
if (str) {
|
||||
strncpy(fw->phone_number.number, str,
|
||||
OFONO_MAX_PHONE_NUMBER_LENGTH);
|
||||
fw->phone_number.number[
|
||||
OFONO_MAX_PHONE_NUMBER_LENGTH] = 0;
|
||||
g_free(str);
|
||||
}
|
||||
grilio_parser_get_int32(&rilp, &fw->time);
|
||||
}
|
||||
|
||||
cb(ril_error_ok(&error), count, list, cbd->data);
|
||||
g_free(list);
|
||||
} else {
|
||||
ofono_error("CF query failed");
|
||||
cb(ril_error_failure(&error), 0, NULL, cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_call_forward_query(struct ofono_call_forwarding *cf, int type,
|
||||
int cls, ofono_call_forwarding_query_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_call_forward *fd = ril_call_forward_get_data(cf);
|
||||
GRilIoRequest *req = ril_call_forward_req(CF_ACTION_INTERROGATE,
|
||||
type, cls, NULL, CF_TIME_DEFAULT);
|
||||
|
||||
ofono_info("cf query");
|
||||
grilio_queue_send_request_full(fd->q, req,
|
||||
RIL_REQUEST_QUERY_CALL_FORWARD_STATUS,
|
||||
ril_call_forward_query_cb, ril_call_forward_cbd_free,
|
||||
ril_call_forward_cbd_new(cb, data));
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static gboolean ril_call_forward_register(gpointer user_data)
|
||||
{
|
||||
struct ofono_call_forwarding *cf = user_data;
|
||||
struct ril_call_forward *fd = ril_call_forward_get_data(cf);
|
||||
|
||||
fd->timer_id = 0;
|
||||
ofono_call_forwarding_register(cf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int ril_call_forward_probe(struct ofono_call_forwarding *cf,
|
||||
unsigned int vendor, void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_call_forward *fd = g_try_new0(struct ril_call_forward, 1);
|
||||
|
||||
DBG("");
|
||||
fd->q = grilio_queue_new(ril_modem_io(modem));
|
||||
fd->timer_id = g_idle_add(ril_call_forward_register, cf);
|
||||
ofono_call_forwarding_set_data(cf, fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_call_forward_remove(struct ofono_call_forwarding *cf)
|
||||
{
|
||||
struct ril_call_forward *fd = ril_call_forward_get_data(cf);
|
||||
|
||||
DBG("");
|
||||
ofono_call_forwarding_set_data(cf, NULL);
|
||||
|
||||
if (fd->timer_id) {
|
||||
g_source_remove(fd->timer_id);
|
||||
}
|
||||
|
||||
grilio_queue_cancel_all(fd->q, FALSE);
|
||||
grilio_queue_unref(fd->q);
|
||||
g_free(fd);
|
||||
}
|
||||
|
||||
const struct ofono_call_forwarding_driver ril_call_forwarding_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_call_forward_probe,
|
||||
.remove = ril_call_forward_remove,
|
||||
.erasure = ril_call_forward_erasure,
|
||||
.deactivation = ril_call_forward_deactivate,
|
||||
.query = ril_call_forward_query,
|
||||
.registration = ril_call_forward_registration,
|
||||
.activation = ril_call_forward_activate
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,308 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
struct ril_call_settings {
|
||||
GRilIoQueue *q;
|
||||
guint timer_id;
|
||||
};
|
||||
|
||||
struct ril_call_settings_cbd {
|
||||
union _ofono_call_settings_cb {
|
||||
ofono_call_settings_status_cb_t status;
|
||||
ofono_call_settings_set_cb_t set;
|
||||
ofono_call_settings_clir_cb_t clir;
|
||||
gpointer ptr;
|
||||
} cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
#define ril_call_settings_cbd_free g_free
|
||||
|
||||
static inline struct ril_call_settings *ril_call_settings_get_data(
|
||||
struct ofono_call_settings *b)
|
||||
{
|
||||
return ofono_call_settings_get_data(b);
|
||||
}
|
||||
|
||||
static struct ril_call_settings_cbd *ril_call_settings_cbd_new(void *cb,
|
||||
void *data)
|
||||
{
|
||||
struct ril_call_settings_cbd *cbd;
|
||||
|
||||
cbd = g_new0(struct ril_call_settings_cbd, 1);
|
||||
cbd->cb.ptr = cb;
|
||||
cbd->data = data;
|
||||
return cbd;
|
||||
}
|
||||
|
||||
static inline void ril_call_settings_submit_req(struct ril_call_settings *sd,
|
||||
GRilIoRequest* req, guint code, GRilIoChannelResponseFunc response,
|
||||
void *cb, void *data)
|
||||
{
|
||||
grilio_queue_send_request_full(sd->q, req, code, response,
|
||||
ril_call_settings_cbd_free,
|
||||
ril_call_settings_cbd_new(cb, data));
|
||||
}
|
||||
|
||||
static void ril_call_settings_clip_query_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_call_settings_cbd *cbd = user_data;
|
||||
ofono_call_settings_status_cb_t cb = cbd->cb.status;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
GRilIoParser rilp;
|
||||
int res = 0;
|
||||
|
||||
/* data length of the response */
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
if (grilio_parser_get_int32(&rilp, &res) && res > 0) {
|
||||
grilio_parser_get_int32(&rilp, &res);
|
||||
}
|
||||
|
||||
cb(ril_error_ok(&error), res, cbd->data);
|
||||
} else {
|
||||
cb(ril_error_failure(&error), -1, cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_call_settings_set_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_call_settings_cbd *cbd = user_data;
|
||||
ofono_call_settings_set_cb_t cb = cbd->cb.set;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
cb(ril_error_ok(&error), cbd->data);
|
||||
} else {
|
||||
cb(ril_error_failure(&error), cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_call_settings_cw_set(struct ofono_call_settings *cs, int mode,
|
||||
int cls, ofono_call_settings_set_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
|
||||
GRilIoRequest *req = grilio_request_sized_new(12);
|
||||
|
||||
grilio_request_append_int32(req, 2); /* Number of params */
|
||||
grilio_request_append_int32(req, mode); /* on/off */
|
||||
|
||||
/* Modem seems to respond with error to all queries
|
||||
* or settings made with bearer class
|
||||
* BEARER_CLASS_DEFAULT. Design decision: If given
|
||||
* class is BEARER_CLASS_DEFAULT let's map it to
|
||||
* SERVICE_CLASS_VOICE effectively making it the
|
||||
* default bearer. This in line with API which is
|
||||
* contains only voice anyways.
|
||||
*/
|
||||
if (cls == BEARER_CLASS_DEFAULT) {
|
||||
cls = BEARER_CLASS_VOICE;
|
||||
}
|
||||
|
||||
grilio_request_append_int32(req, cls); /* Service class */
|
||||
|
||||
ril_call_settings_submit_req(sd, req, RIL_REQUEST_SET_CALL_WAITING,
|
||||
ril_call_settings_set_cb, cb, data);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_call_settings_cw_query_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_call_settings_cbd *cbd = user_data;
|
||||
ofono_call_settings_status_cb_t cb = cbd->cb.status;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
GRilIoParser rilp;
|
||||
int res = 0;
|
||||
int sv = 0;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
|
||||
/* first value in int[] is len so let's skip that */
|
||||
grilio_parser_get_int32(&rilp, NULL);
|
||||
|
||||
/* status of call waiting service, disabled is returned only if
|
||||
* service is not active for any service class */
|
||||
grilio_parser_get_int32(&rilp, &res);
|
||||
DBG("CW enabled/disabled: %d", res);
|
||||
|
||||
if (res > 0) {
|
||||
/* services for which call waiting is enabled,
|
||||
27.007 7.12 */
|
||||
grilio_parser_get_int32(&rilp, &sv);
|
||||
DBG("CW enabled for: %d", sv);
|
||||
}
|
||||
|
||||
cb(ril_error_ok(&error), sv, cbd->data);
|
||||
} else {
|
||||
cb(ril_error_failure(&error), -1, cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_call_settings_cw_query(struct ofono_call_settings *cs, int cls,
|
||||
ofono_call_settings_status_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
|
||||
GRilIoRequest *req = grilio_request_sized_new(8);
|
||||
|
||||
grilio_request_append_int32(req, 1); /* Number of params */
|
||||
|
||||
/*
|
||||
* RILD expects service class to be 0 as certain carriers can reject
|
||||
* the query with specific service class
|
||||
*/
|
||||
grilio_request_append_int32(req, 0);
|
||||
|
||||
ril_call_settings_submit_req(sd, req, RIL_REQUEST_QUERY_CALL_WAITING,
|
||||
ril_call_settings_cw_query_cb, cb, data);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_call_settings_clip_query(struct ofono_call_settings *cs,
|
||||
ofono_call_settings_status_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
|
||||
|
||||
ril_call_settings_submit_req(sd, NULL, RIL_REQUEST_QUERY_CLIP,
|
||||
ril_call_settings_clip_query_cb, cb, data);
|
||||
}
|
||||
|
||||
static void ril_call_settings_clir_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_call_settings_cbd *cbd = user_data;
|
||||
ofono_call_settings_clir_cb_t cb = cbd->cb.clir;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
GRilIoParser rilp;
|
||||
int override = -1, network = -1;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
/*first value in int[] is len so let's skip that*/
|
||||
grilio_parser_get_int32(&rilp, NULL);
|
||||
/* Set HideCallerId property from network */
|
||||
grilio_parser_get_int32(&rilp, &override);
|
||||
/* CallingLineRestriction indicates the state of
|
||||
the CLIR supplementary service in the network */
|
||||
grilio_parser_get_int32(&rilp, &network);
|
||||
|
||||
cb(ril_error_ok(&error), override, network, cbd->data);
|
||||
} else {
|
||||
cb(ril_error_failure(&error), -1, -1, cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_call_settings_clir_query(struct ofono_call_settings *cs,
|
||||
ofono_call_settings_clir_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
|
||||
|
||||
ril_call_settings_submit_req(sd, NULL, RIL_REQUEST_GET_CLIR,
|
||||
ril_call_settings_clir_cb, cb, data);
|
||||
}
|
||||
|
||||
static void ril_call_settings_clir_set(struct ofono_call_settings *cs,
|
||||
int mode, ofono_call_settings_set_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
|
||||
GRilIoRequest *req = grilio_request_sized_new(8);
|
||||
|
||||
grilio_request_append_int32(req, 1); /* Number of params */
|
||||
grilio_request_append_int32(req, mode); /* for outgoing calls */
|
||||
|
||||
ril_call_settings_submit_req(sd, req, RIL_REQUEST_SET_CLIR,
|
||||
ril_call_settings_set_cb, cb, data);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static gboolean ril_call_settings_register(gpointer user_data)
|
||||
{
|
||||
struct ofono_call_settings *cs = user_data;
|
||||
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
|
||||
|
||||
DBG("");
|
||||
GASSERT(sd->timer_id);
|
||||
sd->timer_id = 0;
|
||||
ofono_call_settings_register(cs);
|
||||
|
||||
/* Single-shot */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int ril_call_settings_probe(struct ofono_call_settings *cs,
|
||||
unsigned int vendor, void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_call_settings *sd = g_try_new0(struct ril_call_settings, 1);
|
||||
|
||||
DBG("");
|
||||
sd->q = grilio_queue_new(ril_modem_io(modem));
|
||||
sd->timer_id = g_idle_add(ril_call_settings_register, cs);
|
||||
ofono_call_settings_set_data(cs, sd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_call_settings_remove(struct ofono_call_settings *cs)
|
||||
{
|
||||
struct ril_call_settings *sd = ril_call_settings_get_data(cs);
|
||||
|
||||
DBG("");
|
||||
ofono_call_settings_set_data(cs, NULL);
|
||||
|
||||
if (sd->timer_id > 0) {
|
||||
g_source_remove(sd->timer_id);
|
||||
}
|
||||
|
||||
grilio_queue_cancel_all(sd->q, FALSE);
|
||||
grilio_queue_unref(sd->q);
|
||||
g_free(sd);
|
||||
}
|
||||
|
||||
const struct ofono_call_settings_driver ril_call_settings_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_call_settings_probe,
|
||||
.remove = ril_call_settings_remove,
|
||||
.clip_query = ril_call_settings_clip_query,
|
||||
.cw_query = ril_call_settings_cw_query,
|
||||
.cw_set = ril_call_settings_cw_set,
|
||||
.clir_query = ril_call_settings_clir_query,
|
||||
.clir_set = ril_call_settings_clir_set
|
||||
|
||||
/*
|
||||
* Not supported in RIL API
|
||||
* .colp_query = ril_call_settings_colp_query,
|
||||
* .colr_query = ril_call_settings_colr_query
|
||||
*/
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,150 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
struct ril_call_volume {
|
||||
struct ofono_call_volume *v;
|
||||
GRilIoQueue *q;
|
||||
guint timer_id;
|
||||
};
|
||||
|
||||
struct ril_call_volume_req {
|
||||
ofono_call_volume_cb_t cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
static inline struct ril_call_volume *ril_call_volume_get_data(
|
||||
struct ofono_call_volume *v)
|
||||
{
|
||||
return ofono_call_volume_get_data(v);
|
||||
}
|
||||
|
||||
static void ril_call_volume_mute_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_call_volume_req *cbd = user_data;
|
||||
ofono_call_volume_cb_t cb = cbd->cb;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
cb(ril_error_ok(&error), cbd->data);
|
||||
} else {
|
||||
ofono_error("Could not set the ril mute state");
|
||||
cb(ril_error_failure(&error), cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_call_volume_mute(struct ofono_call_volume *v, int muted,
|
||||
ofono_call_volume_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_call_volume *vd = ril_call_volume_get_data(v);
|
||||
struct ril_call_volume_req *cbd;
|
||||
GRilIoRequest *req = grilio_request_sized_new(8);
|
||||
|
||||
cbd = g_new(struct ril_call_volume_req, 1);
|
||||
cbd->cb = cb;
|
||||
cbd->data = data;
|
||||
|
||||
DBG("%d", muted);
|
||||
grilio_request_append_int32(req, 1);
|
||||
grilio_request_append_int32(req, muted);
|
||||
grilio_queue_send_request_full(vd->q, req, RIL_REQUEST_SET_MUTE,
|
||||
ril_call_volume_mute_cb, g_free, cbd);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_call_volume_query_mute_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_call_volume *vd = user_data;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
int muted = 0;
|
||||
GRilIoParser rilp;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
grilio_parser_get_int32(&rilp, NULL); /* Array length */
|
||||
grilio_parser_get_int32(&rilp, &muted);
|
||||
DBG("{%d}", muted);
|
||||
ofono_call_volume_set_muted(vd->v, muted);
|
||||
} else {
|
||||
ofono_error("Could not retrive the ril mute state");
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean ril_call_volume_register(gpointer user_data)
|
||||
{
|
||||
struct ril_call_volume *vd = user_data;
|
||||
|
||||
DBG("");
|
||||
GASSERT(vd->timer_id);
|
||||
vd->timer_id = 0;
|
||||
ofono_call_volume_register(vd->v);
|
||||
|
||||
/* Probe the mute state */
|
||||
grilio_queue_send_request_full(vd->q, NULL,
|
||||
RIL_REQUEST_GET_MUTE, ril_call_volume_query_mute_cb, NULL, vd);
|
||||
|
||||
/* This makes the timeout a single-shot */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int ril_call_volume_probe(struct ofono_call_volume *v,
|
||||
unsigned int vendor, void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_call_volume *vd = g_new0(struct ril_call_volume, 1);
|
||||
|
||||
DBG("");
|
||||
vd->v = v;
|
||||
vd->q = grilio_queue_new(ril_modem_io(modem));
|
||||
vd->timer_id = g_idle_add(ril_call_volume_register, vd);
|
||||
ofono_call_volume_set_data(v, vd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_call_volume_remove(struct ofono_call_volume *v)
|
||||
{
|
||||
struct ril_call_volume *vd = ril_call_volume_get_data(v);
|
||||
|
||||
DBG("");
|
||||
ofono_call_volume_set_data(v, NULL);
|
||||
|
||||
if (vd->timer_id) {
|
||||
g_source_remove(vd->timer_id);
|
||||
}
|
||||
|
||||
grilio_queue_cancel_all(vd->q, FALSE);
|
||||
grilio_queue_unref(vd->q);
|
||||
g_free(vd);
|
||||
}
|
||||
|
||||
const struct ofono_call_volume_driver ril_call_volume_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_call_volume_probe,
|
||||
.remove = ril_call_volume_remove,
|
||||
.mute = ril_call_volume_mute,
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,230 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <gutil_strv.h>
|
||||
|
||||
struct ril_cbs {
|
||||
struct ofono_cbs *cbs;
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
char *log_prefix;
|
||||
gulong event_id;
|
||||
};
|
||||
|
||||
struct ril_cbs_cbd {
|
||||
struct ril_cbs *cd;
|
||||
ofono_cbs_set_cb_t cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
#define RIL_CBS_CHECK_RETRY_MS 1000
|
||||
#define RIL_CBS_CHECK_RETRY_COUNT 30
|
||||
|
||||
#define DBG_(cd,fmt,args...) DBG("%s" fmt, (cd)->log_prefix, ##args)
|
||||
|
||||
#define ril_cbs_cbd_free g_free
|
||||
|
||||
static struct ril_cbs_cbd *ril_cbs_cbd_new(struct ril_cbs *cd,
|
||||
ofono_cbs_set_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_cbs_cbd *cbd = g_new(struct ril_cbs_cbd, 1);
|
||||
|
||||
cbd->cd = cd;
|
||||
cbd->cb = cb;
|
||||
cbd->data = data;
|
||||
return cbd;
|
||||
}
|
||||
|
||||
static void ril_cbs_request_activation(struct ril_cbs *cd,
|
||||
gboolean activate, GRilIoChannelResponseFunc response,
|
||||
GDestroyNotify destroy, void* user_data)
|
||||
{
|
||||
GRilIoRequest* req = grilio_request_sized_new(8);
|
||||
|
||||
grilio_request_append_int32(req, 1);
|
||||
grilio_request_append_int32(req, activate ? 0 :1);
|
||||
|
||||
DBG_(cd, "%sactivating CB", activate ? "" : "de");
|
||||
grilio_queue_send_request_full(cd->q, req,
|
||||
RIL_REQUEST_GSM_SMS_BROADCAST_ACTIVATION,
|
||||
response, destroy, user_data);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_cbs_set_config(struct ril_cbs *cd, const char *topics,
|
||||
GRilIoChannelResponseFunc response,
|
||||
GDestroyNotify destroy, void* user_data)
|
||||
{
|
||||
char **list = topics ? g_strsplit(topics, ",", 0) : NULL;
|
||||
int i, n = gutil_strv_length(list);
|
||||
GRilIoRequest* req = grilio_request_new();
|
||||
|
||||
grilio_request_append_int32(req, n);
|
||||
for (i = 0; i < n; i++) {
|
||||
const char *entry = list[i];
|
||||
const char *delim = strchr(entry, '-');
|
||||
int from, to;
|
||||
if (delim) {
|
||||
char **range = g_strsplit(topics, "-", 0);
|
||||
from = atoi(range[0]);
|
||||
to = atoi(range[1]);
|
||||
g_strfreev(range);
|
||||
} else {
|
||||
from = to = atoi(entry);
|
||||
}
|
||||
|
||||
grilio_request_append_int32(req, from);
|
||||
grilio_request_append_int32(req, to);
|
||||
grilio_request_append_int32(req, 0);
|
||||
grilio_request_append_int32(req, 0xff);
|
||||
grilio_request_append_int32(req, 1);
|
||||
}
|
||||
|
||||
DBG_(cd, "configuring CB");
|
||||
grilio_queue_send_request_full(cd->q, req,
|
||||
RIL_REQUEST_GSM_SET_BROADCAST_SMS_CONFIG,
|
||||
response, destroy, user_data);
|
||||
grilio_request_unref(req);
|
||||
g_strfreev(list);
|
||||
}
|
||||
|
||||
static void ril_cbs_cb(GRilIoChannel *io, int ril_status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_cbs_cbd *cbd = user_data;
|
||||
|
||||
if (cbd->cb) {
|
||||
struct ofono_error error;
|
||||
|
||||
if (ril_status == RIL_E_SUCCESS) {
|
||||
cbd->cb(ril_error_ok(&error), cbd->data);
|
||||
} else {
|
||||
cbd->cb(ril_error_failure(&error), cbd->data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,
|
||||
ofono_cbs_set_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_cbs *cd = ofono_cbs_get_data(cbs);
|
||||
|
||||
DBG_(cd, "%s", topics);
|
||||
ril_cbs_set_config(cd, topics, ril_cbs_cb, ril_cbs_cbd_free,
|
||||
ril_cbs_cbd_new(cd, cb, data));
|
||||
}
|
||||
|
||||
static void ril_cbs_clear_topics(struct ofono_cbs *cbs,
|
||||
ofono_cbs_set_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_cbs *cd = ofono_cbs_get_data(cbs);
|
||||
|
||||
DBG_(cd, "");
|
||||
ril_cbs_request_activation(cd, FALSE, ril_cbs_cb, ril_cbs_cbd_free,
|
||||
ril_cbs_cbd_new(cd, cb, data));
|
||||
}
|
||||
|
||||
static void ril_cbs_notify(GRilIoChannel *io, guint code,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_cbs *cd = user_data;
|
||||
|
||||
GASSERT(code == RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS);
|
||||
DBG_(cd, "%u bytes", len);
|
||||
ofono_cbs_notify(cd->cbs, data, len);
|
||||
}
|
||||
|
||||
static void ril_cbs_probe_done_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_cbs *cd = user_data;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
DBG_(cd, "registering for CB");
|
||||
cd->event_id = grilio_channel_add_unsol_event_handler(cd->io,
|
||||
ril_cbs_notify, RIL_UNSOL_RESPONSE_NEW_BROADCAST_SMS,
|
||||
cd);
|
||||
ofono_cbs_register(cd->cbs);
|
||||
} else {
|
||||
DBG_(cd, "failed to query CB config");
|
||||
ofono_cbs_remove(cd->cbs);
|
||||
}
|
||||
}
|
||||
|
||||
static int ril_cbs_probe(struct ofono_cbs *cbs, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_cbs *cd = g_try_new0(struct ril_cbs, 1);
|
||||
GRilIoRequest* req = grilio_request_new();
|
||||
|
||||
ofono_cbs_set_data(cbs, cd);
|
||||
cd->log_prefix = (modem->log_prefix && modem->log_prefix[0]) ?
|
||||
g_strconcat(modem->log_prefix, " ", NULL) : g_strdup("");
|
||||
cd->cbs = cbs;
|
||||
|
||||
DBG_(cd, "");
|
||||
cd->io = grilio_channel_ref(ril_modem_io(modem));
|
||||
cd->q = grilio_queue_new(cd->io);
|
||||
|
||||
/*
|
||||
* RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG often fails at startup
|
||||
* especially if other RIL requests are running in parallel. We may
|
||||
* have to retry a few times. Also, make it blocking in order to
|
||||
* improve the chance of success.
|
||||
*/
|
||||
grilio_request_set_retry(req, RIL_CBS_CHECK_RETRY_MS,
|
||||
RIL_CBS_CHECK_RETRY_COUNT);
|
||||
grilio_request_set_blocking(req, TRUE);
|
||||
grilio_queue_send_request_full(cd->q, req,
|
||||
RIL_REQUEST_GSM_GET_BROADCAST_SMS_CONFIG,
|
||||
ril_cbs_probe_done_cb, NULL, cd);
|
||||
grilio_request_unref(req);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_cbs_remove(struct ofono_cbs *cbs)
|
||||
{
|
||||
struct ril_cbs *cd = ofono_cbs_get_data(cbs);
|
||||
|
||||
DBG_(cd, "");
|
||||
ofono_cbs_set_data(cbs, NULL);
|
||||
grilio_channel_remove_handler(cd->io, cd->event_id);
|
||||
grilio_channel_unref(cd->io);
|
||||
grilio_queue_cancel_all(cd->q, FALSE);
|
||||
grilio_queue_unref(cd->q);
|
||||
g_free(cd->log_prefix);
|
||||
g_free(cd);
|
||||
}
|
||||
|
||||
const struct ofono_cbs_driver ril_cbs_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_cbs_probe,
|
||||
.remove = ril_cbs_remove,
|
||||
.set_topics = ril_cbs_set_topics,
|
||||
.clear_topics = ril_cbs_clear_topics
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,578 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_cell_info.h"
|
||||
#include "ril_sim_card.h"
|
||||
#include "ril_radio.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <grilio_channel.h>
|
||||
#include <grilio_request.h>
|
||||
#include <grilio_parser.h>
|
||||
|
||||
#include <gutil_idlepool.h>
|
||||
#include <gutil_misc.h>
|
||||
|
||||
#define DISPLAY_ON_UPDATE_RATE (1000) /* 1 sec */
|
||||
#define DISPLAY_OFF_UPDATE_RATE (60000) /* 1 min */
|
||||
#define MAX_RETRIES (5)
|
||||
|
||||
typedef GObjectClass RilCellInfoClass;
|
||||
typedef struct ril_cell_info RilCellInfo;
|
||||
|
||||
struct ril_cell_info {
|
||||
GObject object;
|
||||
struct sailfish_cell_info info;
|
||||
GRilIoChannel *io;
|
||||
MceDisplay *display;
|
||||
struct ril_radio *radio;
|
||||
struct ril_sim_card *sim_card;
|
||||
gulong display_state_event_id;
|
||||
gulong radio_state_event_id;
|
||||
gulong sim_status_event_id;
|
||||
gboolean sim_card_ready;
|
||||
char *log_prefix;
|
||||
gulong event_id;
|
||||
guint query_id;
|
||||
guint set_rate_id;
|
||||
};
|
||||
|
||||
enum ril_cell_info_signal {
|
||||
SIGNAL_CELLS_CHANGED,
|
||||
SIGNAL_COUNT
|
||||
};
|
||||
|
||||
#define SIGNAL_CELLS_CHANGED_NAME "ril-cell-info-cells-changed"
|
||||
|
||||
static guint ril_cell_info_signals[SIGNAL_COUNT] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE(RilCellInfo, ril_cell_info, G_TYPE_OBJECT)
|
||||
#define RIL_CELL_INFO_TYPE (ril_cell_info_get_type())
|
||||
#define RIL_CELL_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
|
||||
RIL_CELL_INFO_TYPE, RilCellInfo))
|
||||
|
||||
#define DBG_(self,fmt,args...) DBG("%s" fmt, (self)->log_prefix, ##args)
|
||||
|
||||
static inline void ril_cell_free(struct sailfish_cell *cell)
|
||||
{
|
||||
g_slice_free(struct sailfish_cell, cell);
|
||||
}
|
||||
|
||||
static void ril_cell_free1(gpointer cell)
|
||||
{
|
||||
ril_cell_free(cell);
|
||||
}
|
||||
|
||||
static const char *ril_cell_info_int_format(int value, const char *format)
|
||||
{
|
||||
if (value == SAILFISH_CELL_INVALID_VALUE) {
|
||||
return "";
|
||||
} else {
|
||||
static GUtilIdlePool *ril_cell_info_pool = NULL;
|
||||
GUtilIdlePool *pool = gutil_idle_pool_get(&ril_cell_info_pool);
|
||||
char *str = g_strdup_printf(format, value);
|
||||
|
||||
gutil_idle_pool_add(pool, str, g_free);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean ril_cell_info_list_identical(GSList *l1, GSList *l2)
|
||||
{
|
||||
while (l1 && l2) {
|
||||
if (memcmp(l1->data, l2->data, sizeof(struct sailfish_cell))) {
|
||||
return FALSE;
|
||||
}
|
||||
l1 = l1->next;
|
||||
l2 = l2->next;
|
||||
}
|
||||
return !l1 && !l2;
|
||||
}
|
||||
|
||||
static void ril_cell_info_update_cells(struct ril_cell_info *self, GSList *l)
|
||||
{
|
||||
if (!ril_cell_info_list_identical(self->info.cells, l)) {
|
||||
g_slist_free_full(self->info.cells, ril_cell_free1);
|
||||
self->info.cells = l;
|
||||
g_signal_emit(self, ril_cell_info_signals
|
||||
[SIGNAL_CELLS_CHANGED], 0);
|
||||
} else {
|
||||
g_slist_free_full(l, ril_cell_free1);
|
||||
}
|
||||
}
|
||||
|
||||
static struct sailfish_cell *ril_cell_info_parse_cell_gsm(GRilIoParser *rilp,
|
||||
guint version, gboolean registered)
|
||||
{
|
||||
struct sailfish_cell *cell = g_slice_new0(struct sailfish_cell);
|
||||
struct sailfish_cell_info_gsm *gsm = &cell->info.gsm;
|
||||
|
||||
/* Optional RIL_CellIdentityGsm_v12 part */
|
||||
gsm->arfcn = SAILFISH_CELL_INVALID_VALUE;
|
||||
gsm->bsic = SAILFISH_CELL_INVALID_VALUE;
|
||||
/* Optional RIL_GSM_SignalStrength_v12 part */
|
||||
gsm->timingAdvance = SAILFISH_CELL_INVALID_VALUE;
|
||||
/* RIL_CellIdentityGsm */
|
||||
if (grilio_parser_get_int32(rilp, &gsm->mcc) &&
|
||||
grilio_parser_get_int32(rilp, &gsm->mnc) &&
|
||||
grilio_parser_get_int32(rilp, &gsm->lac) &&
|
||||
grilio_parser_get_int32(rilp, &gsm->cid) &&
|
||||
(version < 12 || /* RIL_CellIdentityGsm_v12 part */
|
||||
(grilio_parser_get_int32(rilp, &gsm->arfcn) &&
|
||||
grilio_parser_get_int32(rilp, &gsm->bsic))) &&
|
||||
/* RIL_GW_SignalStrength */
|
||||
grilio_parser_get_int32(rilp, &gsm->signalStrength) &&
|
||||
grilio_parser_get_int32(rilp, &gsm->bitErrorRate) &&
|
||||
(version < 12 || /* RIL_GSM_SignalStrength_v12 part */
|
||||
grilio_parser_get_int32(rilp, &gsm->timingAdvance))) {
|
||||
DBG("[gsm] reg=%d%s%s%s%s%s%s%s%s%s", registered,
|
||||
ril_cell_info_int_format(gsm->mcc, ",mcc=%d"),
|
||||
ril_cell_info_int_format(gsm->mnc, ",mnc=%d"),
|
||||
ril_cell_info_int_format(gsm->lac, ",lac=%d"),
|
||||
ril_cell_info_int_format(gsm->cid, ",cid=%d"),
|
||||
ril_cell_info_int_format(gsm->arfcn, ",arfcn=%d"),
|
||||
ril_cell_info_int_format(gsm->bsic, ",bsic=%d"),
|
||||
ril_cell_info_int_format(gsm->signalStrength,
|
||||
",strength=%d"),
|
||||
ril_cell_info_int_format(gsm->bitErrorRate, ",err=%d"),
|
||||
ril_cell_info_int_format(gsm->timingAdvance, ",t=%d"));
|
||||
cell->type = SAILFISH_CELL_TYPE_GSM;
|
||||
cell->registered = registered;
|
||||
return cell;
|
||||
}
|
||||
|
||||
ofono_error("failed to parse GSM cell info");
|
||||
ril_cell_free(cell);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct sailfish_cell *ril_cell_info_parse_cell_wcdma(GRilIoParser *rilp,
|
||||
guint version, gboolean registered)
|
||||
{
|
||||
struct sailfish_cell *cell = g_slice_new0(struct sailfish_cell);
|
||||
struct sailfish_cell_info_wcdma *wcdma = &cell->info.wcdma;
|
||||
|
||||
/* Optional RIL_CellIdentityWcdma_v12 part */
|
||||
wcdma->uarfcn = SAILFISH_CELL_INVALID_VALUE;
|
||||
if (grilio_parser_get_int32(rilp, &wcdma->mcc) &&
|
||||
grilio_parser_get_int32(rilp, &wcdma->mnc) &&
|
||||
grilio_parser_get_int32(rilp, &wcdma->lac) &&
|
||||
grilio_parser_get_int32(rilp, &wcdma->cid) &&
|
||||
grilio_parser_get_int32(rilp, &wcdma->psc) &&
|
||||
(version < 12 || /* RIL_CellIdentityWcdma_v12 part */
|
||||
grilio_parser_get_int32(rilp, &wcdma->uarfcn)) &&
|
||||
grilio_parser_get_int32(rilp, &wcdma->signalStrength) &&
|
||||
grilio_parser_get_int32(rilp, &wcdma->bitErrorRate)) {
|
||||
DBG("[wcdma] reg=%d%s%s%s%s%s%s%s", registered,
|
||||
ril_cell_info_int_format(wcdma->mcc, ",mcc=%d"),
|
||||
ril_cell_info_int_format(wcdma->mnc, ",mnc=%d"),
|
||||
ril_cell_info_int_format(wcdma->lac, ",lac=%d"),
|
||||
ril_cell_info_int_format(wcdma->cid, ",cid=%d"),
|
||||
ril_cell_info_int_format(wcdma->psc, ",psc=%d"),
|
||||
ril_cell_info_int_format(wcdma->signalStrength,
|
||||
",strength=%d"),
|
||||
ril_cell_info_int_format(wcdma->bitErrorRate,
|
||||
",err=%d"));
|
||||
cell->type = SAILFISH_CELL_TYPE_WCDMA;
|
||||
cell->registered = registered;
|
||||
return cell;
|
||||
}
|
||||
|
||||
ofono_error("failed to parse WCDMA cell info");
|
||||
ril_cell_free(cell);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static struct sailfish_cell *ril_cell_info_parse_cell_lte(GRilIoParser *rilp,
|
||||
guint version, gboolean registered)
|
||||
{
|
||||
struct sailfish_cell *cell = g_slice_new0(struct sailfish_cell);
|
||||
struct sailfish_cell_info_lte *lte = &cell->info.lte;
|
||||
|
||||
/* Optional RIL_CellIdentityLte_v12 part */
|
||||
lte->earfcn = SAILFISH_CELL_INVALID_VALUE;
|
||||
if (grilio_parser_get_int32(rilp, <e->mcc) &&
|
||||
grilio_parser_get_int32(rilp, <e->mnc) &&
|
||||
grilio_parser_get_int32(rilp, <e->ci) &&
|
||||
grilio_parser_get_int32(rilp, <e->pci) &&
|
||||
grilio_parser_get_int32(rilp, <e->tac) &&
|
||||
(version < 12 || /* RIL_CellIdentityLte_v12 part */
|
||||
grilio_parser_get_int32(rilp, <e->earfcn)) &&
|
||||
grilio_parser_get_int32(rilp, <e->signalStrength) &&
|
||||
grilio_parser_get_int32(rilp, <e->rsrp) &&
|
||||
grilio_parser_get_int32(rilp, <e->rsrq) &&
|
||||
grilio_parser_get_int32(rilp, <e->rssnr) &&
|
||||
grilio_parser_get_int32(rilp, <e->cqi) &&
|
||||
grilio_parser_get_int32(rilp, <e->timingAdvance)) {
|
||||
DBG("[lte] reg=%d%s%s%s%s%s%s%s%s%s%s%s", registered,
|
||||
ril_cell_info_int_format(lte->mcc, ",mcc=%d"),
|
||||
ril_cell_info_int_format(lte->mnc, ",mnc=%d"),
|
||||
ril_cell_info_int_format(lte->ci, ",ci=%d"),
|
||||
ril_cell_info_int_format(lte->pci, ",pci=%d"),
|
||||
ril_cell_info_int_format(lte->tac, ",tac=%d"),
|
||||
ril_cell_info_int_format(lte->signalStrength,
|
||||
",strength=%d"),
|
||||
ril_cell_info_int_format(lte->rsrp, ",rsrp=%d"),
|
||||
ril_cell_info_int_format(lte->rsrq, ",rsrq=%d"),
|
||||
ril_cell_info_int_format(lte->rssnr, ",rssnr=%d"),
|
||||
ril_cell_info_int_format(lte->cqi, ",cqi=%d"),
|
||||
ril_cell_info_int_format(lte->timingAdvance, ",t=%d"));
|
||||
cell->type = SAILFISH_CELL_TYPE_LTE;
|
||||
cell->registered = registered;
|
||||
return cell;
|
||||
}
|
||||
|
||||
ofono_error("failed to parse LTE cell info");
|
||||
ril_cell_free(cell);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean ril_cell_info_parse_cell(GRilIoParser *rilp, guint v,
|
||||
struct sailfish_cell **cell_ptr)
|
||||
{
|
||||
int type, reg;
|
||||
|
||||
if (grilio_parser_get_int32(rilp, &type) &&
|
||||
grilio_parser_get_int32(rilp, ®) &&
|
||||
/* Skip timestamp */
|
||||
grilio_parser_get_int32_array(rilp, NULL, 3)) {
|
||||
int skip = 0;
|
||||
struct sailfish_cell *cell = NULL;
|
||||
|
||||
/* Normalize the boolean value */
|
||||
reg = (reg != FALSE);
|
||||
|
||||
switch (type) {
|
||||
case RIL_CELL_INFO_TYPE_GSM:
|
||||
cell = ril_cell_info_parse_cell_gsm(rilp, v, reg);
|
||||
break;
|
||||
case RIL_CELL_INFO_TYPE_WCDMA:
|
||||
cell = ril_cell_info_parse_cell_wcdma(rilp, v, reg);
|
||||
break;
|
||||
case RIL_CELL_INFO_TYPE_LTE:
|
||||
cell = ril_cell_info_parse_cell_lte(rilp, v, reg);
|
||||
break;
|
||||
case RIL_CELL_INFO_TYPE_CDMA:
|
||||
skip = 10;
|
||||
break;
|
||||
case RIL_CELL_INFO_TYPE_TD_SCDMA:
|
||||
skip = 6;
|
||||
break;
|
||||
default:
|
||||
skip = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cell) {
|
||||
*cell_ptr = cell;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (skip && grilio_parser_get_int32_array(rilp, NULL, skip)) {
|
||||
*cell_ptr = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
*cell_ptr = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GSList *ril_cell_info_parse_list(guint v, const void *data, guint len)
|
||||
{
|
||||
GSList *l = NULL;
|
||||
GRilIoParser rilp;
|
||||
int i, n;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
if (grilio_parser_get_int32(&rilp, &n) && n > 0) {
|
||||
struct sailfish_cell *c;
|
||||
|
||||
DBG("%d cell(s):", n);
|
||||
for (i=0; i<n && ril_cell_info_parse_cell(&rilp, v, &c); i++) {
|
||||
if (c) {
|
||||
l = g_slist_insert_sorted(l, c,
|
||||
sailfish_cell_compare_func);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GASSERT(grilio_parser_at_end(&rilp));
|
||||
return l;
|
||||
}
|
||||
|
||||
static void ril_cell_info_list_changed_cb(GRilIoChannel *io, guint code,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(user_data);
|
||||
|
||||
DBG_(self, "");
|
||||
ril_cell_info_update_cells(self, ril_cell_info_parse_list
|
||||
(io->ril_version, data, len));
|
||||
}
|
||||
|
||||
static void ril_cell_info_list_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(user_data);
|
||||
|
||||
DBG_(self, "");
|
||||
GASSERT(self->query_id);
|
||||
self->query_id = 0;
|
||||
ril_cell_info_update_cells(self, (status == RIL_E_SUCCESS) ?
|
||||
ril_cell_info_parse_list(io->ril_version, data, len) : NULL);
|
||||
}
|
||||
|
||||
static void ril_cell_info_set_rate_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(user_data);
|
||||
|
||||
DBG_(self, "");
|
||||
GASSERT(self->set_rate_id);
|
||||
self->set_rate_id = 0;
|
||||
}
|
||||
|
||||
static void ril_cell_info_query(struct ril_cell_info *self)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
grilio_request_set_retry(req, RIL_RETRY_MS, MAX_RETRIES);
|
||||
grilio_channel_cancel_request(self->io, self->query_id, FALSE);
|
||||
self->query_id = grilio_channel_send_request_full(self->io, req,
|
||||
RIL_REQUEST_GET_CELL_INFO_LIST, ril_cell_info_list_cb,
|
||||
NULL, self);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_cell_info_set_rate(struct ril_cell_info *self, int ms)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_sized_new(8);
|
||||
|
||||
grilio_request_append_int32(req, 1);
|
||||
grilio_request_append_int32(req, ms);
|
||||
grilio_request_set_retry(req, RIL_RETRY_MS, MAX_RETRIES);
|
||||
grilio_channel_cancel_request(self->io, self->set_rate_id, FALSE);
|
||||
self->set_rate_id = grilio_channel_send_request_full(self->io, req,
|
||||
RIL_REQUEST_SET_UNSOL_CELL_INFO_LIST_RATE,
|
||||
ril_cell_info_set_rate_cb, NULL, self);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_cell_info_update_rate(struct ril_cell_info *self)
|
||||
{
|
||||
if (self->sim_card_ready) {
|
||||
ril_cell_info_set_rate(self,
|
||||
(self->display->state == MCE_DISPLAY_STATE_OFF) ?
|
||||
DISPLAY_OFF_UPDATE_RATE : DISPLAY_ON_UPDATE_RATE);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_cell_info_display_state_cb(MceDisplay *display, void *arg)
|
||||
{
|
||||
ril_cell_info_update_rate(RIL_CELL_INFO(arg));
|
||||
}
|
||||
|
||||
static void ril_cell_info_refresh(struct ril_cell_info *self)
|
||||
{
|
||||
/* RIL_REQUEST_GET_CELL_INFO_LIST fails without SIM card */
|
||||
if (self->radio->state == RADIO_STATE_ON && self->sim_card_ready) {
|
||||
ril_cell_info_query(self);
|
||||
} else {
|
||||
ril_cell_info_update_cells(self, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_cell_info_radio_state_cb(struct ril_radio *radio, void *arg)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(arg);
|
||||
|
||||
DBG_(self, "%s", ril_radio_state_to_string(radio->state));
|
||||
ril_cell_info_refresh(self);
|
||||
}
|
||||
|
||||
static void ril_cell_info_sim_status_cb(struct ril_sim_card *sim, void *arg)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(arg);
|
||||
|
||||
self->sim_card_ready = ril_sim_card_ready(sim);
|
||||
DBG_(self, "%sready", self->sim_card_ready ? "" : "not ");
|
||||
ril_cell_info_refresh(self);
|
||||
ril_cell_info_update_rate(self);
|
||||
}
|
||||
|
||||
/* sailfish_cell_info interface callbacks */
|
||||
|
||||
struct ril_cell_info_signal_data {
|
||||
sailfish_cell_info_cb_t cb;
|
||||
void *arg;
|
||||
};
|
||||
|
||||
static inline struct ril_cell_info *ril_cell_info_cast
|
||||
(struct sailfish_cell_info *info)
|
||||
{
|
||||
return G_CAST(info, struct ril_cell_info, info);
|
||||
}
|
||||
|
||||
static void ril_cell_info_ref_proc(struct sailfish_cell_info *info)
|
||||
{
|
||||
g_object_ref(ril_cell_info_cast(info));
|
||||
}
|
||||
|
||||
static void ril_cell_info_unref_proc(struct sailfish_cell_info *info)
|
||||
{
|
||||
g_object_unref(ril_cell_info_cast(info));
|
||||
}
|
||||
|
||||
static void ril_cell_info_cells_changed_cb(struct ril_cell_info *self,
|
||||
void *user_data)
|
||||
{
|
||||
struct ril_cell_info_signal_data *data = user_data;
|
||||
|
||||
data->cb(&self->info, data->arg);
|
||||
}
|
||||
|
||||
static void ril_cell_info_cells_disconnect_notify(gpointer data,
|
||||
GClosure *closure)
|
||||
{
|
||||
g_slice_free1(sizeof(struct ril_cell_info_signal_data), data);
|
||||
}
|
||||
|
||||
static gulong ril_cell_info_add_cells_changed_handler_proc
|
||||
(struct sailfish_cell_info *info,
|
||||
sailfish_cell_info_cb_t cb, void *arg)
|
||||
{
|
||||
if (cb) {
|
||||
struct ril_cell_info_signal_data *data =
|
||||
g_slice_new(struct ril_cell_info_signal_data);
|
||||
|
||||
data->cb = cb;
|
||||
data->arg = arg;
|
||||
return g_signal_connect_data(ril_cell_info_cast(info),
|
||||
SIGNAL_CELLS_CHANGED_NAME,
|
||||
G_CALLBACK(ril_cell_info_cells_changed_cb),
|
||||
data, ril_cell_info_cells_disconnect_notify,
|
||||
G_CONNECT_AFTER);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_cell_info_remove_handler_proc(struct sailfish_cell_info *info,
|
||||
gulong id)
|
||||
{
|
||||
if (G_LIKELY(id)) {
|
||||
g_signal_handler_disconnect(ril_cell_info_cast(info), id);
|
||||
}
|
||||
}
|
||||
|
||||
struct sailfish_cell_info *ril_cell_info_new(GRilIoChannel *io,
|
||||
const char *log_prefix, MceDisplay *display,
|
||||
struct ril_radio *radio, struct ril_sim_card *sim_card)
|
||||
{
|
||||
static const struct sailfish_cell_info_proc ril_cell_info_proc = {
|
||||
ril_cell_info_ref_proc,
|
||||
ril_cell_info_unref_proc,
|
||||
ril_cell_info_add_cells_changed_handler_proc,
|
||||
ril_cell_info_remove_handler_proc
|
||||
};
|
||||
|
||||
struct ril_cell_info *self = g_object_new(RIL_CELL_INFO_TYPE, 0);
|
||||
|
||||
self->info.proc = &ril_cell_info_proc;
|
||||
self->io = grilio_channel_ref(io);
|
||||
self->display = mce_display_ref(display);
|
||||
self->radio = ril_radio_ref(radio);
|
||||
self->sim_card = ril_sim_card_ref(sim_card);
|
||||
self->log_prefix = (log_prefix && log_prefix[0]) ?
|
||||
g_strconcat(log_prefix, " ", NULL) : g_strdup("");
|
||||
DBG_(self, "");
|
||||
self->event_id = grilio_channel_add_unsol_event_handler(self->io,
|
||||
ril_cell_info_list_changed_cb, RIL_UNSOL_CELL_INFO_LIST, self);
|
||||
self->display_state_event_id =
|
||||
mce_display_add_state_changed_handler(display,
|
||||
ril_cell_info_display_state_cb, self);
|
||||
self->radio_state_event_id =
|
||||
ril_radio_add_state_changed_handler(radio,
|
||||
ril_cell_info_radio_state_cb, self);
|
||||
self->sim_status_event_id =
|
||||
ril_sim_card_add_status_changed_handler(self->sim_card,
|
||||
ril_cell_info_sim_status_cb, self);
|
||||
self->sim_card_ready = ril_sim_card_ready(sim_card);
|
||||
ril_cell_info_refresh(self);
|
||||
ril_cell_info_update_rate(self);
|
||||
return &self->info;
|
||||
}
|
||||
|
||||
static void ril_cell_info_init(struct ril_cell_info *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void ril_cell_info_dispose(GObject *object)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(object);
|
||||
|
||||
grilio_channel_remove_handlers(self->io, &self->event_id, 1);
|
||||
if (self->query_id) {
|
||||
grilio_channel_cancel_request(self->io, self->query_id, FALSE);
|
||||
self->query_id = 0;
|
||||
}
|
||||
if (self->set_rate_id) {
|
||||
grilio_channel_cancel_request(self->io, self->set_rate_id,
|
||||
FALSE);
|
||||
self->set_rate_id = 0;
|
||||
}
|
||||
gutil_disconnect_handlers(self->display,
|
||||
&self->display_state_event_id, 1);
|
||||
ril_radio_remove_handlers(self->radio, &self->radio_state_event_id, 1);
|
||||
ril_sim_card_remove_handlers(self->sim_card,
|
||||
&self->sim_status_event_id, 1);
|
||||
G_OBJECT_CLASS(ril_cell_info_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void ril_cell_info_finalize(GObject *object)
|
||||
{
|
||||
struct ril_cell_info *self = RIL_CELL_INFO(object);
|
||||
|
||||
DBG_(self, "");
|
||||
g_free(self->log_prefix);
|
||||
grilio_channel_unref(self->io);
|
||||
mce_display_unref(self->display);
|
||||
ril_radio_unref(self->radio);
|
||||
ril_sim_card_unref(self->sim_card);
|
||||
g_slist_free_full(self->info.cells, ril_cell_free1);
|
||||
G_OBJECT_CLASS(ril_cell_info_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void ril_cell_info_class_init(RilCellInfoClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
object_class->dispose = ril_cell_info_dispose;
|
||||
object_class->finalize = ril_cell_info_finalize;
|
||||
ril_cell_info_signals[SIGNAL_CELLS_CHANGED] =
|
||||
g_signal_new(SIGNAL_CELLS_CHANGED_NAME,
|
||||
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST,
|
||||
0, NULL, NULL, NULL, G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,52 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_CONFIG_H
|
||||
#define RIL_CONFIG_H
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
/* Utilities for parsing ril_subscription.conf */
|
||||
|
||||
#define RILCONF_SETTINGS_GROUP "Settings"
|
||||
|
||||
void ril_config_merge_files(GKeyFile *conf, const char *file);
|
||||
|
||||
char *ril_config_get_string(GKeyFile *file, const char *group,
|
||||
const char *key);
|
||||
char **ril_config_get_strings(GKeyFile *file, const char *group,
|
||||
const char *key, char delimiter);
|
||||
gboolean ril_config_get_integer(GKeyFile *file, const char *group,
|
||||
const char *key, int *value);
|
||||
gboolean ril_config_get_boolean(GKeyFile *file, const char *group,
|
||||
const char *key, gboolean *value);
|
||||
gboolean ril_config_get_flag(GKeyFile *file, const char *group,
|
||||
const char *key, int flag, int *flags);
|
||||
gboolean ril_config_get_enum(GKeyFile *file, const char *group,
|
||||
const char *key, int *result,
|
||||
const char *name, int value, ...);
|
||||
GUtilInts *ril_config_get_ints(GKeyFile *file, const char *group,
|
||||
const char *key);
|
||||
char *ril_config_ints_to_string(GUtilInts *ints, char separator);
|
||||
|
||||
#endif /* RIL_CONFIG_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,346 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Canonical Ltd.
|
||||
* Copyright (C) 2013-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef __RIL_CONSTANTS_H
|
||||
#define __RIL_CONSTANTS_H 1
|
||||
|
||||
#include <ofono/ril-constants.h>
|
||||
|
||||
#define RIL_MAX_UUID_LENGTH 64
|
||||
|
||||
/* Radio state */
|
||||
enum ril_radio_state {
|
||||
RADIO_STATE_OFF = 0,
|
||||
RADIO_STATE_UNAVAILABLE = 1,
|
||||
RADIO_STATE_SIM_NOT_READY = 2,
|
||||
RADIO_STATE_SIM_LOCKED_OR_ABSENT = 3,
|
||||
RADIO_STATE_SIM_READY = 4,
|
||||
RADIO_STATE_RUIM_NOT_READY = 5,
|
||||
RADIO_STATE_RUIM_READY = 6,
|
||||
RADIO_STATE_RUIM_LOCKED_OR_ABSENT = 7,
|
||||
RADIO_STATE_NV_NOT_READY = 8,
|
||||
RADIO_STATE_NV_READY = 9,
|
||||
RADIO_STATE_ON = 10
|
||||
};
|
||||
|
||||
/* Preferred network types */
|
||||
enum ril_pref_net_type {
|
||||
PREF_NET_TYPE_GSM_WCDMA = 0,
|
||||
PREF_NET_TYPE_GSM_ONLY = 1,
|
||||
PREF_NET_TYPE_WCDMA = 2,
|
||||
PREF_NET_TYPE_GSM_WCDMA_AUTO = 3,
|
||||
PREF_NET_TYPE_CDMA_EVDO_AUTO = 4,
|
||||
PREF_NET_TYPE_CDMA_ONLY = 5,
|
||||
PREF_NET_TYPE_EVDO_ONLY = 6,
|
||||
PREF_NET_TYPE_GSM_WCDMA_CDMA_EVDO_AUTO = 7,
|
||||
PREF_NET_TYPE_LTE_CDMA_EVDO = 8,
|
||||
PREF_NET_TYPE_LTE_GSM_WCDMA = 9,
|
||||
PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA = 10,
|
||||
PREF_NET_TYPE_LTE_ONLY = 11,
|
||||
PREF_NET_TYPE_LTE_WCDMA = 12
|
||||
};
|
||||
|
||||
/* Radio technologies */
|
||||
enum ril_radio_tech {
|
||||
RADIO_TECH_UNKNOWN = 0,
|
||||
RADIO_TECH_GPRS = 1,
|
||||
RADIO_TECH_EDGE = 2,
|
||||
RADIO_TECH_UMTS = 3,
|
||||
RADIO_TECH_IS95A = 4,
|
||||
RADIO_TECH_IS95B = 5,
|
||||
RADIO_TECH_1xRTT = 6,
|
||||
RADIO_TECH_EVDO_0 = 7,
|
||||
RADIO_TECH_EVDO_A = 8,
|
||||
RADIO_TECH_HSDPA = 9,
|
||||
RADIO_TECH_HSUPA = 10,
|
||||
RADIO_TECH_HSPA = 11,
|
||||
RADIO_TECH_EVDO_B = 12,
|
||||
RADIO_TECH_EHRPD = 13,
|
||||
RADIO_TECH_LTE = 14,
|
||||
RADIO_TECH_HSPAP = 15,
|
||||
RADIO_TECH_GSM = 16,
|
||||
RADIO_TECH_TD_SCDMA = 17,
|
||||
RADIO_TECH_IWLAN = 18,
|
||||
RADIO_TECH_LTE_CA = 19
|
||||
};
|
||||
|
||||
/* Radio capabilities */
|
||||
enum ril_radio_access_family {
|
||||
RAF_GPRS = (1 << RADIO_TECH_GPRS),
|
||||
RAF_EDGE = (1 << RADIO_TECH_EDGE),
|
||||
RAF_UMTS = (1 << RADIO_TECH_UMTS),
|
||||
RAF_IS95A = (1 << RADIO_TECH_IS95A),
|
||||
RAF_IS95B = (1 << RADIO_TECH_IS95B),
|
||||
RAF_1xRTT = (1 << RADIO_TECH_1xRTT),
|
||||
RAF_EVDO_0 = (1 << RADIO_TECH_EVDO_0),
|
||||
RAF_EVDO_A = (1 << RADIO_TECH_EVDO_A),
|
||||
RAF_HSDPA = (1 << RADIO_TECH_HSDPA),
|
||||
RAF_HSUPA = (1 << RADIO_TECH_HSUPA),
|
||||
RAF_HSPA = (1 << RADIO_TECH_HSPA),
|
||||
RAF_EVDO_B = (1 << RADIO_TECH_EVDO_B),
|
||||
RAF_EHRPD = (1 << RADIO_TECH_EHRPD),
|
||||
RAF_LTE = (1 << RADIO_TECH_LTE),
|
||||
RAF_HSPAP = (1 << RADIO_TECH_HSPAP),
|
||||
RAF_GSM = (1 << RADIO_TECH_GSM),
|
||||
RAF_TD_SCDMA = (1 << RADIO_TECH_TD_SCDMA),
|
||||
RAF_LTE_CA = (1 << RADIO_TECH_LTE_CA)
|
||||
};
|
||||
|
||||
enum ril_radio_capability_phase {
|
||||
RC_PHASE_CONFIGURED = 0,
|
||||
RC_PHASE_START = 1,
|
||||
RC_PHASE_APPLY = 2,
|
||||
RC_PHASE_UNSOL_RSP = 3,
|
||||
RC_PHASE_FINISH = 4
|
||||
};
|
||||
|
||||
enum ril_radio_capability_status {
|
||||
RC_STATUS_NONE = 0,
|
||||
RC_STATUS_SUCCESS = 1,
|
||||
RC_STATUS_FAIL = 2
|
||||
};
|
||||
|
||||
#define RIL_RADIO_CAPABILITY_VERSION 1
|
||||
|
||||
struct ril_radio_capability {
|
||||
int version;
|
||||
int session;
|
||||
enum ril_radio_capability_phase phase;
|
||||
enum ril_radio_access_family rat;
|
||||
char logicalModemUuid[RIL_MAX_UUID_LENGTH];
|
||||
int status;
|
||||
};
|
||||
|
||||
enum ril_uicc_subscription_action {
|
||||
RIL_UICC_SUBSCRIPTION_DEACTIVATE = 0,
|
||||
RIL_UICC_SUBSCRIPTION_ACTIVATE = 1
|
||||
};
|
||||
|
||||
/* See RIL_REQUEST_LAST_CALL_FAIL_CAUSE */
|
||||
enum ril_call_fail_cause {
|
||||
CALL_FAIL_UNOBTAINABLE_NUMBER = 1,
|
||||
CALL_FAIL_NO_ROUTE_TO_DESTINATION = 3,
|
||||
CALL_FAIL_CHANNEL_UNACCEPTABLE = 6,
|
||||
CALL_FAIL_OPERATOR_DETERMINED_BARRING = 8,
|
||||
CALL_FAIL_NORMAL = 16,
|
||||
CALL_FAIL_BUSY = 17,
|
||||
CALL_FAIL_NO_USER_RESPONDING = 18,
|
||||
CALL_FAIL_NO_ANSWER_FROM_USER = 19,
|
||||
CALL_FAIL_CALL_REJECTED = 21,
|
||||
CALL_FAIL_NUMBER_CHANGED = 22,
|
||||
CALL_FAIL_DESTINATION_OUT_OF_ORDER = 27,
|
||||
CALL_FAIL_INVALID_NUMBER_FORMAT = 28,
|
||||
CALL_FAIL_FACILITY_REJECTED = 29,
|
||||
CALL_FAIL_RESP_TO_STATUS_ENQUIRY = 30,
|
||||
CALL_FAIL_NORMAL_UNSPECIFIED = 31,
|
||||
CALL_FAIL_CONGESTION = 34,
|
||||
CALL_FAIL_NETWORK_OUT_OF_ORDER = 38,
|
||||
CALL_FAIL_TEMPORARY_FAILURE = 41,
|
||||
CALL_FAIL_SWITCHING_EQUIPMENT_CONGESTION = 42,
|
||||
CALL_FAIL_ACCESS_INFORMATION_DISCARDED = 43,
|
||||
CALL_FAIL_REQUESTED_CIRCUIT_OR_CHANNEL_NOT_AVAILABLE = 44,
|
||||
CALL_FAIL_RESOURCES_UNAVAILABLE_OR_UNSPECIFIED = 47,
|
||||
CALL_FAIL_QOS_UNAVAILABLE = 49,
|
||||
CALL_FAIL_REQUESTED_FACILITY_NOT_SUBSCRIBED = 50,
|
||||
CALL_FAIL_INCOMING_CALLS_BARRED_WITHIN_CUG = 55,
|
||||
CALL_FAIL_BEARER_CAPABILITY_NOT_AUTHORIZED = 57,
|
||||
CALL_FAIL_BEARER_CAPABILITY_UNAVAILABLE = 58,
|
||||
CALL_FAIL_SERVICE_OPTION_NOT_AVAILABLE = 63,
|
||||
CALL_FAIL_BEARER_SERVICE_NOT_IMPLEMENTED = 65,
|
||||
CALL_FAIL_ACM_LIMIT_EXCEEDED = 68,
|
||||
CALL_FAIL_REQUESTED_FACILITY_NOT_IMPLEMENTED = 69,
|
||||
CALL_FAIL_ONLY_DIGITAL_INFORMATION_BEARER_AVAILABLE = 70,
|
||||
CALL_FAIL_SERVICE_OR_OPTION_NOT_IMPLEMENTED = 79,
|
||||
CALL_FAIL_INVALID_TRANSACTION_IDENTIFIER = 81,
|
||||
CALL_FAIL_USER_NOT_MEMBER_OF_CUG = 87,
|
||||
CALL_FAIL_INCOMPATIBLE_DESTINATION = 88,
|
||||
CALL_FAIL_INVALID_TRANSIT_NW_SELECTION = 91,
|
||||
CALL_FAIL_SEMANTICALLY_INCORRECT_MESSAGE = 95,
|
||||
CALL_FAIL_INVALID_MANDATORY_INFORMATION = 96,
|
||||
CALL_FAIL_MESSAGE_TYPE_NON_IMPLEMENTED = 97,
|
||||
CALL_FAIL_MESSAGE_TYPE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 98,
|
||||
CALL_FAIL_INFORMATION_ELEMENT_NON_EXISTENT = 99,
|
||||
CALL_FAIL_CONDITIONAL_IE_ERROR = 100,
|
||||
CALL_FAIL_MESSAGE_NOT_COMPATIBLE_WITH_PROTOCOL_STATE = 101,
|
||||
CALL_FAIL_RECOVERY_ON_TIMER_EXPIRED = 102,
|
||||
CALL_FAIL_PROTOCOL_ERROR_UNSPECIFIED = 111,
|
||||
CALL_FAIL_INTERWORKING_UNSPECIFIED = 127,
|
||||
CALL_FAIL_CALL_BARRED = 240,
|
||||
CALL_FAIL_FDN_BLOCKED = 241,
|
||||
CALL_FAIL_IMSI_UNKNOWN_IN_VLR = 242,
|
||||
CALL_FAIL_IMEI_NOT_ACCEPTED = 243,
|
||||
CALL_FAIL_DIAL_MODIFIED_TO_USSD = 244,
|
||||
CALL_FAIL_DIAL_MODIFIED_TO_SS = 245,
|
||||
CALL_FAIL_DIAL_MODIFIED_TO_DIAL = 246,
|
||||
CALL_FAIL_ERROR_UNSPECIFIED = 0xffff,
|
||||
|
||||
/* Not defined in ril.h but valid 3GPP specific cause values
|
||||
* for call control. See 3GPP TS 24.008 Annex H. */
|
||||
CALL_FAIL_ANONYMOUS_CALL_REJECTION = 24,
|
||||
CALL_FAIL_PRE_EMPTION = 25
|
||||
};
|
||||
|
||||
enum ril_data_call_fail_cause {
|
||||
PDP_FAIL_NONE = 0,
|
||||
PDP_FAIL_OPERATOR_BARRED = 0x08,
|
||||
PDP_FAIL_INSUFFICIENT_RESOURCES = 0x1A,
|
||||
PDP_FAIL_MISSING_UKNOWN_APN = 0x1B,
|
||||
PDP_FAIL_UNKNOWN_PDP_ADDRESS_TYPE = 0x1C,
|
||||
PDP_FAIL_USER_AUTHENTICATION = 0x1D,
|
||||
PDP_FAIL_ACTIVATION_REJECT_GGSN = 0x1E,
|
||||
PDP_FAIL_ACTIVATION_REJECT_UNSPECIFIED = 0x1F,
|
||||
PDP_FAIL_SERVICE_OPTION_NOT_SUPPORTED = 0x20,
|
||||
PDP_FAIL_SERVICE_OPTION_NOT_SUBSCRIBED = 0x21,
|
||||
PDP_FAIL_SERVICE_OPTION_OUT_OF_ORDER = 0x22,
|
||||
PDP_FAIL_NSAPI_IN_USE = 0x23,
|
||||
PDP_FAIL_REGULAR_DEACTIVATION = 0x24,
|
||||
PDP_FAIL_ONLY_IPV4_ALLOWED = 0x32,
|
||||
PDP_FAIL_ONLY_IPV6_ALLOWED = 0x33,
|
||||
PDP_FAIL_ONLY_SINGLE_BEARER_ALLOWED = 0x34,
|
||||
PDP_FAIL_PROTOCOL_ERRORS = 0x6F,
|
||||
PDP_FAIL_VOICE_REGISTRATION_FAIL = -1,
|
||||
PDP_FAIL_DATA_REGISTRATION_FAIL = -2,
|
||||
PDP_FAIL_SIGNAL_LOST = -3,
|
||||
PDP_FAIL_PREF_RADIO_TECH_CHANGED = -4,
|
||||
PDP_FAIL_RADIO_POWER_OFF = -5,
|
||||
PDP_FAIL_TETHERED_CALL_ACTIVE = -6,
|
||||
PDP_FAIL_ERROR_UNSPECIFIED = 0xffff
|
||||
};
|
||||
|
||||
/* RIL_REQUEST_DEACTIVATE_DATA_CALL parameter */
|
||||
#define RIL_DEACTIVATE_DATA_CALL_NO_REASON 0
|
||||
#define RIL_DEACTIVATE_DATA_CALL_RADIO_SHUTDOWN 1
|
||||
|
||||
/* RIL_REQUEST_SETUP_DATA_CALL */
|
||||
enum ril_data_profile {
|
||||
RIL_DATA_PROFILE_DEFAULT = 0,
|
||||
RIL_DATA_PROFILE_TETHERED = 1,
|
||||
RIL_DATA_PROFILE_IMS = 2,
|
||||
RIL_DATA_PROFILE_FOTA = 3,
|
||||
RIL_DATA_PROFILE_CBS = 4,
|
||||
RIL_DATA_PROFILE_OEM_BASE = 1000,
|
||||
RIL_DATA_PROFILE_INVALID = 0xFFFFFFFF
|
||||
};
|
||||
|
||||
enum ril_auth {
|
||||
RIL_AUTH_NONE = 0,
|
||||
RIL_AUTH_PAP = 1,
|
||||
RIL_AUTH_CHAP = 2,
|
||||
RIL_AUTH_BOTH = 3
|
||||
};
|
||||
|
||||
#define RIL_CARD_MAX_APPS 8
|
||||
|
||||
/* SIM card states */
|
||||
enum ril_card_state {
|
||||
RIL_CARDSTATE_UNKNOWN = -1,
|
||||
RIL_CARDSTATE_ABSENT = 0,
|
||||
RIL_CARDSTATE_PRESENT = 1,
|
||||
RIL_CARDSTATE_ERROR = 2
|
||||
};
|
||||
|
||||
/* SIM personalization substates */
|
||||
enum ril_perso_substate {
|
||||
RIL_PERSOSUBSTATE_UNKNOWN = 0,
|
||||
RIL_PERSOSUBSTATE_IN_PROGRESS = 1,
|
||||
RIL_PERSOSUBSTATE_READY = 2,
|
||||
RIL_PERSOSUBSTATE_SIM_NETWORK = 3,
|
||||
RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET = 4,
|
||||
RIL_PERSOSUBSTATE_SIM_CORPORATE = 5,
|
||||
RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER = 6,
|
||||
RIL_PERSOSUBSTATE_SIM_SIM = 7,
|
||||
RIL_PERSOSUBSTATE_SIM_NETWORK_PUK = 8,
|
||||
RIL_PERSOSUBSTATE_SIM_NETWORK_SUBSET_PUK = 9,
|
||||
RIL_PERSOSUBSTATE_SIM_CORPORATE_PUK = 10,
|
||||
RIL_PERSOSUBSTATE_SIM_SERVICE_PROVIDER_PUK = 11,
|
||||
RIL_PERSOSUBSTATE_SIM_SIM_PUK = 12,
|
||||
RIL_PERSOSUBSTATE_RUIM_NETWORK1 = 13,
|
||||
RIL_PERSOSUBSTATE_RUIM_NETWORK2 = 14,
|
||||
RIL_PERSOSUBSTATE_RUIM_HRPD = 15,
|
||||
RIL_PERSOSUBSTATE_RUIM_CORPORATE = 16,
|
||||
RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER = 17,
|
||||
RIL_PERSOSUBSTATE_RUIM_RUIM = 18,
|
||||
RIL_PERSOSUBSTATE_RUIM_NETWORK1_PUK = 19,
|
||||
RIL_PERSOSUBSTATE_RUIM_NETWORK2_PUK = 20,
|
||||
RIL_PERSOSUBSTATE_RUIM_HRPD_PUK = 21,
|
||||
RIL_PERSOSUBSTATE_RUIM_CORPORATE_PUK = 22,
|
||||
RIL_PERSOSUBSTATE_RUIM_SERVICE_PROVIDER_PUK = 23,
|
||||
RIL_PERSOSUBSTATE_RUIM_RUIM_PUK = 24
|
||||
};
|
||||
|
||||
/* SIM - App states */
|
||||
enum ril_app_state {
|
||||
RIL_APPSTATE_ILLEGAL = -1,
|
||||
RIL_APPSTATE_UNKNOWN = 0,
|
||||
RIL_APPSTATE_DETECTED = 1,
|
||||
RIL_APPSTATE_PIN = 2,
|
||||
RIL_APPSTATE_PUK = 3,
|
||||
RIL_APPSTATE_SUBSCRIPTION_PERSO = 4,
|
||||
RIL_APPSTATE_READY = 5
|
||||
};
|
||||
|
||||
/* SIM - PIN states */
|
||||
enum ril_pin_state {
|
||||
RIL_PINSTATE_UNKNOWN = 0,
|
||||
RIL_PINSTATE_ENABLED_NOT_VERIFIED = 1,
|
||||
RIL_PINSTATE_ENABLED_VERIFIED = 2,
|
||||
RIL_PINSTATE_DISABLED = 3,
|
||||
RIL_PINSTATE_ENABLED_BLOCKED = 4,
|
||||
RIL_PINSTATE_ENABLED_PERM_BLOCKED = 5
|
||||
};
|
||||
|
||||
/* SIM - App types */
|
||||
enum ril_app_type {
|
||||
RIL_APPTYPE_UNKNOWN = 0,
|
||||
RIL_APPTYPE_SIM = 1,
|
||||
RIL_APPTYPE_USIM = 2,
|
||||
RIL_APPTYPE_RUIM = 3,
|
||||
RIL_APPTYPE_CSIM = 4,
|
||||
RIL_APPTYPE_ISIM = 5
|
||||
};
|
||||
|
||||
/* Cell info */
|
||||
enum ril_cell_info_type {
|
||||
RIL_CELL_INFO_TYPE_NONE = 0,
|
||||
RIL_CELL_INFO_TYPE_GSM = 1,
|
||||
RIL_CELL_INFO_TYPE_CDMA = 2,
|
||||
RIL_CELL_INFO_TYPE_LTE = 3,
|
||||
RIL_CELL_INFO_TYPE_WCDMA = 4,
|
||||
RIL_CELL_INFO_TYPE_TD_SCDMA = 5
|
||||
};
|
||||
|
||||
enum ril_restricted_state {
|
||||
RIL_RESTRICTED_STATE_NONE = 0x00,
|
||||
RIL_RESTRICTED_STATE_CS_EMERGENCY = 0x01,
|
||||
RIL_RESTRICTED_STATE_CS_NORMAL = 0x02,
|
||||
RIL_RESTRICTED_STATE_CS_ALL = 0x04,
|
||||
RIL_RESTRICTED_STATE_PS_ALL = 0x10
|
||||
};
|
||||
|
||||
/* Suplementary services Service class*/
|
||||
#define SERVICE_CLASS_NONE 0
|
||||
|
||||
/* RIL_FACILITY_LOCK parameters */
|
||||
#define RIL_FACILITY_UNLOCK "0"
|
||||
#define RIL_FACILITY_LOCK "1"
|
||||
|
||||
#endif /*__RIL_CONSTANTS_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,149 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_DATA_H
|
||||
#define RIL_DATA_H
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
#include <ofono/gprs-context.h>
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
enum ril_data_call_active {
|
||||
RIL_DATA_CALL_INACTIVE = 0,
|
||||
RIL_DATA_CALL_LINK_DOWN = 1,
|
||||
RIL_DATA_CALL_ACTIVE = 2
|
||||
};
|
||||
|
||||
struct ril_data_call {
|
||||
int cid;
|
||||
enum ril_data_call_fail_cause status;
|
||||
enum ril_data_call_active active;
|
||||
enum ofono_gprs_proto prot;
|
||||
int retry_time;
|
||||
int mtu;
|
||||
char *ifname;
|
||||
char **dnses;
|
||||
char **gateways;
|
||||
char **addresses;
|
||||
};
|
||||
|
||||
struct ril_data_call_list {
|
||||
guint version;
|
||||
guint num;
|
||||
GSList *calls;
|
||||
};
|
||||
|
||||
struct ril_data {
|
||||
GObject object;
|
||||
struct ril_data_priv *priv;
|
||||
struct ril_data_call_list *data_calls;
|
||||
};
|
||||
|
||||
enum ril_data_manager_flags {
|
||||
RIL_DATA_MANAGER_3GLTE_HANDOVER = 0x01
|
||||
};
|
||||
|
||||
enum ril_data_allow_data_opt {
|
||||
RIL_ALLOW_DATA_AUTO,
|
||||
RIL_ALLOW_DATA_ENABLED,
|
||||
RIL_ALLOW_DATA_DISABLED
|
||||
};
|
||||
|
||||
enum ril_data_call_format {
|
||||
RIL_DATA_CALL_FORMAT_AUTO,
|
||||
RIL_DATA_CALL_FORMAT_6 = 6,
|
||||
RIL_DATA_CALL_FORMAT_9 = 9,
|
||||
RIL_DATA_CALL_FORMAT_11 = 11
|
||||
};
|
||||
|
||||
struct ril_data_options {
|
||||
enum ril_data_allow_data_opt allow_data;
|
||||
enum ril_data_call_format data_call_format;
|
||||
unsigned int data_call_retry_limit;
|
||||
unsigned int data_call_retry_delay_ms;
|
||||
};
|
||||
|
||||
enum ril_data_role {
|
||||
RIL_DATA_ROLE_NONE, /* Data not allowed */
|
||||
RIL_DATA_ROLE_MMS, /* Data is allowed at any speed */
|
||||
RIL_DATA_ROLE_INTERNET /* Data is allowed at full speed */
|
||||
};
|
||||
|
||||
struct ril_data_manager;
|
||||
struct ril_data_manager *ril_data_manager_new(enum ril_data_manager_flags flg);
|
||||
struct ril_data_manager *ril_data_manager_ref(struct ril_data_manager *dm);
|
||||
void ril_data_manager_unref(struct ril_data_manager *dm);
|
||||
void ril_data_manager_assert_data_on(struct ril_data_manager *dm);
|
||||
|
||||
typedef void (*ril_data_cb_t)(struct ril_data *data, void *arg);
|
||||
typedef void (*ril_data_call_setup_cb_t)(struct ril_data *data,
|
||||
int ril_status, const struct ril_data_call *call,
|
||||
void *arg);
|
||||
typedef void (*ril_data_call_deactivate_cb_t)(struct ril_data *data,
|
||||
int ril_status, void *arg);
|
||||
|
||||
struct ril_data *ril_data_new(struct ril_data_manager *dm, const char *name,
|
||||
struct ril_radio *radio, struct ril_network *network,
|
||||
GRilIoChannel *io, const struct ril_data_options *options,
|
||||
const struct ril_slot_config *config,
|
||||
struct ril_vendor_hook *vendor_hook);
|
||||
struct ril_data *ril_data_ref(struct ril_data *data);
|
||||
void ril_data_unref(struct ril_data *data);
|
||||
gboolean ril_data_allowed(struct ril_data *data);
|
||||
void ril_data_poll_call_state(struct ril_data *data);
|
||||
|
||||
gulong ril_data_add_allow_changed_handler(struct ril_data *data,
|
||||
ril_data_cb_t cb, void *arg);
|
||||
gulong ril_data_add_calls_changed_handler(struct ril_data *data,
|
||||
ril_data_cb_t cb, void *arg);
|
||||
void ril_data_remove_handler(struct ril_data *data, gulong id);
|
||||
|
||||
void ril_data_allow(struct ril_data *data, enum ril_data_role role);
|
||||
|
||||
struct ril_data_request;
|
||||
struct ril_data_request *ril_data_call_setup(struct ril_data *data,
|
||||
const struct ofono_gprs_primary_context *ctx,
|
||||
ril_data_call_setup_cb_t cb, void *arg);
|
||||
struct ril_data_request *ril_data_call_deactivate(struct ril_data *data,
|
||||
int cid, ril_data_call_deactivate_cb_t cb, void *arg);
|
||||
void ril_data_request_detach(struct ril_data_request *req);
|
||||
void ril_data_request_cancel(struct ril_data_request *req);
|
||||
|
||||
gboolean ril_data_call_grab(struct ril_data *data, int cid, void *cookie);
|
||||
void ril_data_call_release(struct ril_data *data, int cid, void *cookie);
|
||||
|
||||
void ril_data_call_free(struct ril_data_call *call);
|
||||
struct ril_data_call *ril_data_call_dup(const struct ril_data_call *call);
|
||||
struct ril_data_call *ril_data_call_find(struct ril_data_call_list *list,
|
||||
int cid);
|
||||
|
||||
const char *ril_data_ofono_protocol_to_ril(enum ofono_gprs_proto proto);
|
||||
int ril_data_protocol_to_ofono(const gchar *str);
|
||||
|
||||
/* Constructors of various kinds of RIL requests */
|
||||
GRilIoRequest *ril_request_allow_data_new(gboolean allow);
|
||||
GRilIoRequest *ril_request_deactivate_data_call_new(int cid);
|
||||
|
||||
#endif /* RIL_DATA_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,225 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <gutil_idlequeue.h>
|
||||
|
||||
/*
|
||||
* TODO: No public RIL api to query manufacturer or model.
|
||||
* Check where to get, could /system/build.prop be updated to have good values?
|
||||
*/
|
||||
|
||||
enum ril_devinfo_cb_tag {
|
||||
DEVINFO_QUERY_SERIAL = 1,
|
||||
DEVINFO_QUERY_SVN
|
||||
};
|
||||
|
||||
struct ril_devinfo {
|
||||
struct ofono_devinfo *info;
|
||||
GRilIoQueue *q;
|
||||
GUtilIdleQueue *iq;
|
||||
char *log_prefix;
|
||||
char *imeisv;
|
||||
char *imei;
|
||||
};
|
||||
|
||||
struct ril_devinfo_cbd {
|
||||
struct ril_devinfo *di;
|
||||
ofono_devinfo_query_cb_t cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
#define DBG_(self,fmt,args...) DBG("%s" fmt, (self)->log_prefix, ##args)
|
||||
#define ril_devinfo_cbd_free g_free
|
||||
|
||||
static inline struct ril_devinfo *ril_devinfo_get_data(
|
||||
struct ofono_devinfo *info)
|
||||
{
|
||||
return ofono_devinfo_get_data(info);
|
||||
}
|
||||
|
||||
struct ril_devinfo_cbd *ril_devinfo_cbd_new(struct ril_devinfo *di,
|
||||
ofono_devinfo_query_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_devinfo_cbd *cbd = g_new0(struct ril_devinfo_cbd, 1);
|
||||
|
||||
cbd->di = di;
|
||||
cbd->cb = cb;
|
||||
cbd->data = data;
|
||||
return cbd;
|
||||
}
|
||||
|
||||
static void ril_devinfo_query_unsupported(struct ofono_devinfo *info,
|
||||
ofono_devinfo_query_cb_t cb, void *data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
cb(ril_error_failure(&error), "", data);
|
||||
}
|
||||
|
||||
static void ril_devinfo_query_revision_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_devinfo_cbd *cbd = user_data;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
char *res;
|
||||
GRilIoParser rilp;
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
res = grilio_parser_get_utf8(&rilp);
|
||||
DBG_(cbd->di, "%s", res);
|
||||
cbd->cb(ril_error_ok(&error), res ? res : "", cbd->data);
|
||||
g_free(res);
|
||||
} else {
|
||||
cbd->cb(ril_error_failure(&error), NULL, cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_devinfo_query_revision(struct ofono_devinfo *info,
|
||||
ofono_devinfo_query_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_devinfo *di = ril_devinfo_get_data(info);
|
||||
|
||||
DBG_(di, "");
|
||||
grilio_queue_send_request_full(di->q, NULL,
|
||||
RIL_REQUEST_BASEBAND_VERSION,
|
||||
ril_devinfo_query_revision_cb,
|
||||
ril_devinfo_cbd_free,
|
||||
ril_devinfo_cbd_new(di, cb, data));
|
||||
}
|
||||
|
||||
static void ril_devinfo_query_serial_cb(gpointer user_data)
|
||||
{
|
||||
struct ril_devinfo_cbd *cbd = user_data;
|
||||
struct ril_devinfo *di = cbd->di;
|
||||
struct ofono_error error;
|
||||
|
||||
DBG_(di, "%s", di->imei);
|
||||
cbd->cb(ril_error_ok(&error), di->imei, cbd->data);
|
||||
}
|
||||
|
||||
static void ril_devinfo_query_svn_cb(gpointer user_data)
|
||||
{
|
||||
struct ril_devinfo_cbd *cbd = user_data;
|
||||
struct ril_devinfo *di = cbd->di;
|
||||
struct ofono_error error;
|
||||
|
||||
DBG_(di, "%s", di->imeisv);
|
||||
if (di->imeisv && di->imeisv[0]) {
|
||||
cbd->cb(ril_error_ok(&error), di->imeisv, cbd->data);
|
||||
} else {
|
||||
cbd->cb(ril_error_failure(&error), "", cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_devinfo_query(struct ril_devinfo *di,
|
||||
enum ril_devinfo_cb_tag tag, GUtilIdleFunc fn,
|
||||
ofono_devinfo_query_cb_t cb, void *data)
|
||||
{
|
||||
GVERIFY_FALSE(gutil_idle_queue_cancel_tag(di->iq, tag));
|
||||
gutil_idle_queue_add_tag_full(di->iq, tag, fn,
|
||||
ril_devinfo_cbd_new(di, cb, data),
|
||||
ril_devinfo_cbd_free);
|
||||
}
|
||||
|
||||
static void ril_devinfo_query_serial(struct ofono_devinfo *info,
|
||||
ofono_devinfo_query_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct ril_devinfo *di = ril_devinfo_get_data(info);
|
||||
|
||||
DBG_(di, "");
|
||||
ril_devinfo_query(di, DEVINFO_QUERY_SERIAL,
|
||||
ril_devinfo_query_serial_cb, cb, data);
|
||||
}
|
||||
|
||||
static void ril_devinfo_query_svn(struct ofono_devinfo *info,
|
||||
ofono_devinfo_query_cb_t cb,
|
||||
void *data)
|
||||
{
|
||||
struct ril_devinfo *di = ril_devinfo_get_data(info);
|
||||
|
||||
DBG_(di, "");
|
||||
ril_devinfo_query(di, DEVINFO_QUERY_SVN,
|
||||
ril_devinfo_query_svn_cb, cb, data);
|
||||
}
|
||||
|
||||
static void ril_devinfo_register(gpointer user_data)
|
||||
{
|
||||
struct ril_devinfo *di = user_data;
|
||||
|
||||
DBG_(di, "");
|
||||
ofono_devinfo_register(di->info);
|
||||
}
|
||||
|
||||
static int ril_devinfo_probe(struct ofono_devinfo *info, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_devinfo *di = g_new0(struct ril_devinfo, 1);
|
||||
|
||||
di->log_prefix = (modem->log_prefix && modem->log_prefix[0]) ?
|
||||
g_strconcat(modem->log_prefix, " ", NULL) : g_strdup("");
|
||||
|
||||
DBG_(di, "%s", modem->imei);
|
||||
GASSERT(modem->imei);
|
||||
|
||||
di->q = grilio_queue_new(ril_modem_io(modem));
|
||||
di->info = info;
|
||||
di->imeisv = g_strdup(modem->imeisv);
|
||||
di->imei = g_strdup(modem->imei);
|
||||
di->iq = gutil_idle_queue_new();
|
||||
gutil_idle_queue_add(di->iq, ril_devinfo_register, di);
|
||||
ofono_devinfo_set_data(info, di);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_devinfo_remove(struct ofono_devinfo *info)
|
||||
{
|
||||
struct ril_devinfo *di = ril_devinfo_get_data(info);
|
||||
|
||||
DBG_(di, "");
|
||||
ofono_devinfo_set_data(info, NULL);
|
||||
gutil_idle_queue_cancel_all(di->iq);
|
||||
gutil_idle_queue_unref(di->iq);
|
||||
grilio_queue_cancel_all(di->q, FALSE);
|
||||
grilio_queue_unref(di->q);
|
||||
g_free(di->log_prefix);
|
||||
g_free(di->imeisv);
|
||||
g_free(di->imei);
|
||||
g_free(di);
|
||||
}
|
||||
|
||||
const struct ofono_devinfo_driver ril_devinfo_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_devinfo_probe,
|
||||
.remove = ril_devinfo_remove,
|
||||
/* query_revision won't be called if query_model is missing */
|
||||
.query_model = ril_devinfo_query_unsupported,
|
||||
.query_revision = ril_devinfo_query_revision,
|
||||
.query_serial = ril_devinfo_query_serial,
|
||||
.query_svn = ril_devinfo_query_svn
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,258 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_ecclist.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <gutil_strv.h>
|
||||
#include <gutil_inotify.h>
|
||||
|
||||
#include <sys/inotify.h>
|
||||
|
||||
typedef GObjectClass RilEccListClass;
|
||||
typedef struct ril_ecclist RilEccList;
|
||||
|
||||
struct ril_ecclist_priv {
|
||||
struct ofono_sim *sim;
|
||||
GUtilInotifyWatchCallback *dir_watch;
|
||||
GUtilInotifyWatchCallback *file_watch;
|
||||
char *dir;
|
||||
char *path;
|
||||
char *name;
|
||||
};
|
||||
|
||||
enum ril_ecclist_signal {
|
||||
SIGNAL_LIST_CHANGED,
|
||||
SIGNAL_COUNT
|
||||
};
|
||||
|
||||
#define SIGNAL_LIST_CHANGED_NAME "ril-ecclist-changed"
|
||||
|
||||
static guint ril_ecclist_signals[SIGNAL_COUNT] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE(RilEccList, ril_ecclist, G_TYPE_OBJECT)
|
||||
#define RIL_ECCLIST_TYPE (ril_ecclist_get_type())
|
||||
#define RIL_ECCLIST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
|
||||
RIL_ECCLIST_TYPE, RilEccList))
|
||||
|
||||
static char **ril_ecclist_read(struct ril_ecclist *self)
|
||||
{
|
||||
struct ril_ecclist_priv *priv = self->priv;
|
||||
char **list = NULL;
|
||||
|
||||
if (g_file_test(priv->path, G_FILE_TEST_EXISTS)) {
|
||||
gsize len = 0;
|
||||
gchar *content = NULL;
|
||||
GError *error = NULL;
|
||||
|
||||
if (g_file_get_contents(priv->path, &content, &len, &error)) {
|
||||
char **ptr;
|
||||
|
||||
DBG("%s = %s", priv->name, content);
|
||||
list = g_strsplit(content, ",", 0);
|
||||
for (ptr = list; *ptr; ptr++) {
|
||||
*ptr = g_strstrip(*ptr);
|
||||
}
|
||||
|
||||
gutil_strv_sort(list, TRUE);
|
||||
} else if (error) {
|
||||
DBG("%s: %s", priv->path, GERRMSG(error));
|
||||
g_error_free(error);
|
||||
}
|
||||
|
||||
g_free (content);
|
||||
} else {
|
||||
DBG("%s doesn't exist", priv->path);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
static void ril_ecclist_update(struct ril_ecclist *self)
|
||||
{
|
||||
struct ril_ecclist_priv *priv = self->priv;
|
||||
char **list = ril_ecclist_read(self);
|
||||
|
||||
if (!gutil_strv_equal(self->list, list)) {
|
||||
DBG("%s changed", priv->name);
|
||||
g_strfreev(self->list);
|
||||
self->list = list;
|
||||
g_signal_emit(self, ril_ecclist_signals[SIGNAL_LIST_CHANGED], 0);
|
||||
} else {
|
||||
g_strfreev(list);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_ecclist_changed(GUtilInotifyWatch *watch, guint mask,
|
||||
guint cookie, const char *name, void *user_data)
|
||||
{
|
||||
struct ril_ecclist *self = RIL_ECCLIST(user_data);
|
||||
struct ril_ecclist_priv *priv = self->priv;
|
||||
|
||||
ril_ecclist_update(self);
|
||||
|
||||
if (mask & IN_IGNORED) {
|
||||
DBG("file %s is gone", priv->path);
|
||||
gutil_inotify_watch_callback_free(priv->file_watch);
|
||||
priv->file_watch = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_ecclist_dir_changed(GUtilInotifyWatch *watch, guint mask,
|
||||
guint cookie, const char *name, void *user_data)
|
||||
{
|
||||
struct ril_ecclist *self = RIL_ECCLIST(user_data);
|
||||
struct ril_ecclist_priv *priv = self->priv;
|
||||
|
||||
DBG("0x%04x %s", mask, name);
|
||||
if (!priv->file_watch && !g_strcmp0(name, priv->name)) {
|
||||
priv->file_watch = gutil_inotify_watch_callback_new(priv->path,
|
||||
IN_MODIFY | IN_CLOSE_WRITE,
|
||||
ril_ecclist_changed, self);
|
||||
if (priv->file_watch) {
|
||||
DBG("watching %s", priv->path);
|
||||
ril_ecclist_update(self);
|
||||
}
|
||||
}
|
||||
|
||||
if (mask & IN_IGNORED) {
|
||||
DBG("%s is gone", priv->dir);
|
||||
gutil_inotify_watch_callback_free(priv->dir_watch);
|
||||
priv->dir_watch = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
gulong ril_ecclist_add_list_changed_handler(struct ril_ecclist *self,
|
||||
ril_ecclist_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_LIST_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
void ril_ecclist_remove_handler(struct ril_ecclist *self, gulong id)
|
||||
{
|
||||
if (G_LIKELY(self) && G_LIKELY(id)) {
|
||||
g_signal_handler_disconnect(self, id);
|
||||
}
|
||||
}
|
||||
|
||||
struct ril_ecclist *ril_ecclist_new(const char *path)
|
||||
{
|
||||
if (path) {
|
||||
struct ril_ecclist *self = g_object_new(RIL_ECCLIST_TYPE, 0);
|
||||
struct ril_ecclist_priv *priv = self->priv;
|
||||
|
||||
DBG("%s", path);
|
||||
priv->path = g_strdup(path);
|
||||
priv->name = g_path_get_basename(path);
|
||||
priv->dir = g_path_get_dirname(path);
|
||||
priv->dir_watch = gutil_inotify_watch_callback_new(priv->dir,
|
||||
IN_MODIFY|IN_MOVED_FROM|IN_MOVED_TO|IN_DELETE|
|
||||
IN_CREATE|IN_DELETE_SELF|IN_CLOSE_WRITE,
|
||||
ril_ecclist_dir_changed, self);
|
||||
if (priv->dir_watch) {
|
||||
DBG("watching %s", priv->dir);
|
||||
}
|
||||
|
||||
self->list = ril_ecclist_read(self);
|
||||
priv->file_watch = gutil_inotify_watch_callback_new(priv->path,
|
||||
IN_MODIFY | IN_CLOSE_WRITE,
|
||||
ril_ecclist_changed, self);
|
||||
if (priv->file_watch) {
|
||||
DBG("watching %s", priv->path);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ril_ecclist *ril_ecclist_ref(struct ril_ecclist *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
g_object_ref(RIL_ECCLIST(self));
|
||||
return self;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ril_ecclist_unref(struct ril_ecclist *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
g_object_unref(RIL_ECCLIST(self));
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_ecclist_init(struct ril_ecclist *self)
|
||||
{
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, RIL_ECCLIST_TYPE,
|
||||
struct ril_ecclist_priv);
|
||||
}
|
||||
|
||||
static void ril_ecclist_dispose(GObject *object)
|
||||
{
|
||||
struct ril_ecclist *self = RIL_ECCLIST(object);
|
||||
struct ril_ecclist_priv *priv = self->priv;
|
||||
|
||||
if (priv->dir_watch) {
|
||||
gutil_inotify_watch_callback_free(priv->dir_watch);
|
||||
priv->dir_watch = NULL;
|
||||
}
|
||||
|
||||
if (priv->file_watch) {
|
||||
gutil_inotify_watch_callback_free(priv->file_watch);
|
||||
priv->file_watch = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS(ril_ecclist_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void ril_ecclist_finalize(GObject *object)
|
||||
{
|
||||
struct ril_ecclist *self = RIL_ECCLIST(object);
|
||||
struct ril_ecclist_priv *priv = self->priv;
|
||||
|
||||
GASSERT(!priv->dir_watch);
|
||||
GASSERT(!priv->file_watch);
|
||||
g_free(priv->dir);
|
||||
g_free(priv->path);
|
||||
g_free(priv->name);
|
||||
g_strfreev(self->list);
|
||||
|
||||
G_OBJECT_CLASS(ril_ecclist_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void ril_ecclist_class_init(RilEccListClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
object_class->dispose = ril_ecclist_dispose;
|
||||
object_class->finalize = ril_ecclist_finalize;
|
||||
g_type_class_add_private(klass, sizeof(struct ril_ecclist_priv));
|
||||
ril_ecclist_signals[SIGNAL_LIST_CHANGED] =
|
||||
g_signal_new(SIGNAL_LIST_CHANGED_NAME,
|
||||
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST,
|
||||
0, NULL, NULL, NULL, G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_ECCLIST_H
|
||||
#define RIL_ECCLIST_H
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
struct ril_ecclist_priv;
|
||||
|
||||
struct ril_ecclist {
|
||||
GObject object;
|
||||
struct ril_ecclist_priv *priv;
|
||||
char **list;
|
||||
};
|
||||
|
||||
typedef void (*ril_ecclist_cb_t)(struct ril_ecclist *ecc, void *arg);
|
||||
|
||||
struct ril_ecclist *ril_ecclist_new(const char *path);
|
||||
struct ril_ecclist *ril_ecclist_ref(struct ril_ecclist *ecc);
|
||||
void ril_ecclist_unref(struct ril_ecclist *ecc);
|
||||
gulong ril_ecclist_add_list_changed_handler(struct ril_ecclist *ecc,
|
||||
ril_ecclist_cb_t cb, void *arg);
|
||||
void ril_ecclist_remove_handler(struct ril_ecclist *ecc, gulong id);
|
||||
|
||||
#endif /* RIL_ECCLIST_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,283 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2016 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_network.h"
|
||||
#include "ril_data.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "common.h"
|
||||
|
||||
/*
|
||||
* This module is the ofono_gprs_driver implementation for rilmodem.
|
||||
*
|
||||
* Notes:
|
||||
*
|
||||
* 1. ofono_gprs_suspend/resume() are not used by this module, as
|
||||
* the concept of suspended GPRS is not exposed by RILD.
|
||||
*
|
||||
* 2. ofono_gprs_bearer_notify() is never called as RILD does not
|
||||
* expose an unsolicited event equivalent to +CPSB ( see 27.007
|
||||
* 7.29 ), and the tech values returned by REQUEST_DATA/VOICE
|
||||
* _REGISTRATION requests do not match the values defined for
|
||||
* <AcT> in the +CPSB definition. Note, the values returned by
|
||||
* the *REGISTRATION commands are aligned with those defined by
|
||||
* +CREG ( see 27.003 7.2 ).
|
||||
*/
|
||||
|
||||
struct ril_gprs {
|
||||
struct ofono_gprs *gprs;
|
||||
struct ril_modem *md;
|
||||
struct ril_data *data;
|
||||
struct ril_network *network;
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
gboolean attached;
|
||||
int max_cids;
|
||||
enum network_registration_status registration_status;
|
||||
guint register_id;
|
||||
gulong network_event_id;
|
||||
gulong data_event_id;
|
||||
guint set_attached_id;
|
||||
};
|
||||
|
||||
struct ril_gprs_cbd {
|
||||
struct ril_gprs *gd;
|
||||
ofono_gprs_cb_t cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
#define ril_gprs_cbd_free g_free
|
||||
|
||||
static struct ril_gprs *ril_gprs_get_data(struct ofono_gprs *ofono)
|
||||
{
|
||||
return ofono ? ofono_gprs_get_data(ofono) : NULL;
|
||||
}
|
||||
|
||||
static struct ril_gprs_cbd *ril_gprs_cbd_new(struct ril_gprs *gd,
|
||||
ofono_gprs_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_gprs_cbd *cbd = g_new0(struct ril_gprs_cbd, 1);
|
||||
|
||||
cbd->gd = gd;
|
||||
cbd->cb = cb;
|
||||
cbd->data = data;
|
||||
return cbd;
|
||||
}
|
||||
|
||||
static enum network_registration_status ril_gprs_fix_registration_status(
|
||||
struct ril_gprs *gd, enum network_registration_status status)
|
||||
{
|
||||
if (!ril_data_allowed(gd->data)) {
|
||||
return NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
|
||||
} else {
|
||||
/* TODO: need a way to make sure that SPDI information has
|
||||
* already been read from the SIM (i.e. sim_spdi_read_cb in
|
||||
* network.c has been called) */
|
||||
struct ofono_netreg *netreg = ril_modem_ofono_netreg(gd->md);
|
||||
return ril_netreg_check_if_really_roaming(netreg, status);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_gprs_data_update_registration_state(struct ril_gprs *gd)
|
||||
{
|
||||
const enum network_registration_status status =
|
||||
ril_gprs_fix_registration_status(gd, gd->network->data.status);
|
||||
|
||||
if (gd->registration_status != status) {
|
||||
ofono_info("data reg changed %d -> %d (%s), attached %d",
|
||||
gd->registration_status, status,
|
||||
registration_status_to_string(status),
|
||||
gd->attached);
|
||||
gd->registration_status = status;
|
||||
ofono_gprs_status_notify(gd->gprs, gd->registration_status);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_gprs_check_data_allowed(struct ril_gprs *gd)
|
||||
{
|
||||
DBG("%s %d %d", ril_modem_get_path(gd->md), ril_data_allowed(gd->data),
|
||||
gd->attached);
|
||||
if (!ril_data_allowed(gd->data) && gd->attached) {
|
||||
gd->attached = FALSE;
|
||||
if (gd->gprs) {
|
||||
ofono_gprs_detached_notify(gd->gprs);
|
||||
}
|
||||
}
|
||||
|
||||
ril_gprs_data_update_registration_state(gd);
|
||||
}
|
||||
|
||||
static gboolean ril_gprs_set_attached_cb(gpointer user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_gprs_cbd *cbd = user_data;
|
||||
struct ril_gprs *gd = cbd->gd;
|
||||
|
||||
GASSERT(gd->set_attached_id);
|
||||
gd->set_attached_id = 0;
|
||||
ril_gprs_check_data_allowed(gd);
|
||||
cbd->cb(ril_error_ok(&error), cbd->data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void ril_gprs_set_attached(struct ofono_gprs *gprs, int attached,
|
||||
ofono_gprs_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_gprs *gd = ril_gprs_get_data(gprs);
|
||||
|
||||
if (ril_data_allowed(gd->data) || !attached) {
|
||||
DBG("%s attached: %d", ril_modem_get_path(gd->md), attached);
|
||||
if (gd->set_attached_id) {
|
||||
g_source_remove(gd->set_attached_id);
|
||||
}
|
||||
gd->attached = attached;
|
||||
gd->set_attached_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
|
||||
ril_gprs_set_attached_cb,
|
||||
ril_gprs_cbd_new(gd, cb, data),
|
||||
ril_gprs_cbd_free);
|
||||
} else {
|
||||
struct ofono_error error;
|
||||
DBG("%s not allowed to attach", ril_modem_get_path(gd->md));
|
||||
cb(ril_error_failure(&error), data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_gprs_allow_data_changed(struct ril_data *data, void *user_data)
|
||||
{
|
||||
struct ril_gprs *gd = user_data;
|
||||
|
||||
GASSERT(gd->data == data);
|
||||
DBG("%s %d", ril_modem_get_path(gd->md), ril_data_allowed(data));
|
||||
if (!gd->set_attached_id) {
|
||||
ril_gprs_check_data_allowed(gd);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_gprs_data_registration_state_changed(struct ril_network *net,
|
||||
void *user_data)
|
||||
{
|
||||
struct ril_gprs *gd = user_data;
|
||||
const struct ril_registration_state *data = &net->data;
|
||||
|
||||
GASSERT(gd->network == net);
|
||||
if (data->max_calls > gd->max_cids) {
|
||||
DBG("Setting max cids to %d", data->max_calls);
|
||||
gd->max_cids = data->max_calls;
|
||||
ofono_gprs_set_cid_range(gd->gprs, 1, gd->max_cids);
|
||||
}
|
||||
|
||||
ril_gprs_data_update_registration_state(gd);
|
||||
}
|
||||
|
||||
static void ril_gprs_registration_status(struct ofono_gprs *gprs,
|
||||
ofono_gprs_status_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_gprs *gd = ril_gprs_get_data(gprs);
|
||||
struct ofono_error error;
|
||||
const enum network_registration_status status = gd->attached ?
|
||||
gd->registration_status :
|
||||
NETWORK_REGISTRATION_STATUS_NOT_REGISTERED;
|
||||
|
||||
|
||||
DBG("%d (%s)", status, registration_status_to_string(status));
|
||||
cb(ril_error_ok(&error), status, data);
|
||||
}
|
||||
|
||||
static gboolean ril_gprs_register(gpointer user_data)
|
||||
{
|
||||
struct ril_gprs *gd = user_data;
|
||||
|
||||
gd->register_id = 0;
|
||||
gd->network_event_id = ril_network_add_data_state_changed_handler(
|
||||
gd->network, ril_gprs_data_registration_state_changed, gd);
|
||||
gd->data_event_id = ril_data_add_allow_changed_handler(gd->data,
|
||||
ril_gprs_allow_data_changed, gd);
|
||||
gd->registration_status = ril_gprs_fix_registration_status(gd,
|
||||
gd->network->data.status);
|
||||
|
||||
gd->max_cids = gd->network->data.max_calls;
|
||||
if (gd->max_cids > 0) {
|
||||
DBG("Setting max cids to %d", gd->max_cids);
|
||||
ofono_gprs_set_cid_range(gd->gprs, 1, gd->max_cids);
|
||||
}
|
||||
|
||||
ofono_gprs_register(gd->gprs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int ril_gprs_probe(struct ofono_gprs *gprs, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_gprs *gd = g_new0(struct ril_gprs, 1);
|
||||
|
||||
DBG("%s", ril_modem_get_path(modem));
|
||||
gd->md = modem;
|
||||
gd->io = grilio_channel_ref(ril_modem_io(modem));
|
||||
gd->q = grilio_queue_new(gd->io);
|
||||
gd->data = ril_data_ref(modem->data);
|
||||
gd->network = ril_network_ref(modem->network);
|
||||
gd->gprs = gprs;
|
||||
ofono_gprs_set_data(gprs, gd);
|
||||
|
||||
/* ofono crashes if we register right away */
|
||||
gd->register_id = g_idle_add(ril_gprs_register, gd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_gprs_remove(struct ofono_gprs *gprs)
|
||||
{
|
||||
struct ril_gprs *gd = ril_gprs_get_data(gprs);
|
||||
|
||||
DBG("%s", ril_modem_get_path(gd->md));
|
||||
ofono_gprs_set_data(gprs, NULL);
|
||||
|
||||
if (gd->set_attached_id) {
|
||||
g_source_remove(gd->set_attached_id);
|
||||
}
|
||||
|
||||
if (gd->register_id) {
|
||||
g_source_remove(gd->register_id);
|
||||
}
|
||||
|
||||
ril_network_remove_handler(gd->network, gd->network_event_id);
|
||||
ril_network_unref(gd->network);
|
||||
|
||||
ril_data_remove_handler(gd->data, gd->data_event_id);
|
||||
ril_data_unref(gd->data);
|
||||
|
||||
grilio_channel_unref(gd->io);
|
||||
grilio_queue_cancel_all(gd->q, FALSE);
|
||||
grilio_queue_unref(gd->q);
|
||||
g_free(gd);
|
||||
}
|
||||
|
||||
const struct ofono_gprs_driver ril_gprs_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_gprs_probe,
|
||||
.remove = ril_gprs_remove,
|
||||
.set_attached = ril_gprs_set_attached,
|
||||
.attached_status = ril_gprs_registration_status,
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,602 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_network.h"
|
||||
#include "ril_data.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <gutil_strv.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
|
||||
#include "ofono.h"
|
||||
#include "common.h"
|
||||
#include "mtu-watch.h"
|
||||
|
||||
#define CTX_ID_NONE ((unsigned int)(-1))
|
||||
|
||||
#define MAX_MTU 1280
|
||||
|
||||
struct ril_gprs_context_call {
|
||||
struct ril_data_request *req;
|
||||
ofono_gprs_context_cb_t cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
struct ril_gprs_context {
|
||||
struct ofono_gprs_context *gc;
|
||||
struct ril_modem *modem;
|
||||
struct ril_network *network;
|
||||
struct ril_data *data;
|
||||
guint active_ctx_cid;
|
||||
gulong calls_changed_id;
|
||||
struct mtu_watch *mtu_watch;
|
||||
struct ril_data_call *active_call;
|
||||
struct ril_gprs_context_call activate;
|
||||
struct ril_gprs_context_call deactivate;
|
||||
};
|
||||
|
||||
static inline struct ril_gprs_context *ril_gprs_context_get_data(
|
||||
struct ofono_gprs_context *gprs)
|
||||
{
|
||||
return ofono_gprs_context_get_data(gprs);
|
||||
}
|
||||
|
||||
static char *ril_gprs_context_netmask(const char *bits)
|
||||
{
|
||||
if (bits) {
|
||||
int nbits = atoi(bits);
|
||||
if (nbits > 0 && nbits < 33) {
|
||||
const char* str;
|
||||
struct in_addr in;
|
||||
in.s_addr = htonl((nbits == 32) ? 0xffffffff :
|
||||
((1u << nbits)-1) << (32-nbits));
|
||||
str = inet_ntoa(in);
|
||||
if (str) {
|
||||
return g_strdup(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int ril_gprs_context_address_family(const char *addr)
|
||||
{
|
||||
if (strchr(addr, ':')) {
|
||||
return AF_INET6;
|
||||
} else if (strchr(addr, '.')) {
|
||||
return AF_INET;
|
||||
} else {
|
||||
return AF_UNSPEC;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_gprs_context_free_active_call(struct ril_gprs_context *gcd)
|
||||
{
|
||||
if (gcd->active_call) {
|
||||
ril_data_call_release(gcd->data, gcd->active_call->cid, gcd);
|
||||
ril_data_call_free(gcd->active_call);
|
||||
gcd->active_call = NULL;
|
||||
}
|
||||
if (gcd->calls_changed_id) {
|
||||
ril_data_remove_handler(gcd->data, gcd->calls_changed_id);
|
||||
gcd->calls_changed_id = 0;
|
||||
}
|
||||
if (gcd->mtu_watch) {
|
||||
mtu_watch_free(gcd->mtu_watch);
|
||||
gcd->mtu_watch = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_gprs_context_set_active_call(struct ril_gprs_context *gcd,
|
||||
const struct ril_data_call *call)
|
||||
{
|
||||
if (call) {
|
||||
ril_data_call_free(gcd->active_call);
|
||||
gcd->active_call = ril_data_call_dup(call);
|
||||
if (!gcd->mtu_watch) {
|
||||
gcd->mtu_watch = mtu_watch_new(MAX_MTU);
|
||||
}
|
||||
mtu_watch_set_ifname(gcd->mtu_watch, call->ifname);
|
||||
ril_data_call_grab(gcd->data, call->cid, gcd);
|
||||
} else {
|
||||
ril_gprs_context_free_active_call(gcd);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_gprs_context_set_disconnected(struct ril_gprs_context *gcd)
|
||||
{
|
||||
if (gcd->active_call) {
|
||||
ril_gprs_context_free_active_call(gcd);
|
||||
if (gcd->deactivate.req) {
|
||||
struct ril_gprs_context_call deact = gcd->deactivate;
|
||||
|
||||
/*
|
||||
* Complete the deactivate request. We need to
|
||||
* clear gcd->deactivate first because cancelling
|
||||
* the deactivation request will probably result
|
||||
* in ril_gprs_context_deactivate_primary_cb() being
|
||||
* invoked with GRILIO_CANCELLED status. And we don't
|
||||
* want to fail the disconnect request because this
|
||||
* is a success (we wanted to disconnect the data
|
||||
* call and it's gone).
|
||||
*
|
||||
* Additionally, we need to make sure that we don't
|
||||
* complete the same request twice - that would crash
|
||||
* the core.
|
||||
*/
|
||||
memset(&gcd->deactivate, 0, sizeof(gcd->deactivate));
|
||||
ril_data_request_cancel(deact.req);
|
||||
if (deact.cb) {
|
||||
struct ofono_error error;
|
||||
ofono_info("Deactivated data call");
|
||||
deact.cb(ril_error_ok(&error), deact.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (gcd->active_ctx_cid != CTX_ID_NONE) {
|
||||
guint id = gcd->active_ctx_cid;
|
||||
gcd->active_ctx_cid = CTX_ID_NONE;
|
||||
DBG("ofono context %u deactivated", id);
|
||||
ofono_gprs_context_deactivated(gcd->gc, id);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_gprs_context_set_address(struct ofono_gprs_context *gc,
|
||||
const struct ril_data_call *call)
|
||||
{
|
||||
const char *ip_addr = NULL;
|
||||
char *ip_mask = NULL;
|
||||
const char *ipv6_addr = NULL;
|
||||
unsigned char ipv6_prefix_length = 0;
|
||||
char *tmp_ip_addr = NULL;
|
||||
char *tmp_ipv6_addr = NULL;
|
||||
char * const *list = call->addresses;
|
||||
const int n = gutil_strv_length(list);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < n && (!ipv6_addr || !ip_addr); i++) {
|
||||
const char *addr = list[i];
|
||||
switch (ril_gprs_context_address_family(addr)) {
|
||||
case AF_INET:
|
||||
if (!ip_addr) {
|
||||
const char* s = strstr(addr, "/");
|
||||
if (s) {
|
||||
const gsize len = s - addr;
|
||||
tmp_ip_addr = g_strndup(addr, len);
|
||||
ip_addr = tmp_ip_addr;
|
||||
ip_mask = ril_gprs_context_netmask(s+1);
|
||||
} else {
|
||||
ip_addr = addr;
|
||||
}
|
||||
if (!ip_mask) {
|
||||
ip_mask = g_strdup("255.255.255.0");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case AF_INET6:
|
||||
if (!ipv6_addr) {
|
||||
const char* s = strstr(addr, "/");
|
||||
if (s) {
|
||||
const gsize len = s - addr;
|
||||
const int prefix = atoi(s + 1);
|
||||
tmp_ipv6_addr = g_strndup(addr, len);
|
||||
ipv6_addr = tmp_ipv6_addr;
|
||||
if (prefix >= 0 && prefix <= 128) {
|
||||
ipv6_prefix_length = prefix;
|
||||
}
|
||||
} else {
|
||||
ipv6_addr = addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ofono_gprs_context_set_ipv4_address(gc, ip_addr, TRUE);
|
||||
ofono_gprs_context_set_ipv4_netmask(gc, ip_mask);
|
||||
ofono_gprs_context_set_ipv6_address(gc, ipv6_addr);
|
||||
ofono_gprs_context_set_ipv6_prefix_length(gc, ipv6_prefix_length);
|
||||
|
||||
if (!ip_addr && !ipv6_addr) {
|
||||
ofono_error("GPRS context: No IP address");
|
||||
}
|
||||
|
||||
/* Allocate temporary strings */
|
||||
g_free(ip_mask);
|
||||
g_free(tmp_ip_addr);
|
||||
g_free(tmp_ipv6_addr);
|
||||
}
|
||||
|
||||
static void ril_gprs_context_set_gateway(struct ofono_gprs_context *gc,
|
||||
const struct ril_data_call *call)
|
||||
{
|
||||
const char *ip_gw = NULL;
|
||||
const char *ipv6_gw = NULL;
|
||||
char * const *list = call->gateways;
|
||||
const int n = gutil_strv_length(list);
|
||||
int i;
|
||||
|
||||
/* Pick 1 gw for each protocol*/
|
||||
for (i = 0; i < n && (!ipv6_gw || !ip_gw); i++) {
|
||||
const char *addr = list[i];
|
||||
switch (ril_gprs_context_address_family(addr)) {
|
||||
case AF_INET:
|
||||
if (!ip_gw) ip_gw = addr;
|
||||
break;
|
||||
case AF_INET6:
|
||||
if (!ipv6_gw) ipv6_gw = addr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ofono_gprs_context_set_ipv4_gateway(gc, ip_gw);
|
||||
ofono_gprs_context_set_ipv6_gateway(gc, ipv6_gw);
|
||||
}
|
||||
|
||||
static void ril_gprs_context_set_dns_servers(struct ofono_gprs_context *gc,
|
||||
const struct ril_data_call *call)
|
||||
{
|
||||
int i;
|
||||
char * const *list = call->dnses;
|
||||
const int n = gutil_strv_length(list);
|
||||
const char **ip_dns = g_new0(const char *, n+1);
|
||||
const char **ipv6_dns = g_new0(const char *, n+1);
|
||||
const char **ip_ptr = ip_dns;
|
||||
const char **ipv6_ptr = ipv6_dns;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
const char *addr = list[i];
|
||||
switch (ril_gprs_context_address_family(addr)) {
|
||||
case AF_INET:
|
||||
*ip_ptr++ = addr;
|
||||
break;
|
||||
case AF_INET6:
|
||||
*ipv6_ptr++ = addr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ofono_gprs_context_set_ipv4_dns_servers(gc, ip_dns);
|
||||
ofono_gprs_context_set_ipv6_dns_servers(gc, ipv6_dns);
|
||||
|
||||
g_free(ip_dns);
|
||||
g_free(ipv6_dns);
|
||||
}
|
||||
|
||||
/* Only compares the stuff that's important to us */
|
||||
#define DATA_CALL_IFNAME_CHANGED (0x01)
|
||||
#define DATA_CALL_ADDRESS_CHANGED (0x02)
|
||||
#define DATA_CALL_GATEWAY_CHANGED (0x04)
|
||||
#define DATA_CALL_DNS_CHANGED (0x08)
|
||||
#define DATA_CALL_ALL_CHANGED (0x0f)
|
||||
static int ril_gprs_context_data_call_change(
|
||||
const struct ril_data_call *c1,
|
||||
const struct ril_data_call *c2)
|
||||
{
|
||||
if (!c1 && !c2) {
|
||||
return 0;
|
||||
} else if (c1 && c2) {
|
||||
int changes = 0;
|
||||
|
||||
if (g_strcmp0(c1->ifname, c2->ifname)) {
|
||||
changes |= DATA_CALL_IFNAME_CHANGED;
|
||||
}
|
||||
|
||||
if (!gutil_strv_equal(c1->addresses, c2->addresses)) {
|
||||
changes |= DATA_CALL_ADDRESS_CHANGED;
|
||||
}
|
||||
|
||||
if (!gutil_strv_equal(c1->gateways, c2->gateways)) {
|
||||
changes |= DATA_CALL_GATEWAY_CHANGED;
|
||||
}
|
||||
|
||||
if (!gutil_strv_equal(c1->dnses, c2->dnses)) {
|
||||
changes |= DATA_CALL_DNS_CHANGED;
|
||||
}
|
||||
|
||||
return changes;
|
||||
} else {
|
||||
return DATA_CALL_ALL_CHANGED;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_gprs_context_call_list_changed(struct ril_data *data, void *arg)
|
||||
{
|
||||
struct ril_gprs_context *gcd = arg;
|
||||
struct ofono_gprs_context *gc = gcd->gc;
|
||||
|
||||
/*
|
||||
* gcd->active_call can't be NULL here because this callback
|
||||
* is only registered when we have the active call and released
|
||||
* when active call is dropped.
|
||||
*/
|
||||
struct ril_data_call *prev_call = gcd->active_call;
|
||||
const struct ril_data_call *call =
|
||||
ril_data_call_find(data->data_calls, prev_call->cid);
|
||||
int change = 0;
|
||||
|
||||
if (call && call->active != RIL_DATA_CALL_INACTIVE) {
|
||||
/* Compare it against the last known state */
|
||||
change = ril_gprs_context_data_call_change(call, prev_call);
|
||||
} else {
|
||||
ofono_error("Clearing active context");
|
||||
ril_gprs_context_set_disconnected(gcd);
|
||||
call = NULL;
|
||||
}
|
||||
|
||||
if (!call) {
|
||||
/* We are not interested */
|
||||
return;
|
||||
} else if (!change) {
|
||||
DBG("call %u didn't change", call->cid);
|
||||
return;
|
||||
} else {
|
||||
DBG("call %u changed", call->cid);
|
||||
}
|
||||
|
||||
/*
|
||||
* prev_call points to the previous active call, and it will
|
||||
* be deallocated at the end of the this function. Clear the
|
||||
* gcd->active_call pointer so that we don't deallocate it twice.
|
||||
*/
|
||||
gcd->active_call = NULL;
|
||||
ril_gprs_context_set_active_call(gcd, call);
|
||||
|
||||
if (call->status != PDP_FAIL_NONE) {
|
||||
ofono_info("data call status: %d", call->status);
|
||||
}
|
||||
|
||||
if (change & DATA_CALL_IFNAME_CHANGED) {
|
||||
DBG("interface changed");
|
||||
ofono_gprs_context_set_interface(gc, call->ifname);
|
||||
}
|
||||
|
||||
if (change & DATA_CALL_ADDRESS_CHANGED) {
|
||||
DBG("address changed");
|
||||
ril_gprs_context_set_address(gc, call);
|
||||
}
|
||||
|
||||
if (change & DATA_CALL_GATEWAY_CHANGED) {
|
||||
DBG("gateway changed");
|
||||
ril_gprs_context_set_gateway(gc, call);
|
||||
}
|
||||
|
||||
if (change & DATA_CALL_DNS_CHANGED) {
|
||||
DBG("name server(s) changed");
|
||||
ril_gprs_context_set_dns_servers(gc, call);
|
||||
}
|
||||
|
||||
ofono_gprs_context_signal_change(gc, gcd->active_ctx_cid);
|
||||
ril_data_call_free(prev_call);
|
||||
}
|
||||
|
||||
static void ril_gprs_context_activate_primary_cb(struct ril_data *data,
|
||||
int ril_status, const struct ril_data_call *call,
|
||||
void *user_data)
|
||||
{
|
||||
struct ril_gprs_context *gcd = user_data;
|
||||
struct ofono_gprs_context *gc = gcd->gc;
|
||||
struct ofono_error error;
|
||||
ofono_gprs_context_cb_t cb;
|
||||
gpointer cb_data;
|
||||
|
||||
ril_error_init_failure(&error);
|
||||
if (ril_status != RIL_E_SUCCESS) {
|
||||
ofono_error("GPRS context: Reply failure: %s",
|
||||
ril_error_to_string(ril_status));
|
||||
} else if (!call) {
|
||||
ofono_error("Unexpected data call failure");
|
||||
} else if (call->status != PDP_FAIL_NONE) {
|
||||
ofono_error("Unexpected data call status %d", call->status);
|
||||
error.type = OFONO_ERROR_TYPE_CMS;
|
||||
error.error = call->status;
|
||||
} else if (!call->ifname) {
|
||||
/* Must have interface */
|
||||
ofono_error("GPRS context: No interface");
|
||||
} else {
|
||||
ofono_info("setting up data call");
|
||||
|
||||
GASSERT(!gcd->calls_changed_id);
|
||||
ril_data_remove_handler(gcd->data, gcd->calls_changed_id);
|
||||
gcd->calls_changed_id =
|
||||
ril_data_add_calls_changed_handler(gcd->data,
|
||||
ril_gprs_context_call_list_changed, gcd);
|
||||
|
||||
ril_gprs_context_set_active_call(gcd, call);
|
||||
ofono_gprs_context_set_interface(gc, call->ifname);
|
||||
ril_gprs_context_set_address(gc, call);
|
||||
ril_gprs_context_set_gateway(gc, call);
|
||||
ril_gprs_context_set_dns_servers(gc, call);
|
||||
ril_error_init_ok(&error);
|
||||
}
|
||||
|
||||
if (error.type != OFONO_ERROR_TYPE_NO_ERROR) {
|
||||
gcd->active_ctx_cid = CTX_ID_NONE;
|
||||
}
|
||||
|
||||
cb = gcd->activate.cb;
|
||||
cb_data = gcd->activate.data;
|
||||
GASSERT(gcd->activate.req);
|
||||
memset(&gcd->activate, 0, sizeof(gcd->activate));
|
||||
|
||||
if (cb) {
|
||||
cb(&error, cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_gprs_context_activate_primary(struct ofono_gprs_context *gc,
|
||||
const struct ofono_gprs_primary_context *ctx,
|
||||
ofono_gprs_context_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_gprs_context *gcd = ril_gprs_context_get_data(gc);
|
||||
struct ofono_netreg *netreg = ril_modem_ofono_netreg(gcd->modem);
|
||||
const int rs = ofono_netreg_get_status(netreg);
|
||||
|
||||
/* Let's make sure that we aren't connecting when roaming not allowed */
|
||||
if (rs == NETWORK_REGISTRATION_STATUS_ROAMING) {
|
||||
struct ofono_gprs *gprs = ril_modem_ofono_gprs(gcd->modem);
|
||||
if (!__ofono_gprs_get_roaming_allowed(gprs) &&
|
||||
ril_netreg_check_if_really_roaming(netreg, rs) ==
|
||||
NETWORK_REGISTRATION_STATUS_ROAMING) {
|
||||
struct ofono_error error;
|
||||
ofono_info("Can't activate context %u (roaming)",
|
||||
ctx->cid);
|
||||
cb(ril_error_failure(&error), data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ofono_info("Activating context: %u", ctx->cid);
|
||||
GASSERT(!gcd->activate.req);
|
||||
GASSERT(ctx->cid != CTX_ID_NONE);
|
||||
|
||||
gcd->active_ctx_cid = ctx->cid;
|
||||
gcd->activate.cb = cb;
|
||||
gcd->activate.data = data;
|
||||
gcd->activate.req = ril_data_call_setup(gcd->data, ctx,
|
||||
ril_gprs_context_activate_primary_cb, gcd);
|
||||
}
|
||||
|
||||
static void ril_gprs_context_deactivate_primary_cb(struct ril_data *data,
|
||||
int ril_status, void *user_data)
|
||||
{
|
||||
struct ril_gprs_context *gcd = user_data;
|
||||
|
||||
/*
|
||||
* Data call list may change before the completion of the deactivate
|
||||
* request, in that case ril_gprs_context_set_disconnected will be
|
||||
* invoked and gcd->deactivate.req will be NULL.
|
||||
*/
|
||||
if (gcd->deactivate.req) {
|
||||
struct ofono_error error;
|
||||
ofono_gprs_context_cb_t cb = gcd->deactivate.cb;
|
||||
gpointer cb_data = gcd->deactivate.data;
|
||||
|
||||
if (ril_status == RIL_E_SUCCESS) {
|
||||
GASSERT(gcd->active_call);
|
||||
ril_error_init_ok(&error);
|
||||
ofono_info("Deactivated data call");
|
||||
} else {
|
||||
ril_error_init_failure(&error);
|
||||
ofono_error("Deactivate failure: %s",
|
||||
ril_error_to_string(ril_status));
|
||||
}
|
||||
|
||||
memset(&gcd->deactivate, 0, sizeof(gcd->deactivate));
|
||||
if (cb) {
|
||||
ril_gprs_context_free_active_call(gcd);
|
||||
cb(&error, cb_data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure we are in the disconnected state */
|
||||
ril_gprs_context_set_disconnected(gcd);
|
||||
}
|
||||
|
||||
static void ril_gprs_context_deactivate_primary(struct ofono_gprs_context *gc,
|
||||
unsigned int id, ofono_gprs_context_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_gprs_context *gcd = ril_gprs_context_get_data(gc);
|
||||
|
||||
GASSERT(gcd->active_call && gcd->active_ctx_cid == id);
|
||||
ofono_info("Deactivating context: %u", id);
|
||||
|
||||
if (gcd->active_call && gcd->active_ctx_cid == id) {
|
||||
gcd->deactivate.cb = cb;
|
||||
gcd->deactivate.data = data;
|
||||
gcd->deactivate.req = ril_data_call_deactivate(gcd->data,
|
||||
gcd->active_call->cid,
|
||||
ril_gprs_context_deactivate_primary_cb, gcd);
|
||||
} else if (cb) {
|
||||
struct ofono_error error;
|
||||
cb(ril_error_ok(&error), data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_gprs_context_detach_shutdown(struct ofono_gprs_context *gc,
|
||||
unsigned int id)
|
||||
{
|
||||
DBG("%u", id);
|
||||
ril_gprs_context_deactivate_primary(gc, id, NULL, NULL);
|
||||
}
|
||||
|
||||
static int ril_gprs_context_probe(struct ofono_gprs_context *gc,
|
||||
unsigned int vendor, void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_gprs_context *gcd = g_new0(struct ril_gprs_context, 1);
|
||||
|
||||
DBG("");
|
||||
gcd->gc = gc;
|
||||
gcd->modem = modem;
|
||||
gcd->network = ril_network_ref(modem->network);
|
||||
gcd->data = ril_data_ref(modem->data);
|
||||
gcd->active_ctx_cid = CTX_ID_NONE;
|
||||
ofono_gprs_context_set_data(gc, gcd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_gprs_context_remove(struct ofono_gprs_context *gc)
|
||||
{
|
||||
struct ril_gprs_context *gcd = ril_gprs_context_get_data(gc);
|
||||
|
||||
DBG("");
|
||||
ofono_gprs_context_set_data(gc, NULL);
|
||||
|
||||
if (gcd->activate.req) {
|
||||
/*
|
||||
* The core has already completed its pending D-Bus
|
||||
* request, invoking the completion callback will
|
||||
* cause libdbus to panic.
|
||||
*/
|
||||
ril_data_request_detach(gcd->activate.req);
|
||||
ril_data_request_cancel(gcd->activate.req);
|
||||
}
|
||||
|
||||
if (gcd->deactivate.req) {
|
||||
/* Let it complete but we won't be around to be notified. */
|
||||
ril_data_request_detach(gcd->deactivate.req);
|
||||
} else if (gcd->active_call) {
|
||||
ril_data_call_deactivate(gcd->data, gcd->active_call->cid,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
ril_data_remove_handler(gcd->data, gcd->calls_changed_id);
|
||||
ril_data_unref(gcd->data);
|
||||
ril_network_unref(gcd->network);
|
||||
ril_data_call_free(gcd->active_call);
|
||||
mtu_watch_free(gcd->mtu_watch);
|
||||
g_free(gcd);
|
||||
}
|
||||
|
||||
const struct ofono_gprs_context_driver ril_gprs_context_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_gprs_context_probe,
|
||||
.remove = ril_gprs_context_remove,
|
||||
.activate_primary = ril_gprs_context_activate_primary,
|
||||
.deactivate_primary = ril_gprs_context_deactivate_primary,
|
||||
.detach_shutdown = ril_gprs_context_detach_shutdown,
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,518 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_network.h"
|
||||
#include "ril_radio.h"
|
||||
#include "ril_sim_card.h"
|
||||
#include "ril_sim_settings.h"
|
||||
#include "ril_cell_info.h"
|
||||
#include "ril_data.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "ofono.h"
|
||||
|
||||
#include "sailfish_watch.h"
|
||||
|
||||
#define MAX_PDP_CONTEXTS (2)
|
||||
#define ONLINE_TIMEOUT_SECS (15) /* 20 sec is hardcoded in ofono core */
|
||||
|
||||
enum ril_modem_power_state {
|
||||
POWERED_OFF,
|
||||
POWERED_ON,
|
||||
POWERING_OFF
|
||||
};
|
||||
|
||||
enum ril_modem_online_state {
|
||||
OFFLINE,
|
||||
GOING_ONLINE,
|
||||
ONLINE,
|
||||
GOING_OFFLINE
|
||||
};
|
||||
|
||||
struct ril_modem_online_request {
|
||||
ofono_modem_online_cb_t cb;
|
||||
struct ril_modem_data *md;
|
||||
void *data;
|
||||
guint timeout_id;
|
||||
};
|
||||
|
||||
struct ril_modem_data {
|
||||
struct ril_modem modem;
|
||||
struct sailfish_watch *watch;
|
||||
GRilIoQueue *q;
|
||||
char *log_prefix;
|
||||
char *imeisv;
|
||||
char *imei;
|
||||
char *ecclist_file;
|
||||
gulong imsi_event_id;
|
||||
|
||||
guint online_check_id;
|
||||
enum ril_modem_power_state power_state;
|
||||
gulong radio_state_event_id;
|
||||
|
||||
struct ril_modem_online_request set_online;
|
||||
struct ril_modem_online_request set_offline;
|
||||
};
|
||||
|
||||
#define RADIO_POWER_TAG(md) (md)
|
||||
|
||||
#define DBG_(md,fmt,args...) DBG("%s" fmt, (md)->log_prefix, ##args)
|
||||
|
||||
static struct ril_modem_data *ril_modem_data_from_ofono(struct ofono_modem *o)
|
||||
{
|
||||
struct ril_modem_data *md = ofono_modem_get_data(o);
|
||||
GASSERT(md->modem.ofono == o);
|
||||
return md;
|
||||
}
|
||||
|
||||
static void *ril_modem_get_atom_data(struct ril_modem *modem,
|
||||
enum ofono_atom_type type)
|
||||
{
|
||||
if (modem && modem->ofono) {
|
||||
struct ofono_atom *atom =
|
||||
__ofono_modem_find_atom(modem->ofono, type);
|
||||
|
||||
if (atom) {
|
||||
return __ofono_atom_get_data(atom);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ofono_sim *ril_modem_ofono_sim(struct ril_modem *modem)
|
||||
{
|
||||
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_SIM);
|
||||
}
|
||||
|
||||
struct ofono_gprs *ril_modem_ofono_gprs(struct ril_modem *modem)
|
||||
{
|
||||
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_GPRS);
|
||||
}
|
||||
|
||||
struct ofono_netreg *ril_modem_ofono_netreg(struct ril_modem *modem)
|
||||
{
|
||||
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_NETREG);
|
||||
}
|
||||
|
||||
static inline struct ofono_radio_settings *ril_modem_radio_settings(
|
||||
struct ril_modem *modem)
|
||||
{
|
||||
return ril_modem_get_atom_data(modem, OFONO_ATOM_TYPE_RADIO_SETTINGS);
|
||||
}
|
||||
|
||||
void ril_modem_delete(struct ril_modem *md)
|
||||
{
|
||||
if (md && md->ofono) {
|
||||
ofono_modem_remove(md->ofono);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_modem_online_request_ok(struct ril_modem_online_request *req)
|
||||
{
|
||||
if (req->timeout_id) {
|
||||
g_source_remove(req->timeout_id);
|
||||
req->timeout_id = 0;
|
||||
}
|
||||
|
||||
if (req->cb) {
|
||||
struct ofono_error error;
|
||||
ofono_modem_online_cb_t cb = req->cb;
|
||||
void *data = req->data;
|
||||
|
||||
req->cb = NULL;
|
||||
req->data = NULL;
|
||||
cb(ril_error_ok(&error), data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_modem_update_online_state(struct ril_modem_data *md)
|
||||
{
|
||||
switch (md->modem.radio->state) {
|
||||
case RADIO_STATE_ON:
|
||||
DBG("online");
|
||||
ril_modem_online_request_ok(&md->set_online);
|
||||
break;
|
||||
|
||||
case RADIO_STATE_OFF:
|
||||
case RADIO_STATE_UNAVAILABLE:
|
||||
DBG("offline");
|
||||
ril_modem_online_request_ok(&md->set_offline);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (!md->set_offline.timeout_id && !md->set_online.timeout_id &&
|
||||
md->power_state == POWERING_OFF) {
|
||||
md->power_state = POWERED_OFF;
|
||||
if (md->modem.ofono) {
|
||||
ofono_modem_set_powered(md->modem.ofono, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean ril_modem_online_request_timeout(gpointer data)
|
||||
{
|
||||
struct ril_modem_online_request *req = data;
|
||||
struct ofono_error error;
|
||||
ofono_modem_online_cb_t cb = req->cb;
|
||||
void *cb_data = req->data;
|
||||
|
||||
GASSERT(req->timeout_id);
|
||||
GASSERT(cb);
|
||||
|
||||
req->timeout_id = 0;
|
||||
req->cb = NULL;
|
||||
req->data = NULL;
|
||||
cb(ril_error_failure(&error), cb_data);
|
||||
ril_modem_update_online_state(req->md);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static gboolean ril_modem_online_check(gpointer data)
|
||||
{
|
||||
struct ril_modem_data *md = data;
|
||||
|
||||
GASSERT(md->online_check_id);
|
||||
md->online_check_id = 0;
|
||||
ril_modem_update_online_state(md);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void ril_modem_schedule_online_check(struct ril_modem_data *md)
|
||||
{
|
||||
if (!md->online_check_id) {
|
||||
md->online_check_id = g_idle_add(ril_modem_online_check, md);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_modem_update_radio_settings(struct ril_modem_data *md)
|
||||
{
|
||||
struct ril_modem *m = &md->modem;
|
||||
if (m->radio->state == RADIO_STATE_ON && md->watch->imsi) {
|
||||
/* radio-settings.c assumes that IMSI is available */
|
||||
if (!ril_modem_radio_settings(m)) {
|
||||
DBG_(md, "initializing radio settings interface");
|
||||
ofono_radio_settings_create(m->ofono, 0,
|
||||
RILMODEM_DRIVER, md);
|
||||
}
|
||||
} else {
|
||||
/* ofono core may remove radio settings atom internally */
|
||||
struct ofono_radio_settings *rs = ril_modem_radio_settings(m);
|
||||
if (rs) {
|
||||
DBG_(md, "removing radio settings interface");
|
||||
ofono_radio_settings_remove(rs);
|
||||
} else {
|
||||
DBG_(md, "radio settings interface is already gone");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_modem_radio_state_cb(struct ril_radio *radio, void *data)
|
||||
{
|
||||
struct ril_modem_data *md = data;
|
||||
|
||||
GASSERT(md->modem.radio == radio);
|
||||
ril_modem_update_radio_settings(md);
|
||||
ril_modem_update_online_state(md);
|
||||
}
|
||||
|
||||
static void ril_modem_imsi_cb(struct sailfish_watch *watch, void *data)
|
||||
{
|
||||
struct ril_modem_data *md = data;
|
||||
|
||||
GASSERT(md->watch == watch);
|
||||
ril_modem_update_radio_settings(md);
|
||||
}
|
||||
|
||||
static void ril_modem_pre_sim(struct ofono_modem *modem)
|
||||
{
|
||||
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
|
||||
|
||||
DBG("%s", ofono_modem_get_path(modem));
|
||||
ofono_devinfo_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
ofono_sim_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
if (md->modem.config.enable_voicecall) {
|
||||
ofono_voicecall_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
}
|
||||
if (!md->radio_state_event_id) {
|
||||
md->radio_state_event_id =
|
||||
ril_radio_add_state_changed_handler(md->modem.radio,
|
||||
ril_modem_radio_state_cb, md);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_modem_post_sim(struct ofono_modem *modem)
|
||||
{
|
||||
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
|
||||
struct ofono_gprs *gprs;
|
||||
|
||||
DBG("%s", ofono_modem_get_path(modem));
|
||||
ofono_sms_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
gprs = ofono_gprs_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
if (gprs) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_PDP_CONTEXTS; i++) {
|
||||
struct ofono_gprs_context *gc =
|
||||
ofono_gprs_context_create(modem, 0,
|
||||
RILMODEM_DRIVER, md);
|
||||
if (gc == NULL)
|
||||
break;
|
||||
|
||||
ofono_gprs_add_context(gprs, gc);
|
||||
}
|
||||
}
|
||||
|
||||
ofono_phonebook_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
ofono_call_forwarding_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
ofono_call_barring_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
ofono_stk_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
ofono_message_waiting_register(ofono_message_waiting_create(modem));
|
||||
if (md->modem.config.enable_cbs) {
|
||||
ofono_cbs_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_modem_post_online(struct ofono_modem *modem)
|
||||
{
|
||||
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
|
||||
|
||||
DBG("%s", ofono_modem_get_path(modem));
|
||||
ofono_call_volume_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
ofono_netreg_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
ofono_ussd_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
ofono_call_settings_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
ofono_netmon_create(modem, 0, RILMODEM_DRIVER, md);
|
||||
}
|
||||
|
||||
static void ril_modem_set_online(struct ofono_modem *modem, ofono_bool_t online,
|
||||
ofono_modem_online_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
|
||||
struct ril_radio *radio = md->modem.radio;
|
||||
struct ril_modem_online_request *req;
|
||||
|
||||
DBG("%s going %sline", ofono_modem_get_path(modem),
|
||||
online ? "on" : "off");
|
||||
|
||||
ril_radio_set_online(radio, online);
|
||||
if (online) {
|
||||
ril_radio_power_on(radio, RADIO_POWER_TAG(md));
|
||||
req = &md->set_online;
|
||||
} else {
|
||||
ril_radio_power_off(radio, RADIO_POWER_TAG(md));
|
||||
req = &md->set_offline;
|
||||
}
|
||||
|
||||
req->cb = cb;
|
||||
req->data = data;
|
||||
if (req->timeout_id) {
|
||||
g_source_remove(req->timeout_id);
|
||||
}
|
||||
req->timeout_id = g_timeout_add_seconds(ONLINE_TIMEOUT_SECS,
|
||||
ril_modem_online_request_timeout, req);
|
||||
ril_modem_schedule_online_check(md);
|
||||
}
|
||||
|
||||
static int ril_modem_enable(struct ofono_modem *modem)
|
||||
{
|
||||
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
|
||||
|
||||
DBG("%s", ofono_modem_get_path(modem));
|
||||
md->power_state = POWERED_ON;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ril_modem_disable(struct ofono_modem *modem)
|
||||
{
|
||||
struct ril_modem_data *md = ril_modem_data_from_ofono(modem);
|
||||
|
||||
DBG("%s", ofono_modem_get_path(modem));
|
||||
if (md->set_online.timeout_id || md->set_offline.timeout_id) {
|
||||
md->power_state = POWERING_OFF;
|
||||
return -EINPROGRESS;
|
||||
} else {
|
||||
md->power_state = POWERED_OFF;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static int ril_modem_probe(struct ofono_modem *modem)
|
||||
{
|
||||
DBG("%s", ofono_modem_get_path(modem));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_modem_remove(struct ofono_modem *ofono)
|
||||
{
|
||||
struct ril_modem_data *md = ril_modem_data_from_ofono(ofono);
|
||||
struct ril_modem *modem = &md->modem;
|
||||
|
||||
DBG("%s", ril_modem_get_path(modem));
|
||||
ofono_modem_set_data(ofono, NULL);
|
||||
|
||||
ril_radio_remove_handler(modem->radio, md->radio_state_event_id);
|
||||
ril_radio_power_off(modem->radio, RADIO_POWER_TAG(md));
|
||||
ril_radio_unref(modem->radio);
|
||||
ril_sim_settings_unref(modem->sim_settings);
|
||||
|
||||
sailfish_watch_remove_handler(md->watch, md->imsi_event_id);
|
||||
sailfish_watch_unref(md->watch);
|
||||
|
||||
if (md->online_check_id) {
|
||||
g_source_remove(md->online_check_id);
|
||||
}
|
||||
|
||||
if (md->set_online.timeout_id) {
|
||||
g_source_remove(md->set_online.timeout_id);
|
||||
}
|
||||
|
||||
if (md->set_offline.timeout_id) {
|
||||
g_source_remove(md->set_offline.timeout_id);
|
||||
}
|
||||
|
||||
ril_network_unref(modem->network);
|
||||
ril_sim_card_unref(modem->sim_card);
|
||||
ril_data_unref(modem->data);
|
||||
sailfish_cell_info_unref(modem->cell_info);
|
||||
grilio_channel_unref(modem->io);
|
||||
grilio_queue_cancel_all(md->q, FALSE);
|
||||
grilio_queue_unref(md->q);
|
||||
g_free(md->ecclist_file);
|
||||
g_free(md->log_prefix);
|
||||
g_free(md->imeisv);
|
||||
g_free(md->imei);
|
||||
g_free(md);
|
||||
}
|
||||
|
||||
struct ril_modem *ril_modem_create(GRilIoChannel *io, const char *log_prefix,
|
||||
const char *path, const char *imei, const char *imeisv,
|
||||
const char *ecclist_file, const struct ril_slot_config *config,
|
||||
struct ril_radio *radio, struct ril_network *network,
|
||||
struct ril_sim_card *card, struct ril_data *data,
|
||||
struct ril_sim_settings *settings,
|
||||
struct sailfish_cell_info *cell_info)
|
||||
{
|
||||
/* Skip the slash from the path, it looks like "/ril_0" */
|
||||
struct ofono_modem *ofono = ofono_modem_create(path + 1,
|
||||
RILMODEM_DRIVER);
|
||||
if (ofono) {
|
||||
int err;
|
||||
struct ril_modem_data *md = g_new0(struct ril_modem_data, 1);
|
||||
struct ril_modem *modem = &md->modem;
|
||||
|
||||
/*
|
||||
* ril_plugin.c must wait until IMEI becomes known before
|
||||
* creating the modem
|
||||
*/
|
||||
GASSERT(imei);
|
||||
|
||||
/* Copy config */
|
||||
modem->config = *config;
|
||||
modem->imei = md->imei = g_strdup(imei);
|
||||
modem->imeisv = md->imeisv = g_strdup(imeisv);
|
||||
modem->log_prefix = log_prefix; /* No need to strdup */
|
||||
modem->ecclist_file = ecclist_file; /* No need to strdup */
|
||||
md->log_prefix = (log_prefix && log_prefix[0]) ?
|
||||
g_strconcat(log_prefix, " ", NULL) : g_strdup("");
|
||||
|
||||
modem->ofono = ofono;
|
||||
modem->radio = ril_radio_ref(radio);
|
||||
modem->network = ril_network_ref(network);
|
||||
modem->sim_card = ril_sim_card_ref(card);
|
||||
modem->sim_settings = ril_sim_settings_ref(settings);
|
||||
modem->cell_info = sailfish_cell_info_ref(cell_info);
|
||||
modem->data = ril_data_ref(data);
|
||||
modem->io = grilio_channel_ref(io);
|
||||
md->q = grilio_queue_new(io);
|
||||
md->watch = sailfish_watch_new(path);
|
||||
|
||||
md->imsi_event_id =
|
||||
sailfish_watch_add_imsi_changed_handler(md->watch,
|
||||
ril_modem_imsi_cb, md);
|
||||
|
||||
md->set_online.md = md;
|
||||
md->set_offline.md = md;
|
||||
ofono_modem_set_data(ofono, md);
|
||||
err = ofono_modem_register(ofono);
|
||||
if (!err) {
|
||||
GASSERT(io->connected);
|
||||
if (config->radio_power_cycle) {
|
||||
ril_radio_power_cycle(modem->radio);
|
||||
}
|
||||
|
||||
/*
|
||||
* ofono_modem_reset sets Powered to TRUE without
|
||||
* issuing PropertyChange signal.
|
||||
*/
|
||||
ofono_modem_set_powered(modem->ofono, FALSE);
|
||||
ofono_modem_set_powered(modem->ofono, TRUE);
|
||||
md->power_state = POWERED_ON;
|
||||
|
||||
/*
|
||||
* With some RIL implementations, querying available
|
||||
* band modes causes some magic Android properties to
|
||||
* appear.
|
||||
*/
|
||||
if (config->query_available_band_mode) {
|
||||
grilio_queue_send_request(md->q, NULL,
|
||||
RIL_REQUEST_QUERY_AVAILABLE_BAND_MODE);
|
||||
}
|
||||
|
||||
ril_modem_update_radio_settings(md);
|
||||
return modem;
|
||||
} else {
|
||||
ofono_error("Error %d registering %s",
|
||||
err, RILMODEM_DRIVER);
|
||||
|
||||
/*
|
||||
* If ofono_modem_register() failed, then
|
||||
* ofono_modem_remove() won't invoke
|
||||
* ril_modem_remove() callback.
|
||||
*/
|
||||
ril_modem_remove(ofono);
|
||||
}
|
||||
|
||||
ofono_modem_remove(ofono);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const struct ofono_modem_driver ril_modem_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_modem_probe,
|
||||
.remove = ril_modem_remove,
|
||||
.enable = ril_modem_enable,
|
||||
.disable = ril_modem_disable,
|
||||
.pre_sim = ril_modem_pre_sim,
|
||||
.post_sim = ril_modem_post_sim,
|
||||
.post_online = ril_modem_post_online,
|
||||
.set_online = ril_modem_set_online
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,324 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <sailfish_cell_info.h>
|
||||
|
||||
#include "ofono.h"
|
||||
|
||||
struct ril_netmon {
|
||||
struct ofono_netmon *netmon;
|
||||
struct sailfish_cell_info *cell_info;
|
||||
guint register_id;
|
||||
};
|
||||
|
||||
/* This number must be in sync with ril_netmon_notify_ofono: */
|
||||
#define RIL_NETMON_MAX_OFONO_PARAMS (8)
|
||||
|
||||
struct ril_netmon_ofono_param {
|
||||
enum ofono_netmon_info type;
|
||||
int value;
|
||||
};
|
||||
|
||||
static inline struct ril_netmon *ril_netmon_get_data(struct ofono_netmon *ofono)
|
||||
{
|
||||
return ofono ? ofono_netmon_get_data(ofono) : NULL;
|
||||
}
|
||||
|
||||
static void ril_netmon_format_mccmnc(char *s_mcc, char *s_mnc, int mcc, int mnc)
|
||||
{
|
||||
s_mcc[0] = 0;
|
||||
s_mnc[0] = 0;
|
||||
|
||||
if (mcc >= 0 && mcc <= 999) {
|
||||
snprintf(s_mcc, OFONO_MAX_MCC_LENGTH + 1, "%03d", mcc);
|
||||
if (mnc >= 0 && mnc <= 999) {
|
||||
const unsigned int mnclen = mnclength(mcc, mnc);
|
||||
const char *format[] = { "%d", "%02d", "%03d" };
|
||||
const char *fmt = (mnclen > 0 &&
|
||||
mnclen <= G_N_ELEMENTS(format)) ?
|
||||
format[mnclen - 1] : format[0];
|
||||
snprintf(s_mnc, OFONO_MAX_MNC_LENGTH + 1, fmt, mnc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_netmon_notify_ofono(struct ofono_netmon *netmon,
|
||||
enum ofono_netmon_cell_type type, int mcc, int mnc,
|
||||
struct ril_netmon_ofono_param *params, int nparams)
|
||||
{
|
||||
char s_mcc[OFONO_MAX_MCC_LENGTH + 1];
|
||||
char s_mnc[OFONO_MAX_MNC_LENGTH + 1];
|
||||
int i;
|
||||
|
||||
/* Better not to push uninitialized data to the stack ... */
|
||||
for (i = nparams; i < RIL_NETMON_MAX_OFONO_PARAMS; i++) {
|
||||
params[i].type = OFONO_NETMON_INFO_INVALID;
|
||||
params[i].value = SAILFISH_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
ril_netmon_format_mccmnc(s_mcc, s_mnc, mcc, mnc);
|
||||
ofono_netmon_serving_cell_notify(netmon, type,
|
||||
OFONO_NETMON_INFO_MCC, s_mcc,
|
||||
OFONO_NETMON_INFO_MNC, s_mnc,
|
||||
params[0].type, params[0].value,
|
||||
params[1].type, params[1].value,
|
||||
params[2].type, params[2].value,
|
||||
params[3].type, params[3].value,
|
||||
params[4].type, params[4].value,
|
||||
params[5].type, params[5].value,
|
||||
params[6].type, params[6].value,
|
||||
params[7].type, params[7].value,
|
||||
OFONO_NETMON_INFO_INVALID);
|
||||
}
|
||||
|
||||
static void ril_netmon_notify_gsm(struct ofono_netmon *netmon,
|
||||
const struct sailfish_cell_info_gsm *gsm)
|
||||
{
|
||||
struct ril_netmon_ofono_param params[RIL_NETMON_MAX_OFONO_PARAMS];
|
||||
int n = 0;
|
||||
|
||||
if (gsm->lac != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_LAC;
|
||||
params[n].value = gsm->lac;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (gsm->cid != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_CI;
|
||||
params[n].value = gsm->cid;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (gsm->arfcn != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_ARFCN;
|
||||
params[n].value = gsm->arfcn;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (gsm->signalStrength != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_RSSI;
|
||||
params[n].value = gsm->signalStrength;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (gsm->bitErrorRate != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_BER;
|
||||
params[n].value = gsm->bitErrorRate;
|
||||
n++;
|
||||
}
|
||||
|
||||
ril_netmon_notify_ofono(netmon, OFONO_NETMON_CELL_TYPE_GSM,
|
||||
gsm->mcc, gsm->mnc, params, n);
|
||||
}
|
||||
|
||||
static void ril_netmon_notify_wcdma(struct ofono_netmon *netmon,
|
||||
const struct sailfish_cell_info_wcdma *wcdma)
|
||||
{
|
||||
struct ril_netmon_ofono_param params[RIL_NETMON_MAX_OFONO_PARAMS];
|
||||
int n = 0;
|
||||
|
||||
if (wcdma->lac != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_LAC;
|
||||
params[n].value = wcdma->lac;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (wcdma->cid != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_CI;
|
||||
params[n].value = wcdma->cid;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (wcdma->psc != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_PSC;
|
||||
params[n].value = wcdma->psc;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (wcdma->uarfcn != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_ARFCN;
|
||||
params[n].value = wcdma->uarfcn;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (wcdma->signalStrength != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_RSSI;
|
||||
params[n].value = wcdma->signalStrength;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (wcdma->bitErrorRate != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_BER;
|
||||
params[n].value = wcdma->bitErrorRate;
|
||||
n++;
|
||||
}
|
||||
|
||||
ril_netmon_notify_ofono(netmon, OFONO_NETMON_CELL_TYPE_UMTS,
|
||||
wcdma->mcc, wcdma->mnc, params, n);
|
||||
}
|
||||
|
||||
static void ril_netmon_notify_lte(struct ofono_netmon *netmon,
|
||||
const struct sailfish_cell_info_lte *lte)
|
||||
{
|
||||
struct ril_netmon_ofono_param params[RIL_NETMON_MAX_OFONO_PARAMS];
|
||||
int n = 0;
|
||||
|
||||
if (lte->ci != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_CI;
|
||||
params[n].value = lte->ci;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->earfcn != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_EARFCN;
|
||||
params[n].value = lte->earfcn;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->signalStrength != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_RSSI;
|
||||
params[n].value = lte->signalStrength;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->rsrp != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_RSRQ;
|
||||
params[n].value = lte->rsrp;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->rsrq != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_RSRP;
|
||||
params[n].value = lte->rsrq;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->cqi != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_CQI;
|
||||
params[n].value = lte->cqi;
|
||||
n++;
|
||||
}
|
||||
|
||||
if (lte->timingAdvance != SAILFISH_CELL_INVALID_VALUE) {
|
||||
params[n].type = OFONO_NETMON_INFO_TIMING_ADVANCE;
|
||||
params[n].value = lte->timingAdvance;
|
||||
n++;
|
||||
}
|
||||
|
||||
ril_netmon_notify_ofono(netmon, OFONO_NETMON_CELL_TYPE_LTE,
|
||||
lte->mcc, lte->mnc, params, n);
|
||||
}
|
||||
|
||||
static void ril_netmon_request_update(struct ofono_netmon *netmon,
|
||||
ofono_netmon_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_netmon *nm = ril_netmon_get_data(netmon);
|
||||
struct ofono_error error;
|
||||
GSList *l;
|
||||
|
||||
for (l = nm->cell_info->cells; l; l = l->next) {
|
||||
const struct sailfish_cell *cell = l->data;
|
||||
|
||||
if (cell->registered) {
|
||||
switch (cell->type) {
|
||||
case SAILFISH_CELL_TYPE_GSM:
|
||||
ril_netmon_notify_gsm(netmon,
|
||||
&cell->info.gsm);
|
||||
break;
|
||||
case SAILFISH_CELL_TYPE_WCDMA:
|
||||
ril_netmon_notify_wcdma(netmon,
|
||||
&cell->info.wcdma);
|
||||
break;
|
||||
case SAILFISH_CELL_TYPE_LTE:
|
||||
ril_netmon_notify_lte(netmon,
|
||||
&cell->info.lte);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cb(ril_error_ok(&error), data);
|
||||
}
|
||||
|
||||
static gboolean ril_netmon_register(gpointer user_data)
|
||||
{
|
||||
struct ril_netmon *nm = user_data;
|
||||
|
||||
GASSERT(nm->register_id);
|
||||
nm->register_id = 0;
|
||||
ofono_netmon_register(nm->netmon);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static int ril_netmon_probe(struct ofono_netmon *netmon, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
int ret;
|
||||
|
||||
if (modem->cell_info) {
|
||||
struct ril_netmon *nm = g_slice_new0(struct ril_netmon);
|
||||
|
||||
nm->cell_info = sailfish_cell_info_ref(modem->cell_info);
|
||||
nm->netmon = netmon;
|
||||
|
||||
ofono_netmon_set_data(netmon, nm);
|
||||
nm->register_id = g_idle_add(ril_netmon_register, nm);
|
||||
ret = 0;
|
||||
} else {
|
||||
DBG("%s no", modem->log_prefix ? modem->log_prefix : "");
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
DBG("%s %d", modem->log_prefix ? modem->log_prefix : "", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ril_netmon_remove(struct ofono_netmon *netmon)
|
||||
{
|
||||
struct ril_netmon *nm = ril_netmon_get_data(netmon);
|
||||
|
||||
DBG("");
|
||||
ofono_netmon_set_data(netmon, NULL);
|
||||
|
||||
if (nm->register_id > 0) {
|
||||
g_source_remove(nm->register_id);
|
||||
}
|
||||
|
||||
sailfish_cell_info_unref(nm->cell_info);
|
||||
g_slice_free(struct ril_netmon, nm);
|
||||
}
|
||||
|
||||
const struct ofono_netmon_driver ril_netmon_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_netmon_probe,
|
||||
.remove = ril_netmon_remove,
|
||||
.request_update = ril_netmon_request_update,
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,580 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_network.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "simutil.h"
|
||||
|
||||
enum ril_netreg_events {
|
||||
NETREG_RIL_EVENT_NITZ_TIME_RECEIVED,
|
||||
NETREG_RIL_EVENT_SIGNAL_STRENGTH,
|
||||
NETREG_RIL_EVENT_COUNT
|
||||
};
|
||||
|
||||
enum ril_netreg_network_events {
|
||||
NETREG_NETWORK_EVENT_OPERATOR_CHANGED,
|
||||
NETREG_NETWORK_EVENT_VOICE_STATE_CHANGED,
|
||||
NETREG_NETWORK_EVENT_COUNT
|
||||
};
|
||||
|
||||
struct ril_netreg {
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
struct ofono_netreg *netreg;
|
||||
struct ril_network *network;
|
||||
char *log_prefix;
|
||||
guint timer_id;
|
||||
guint notify_id;
|
||||
guint current_operator_id;
|
||||
gulong ril_event_id[NETREG_RIL_EVENT_COUNT];
|
||||
gulong network_event_id[NETREG_NETWORK_EVENT_COUNT];
|
||||
};
|
||||
|
||||
struct ril_netreg_cbd {
|
||||
struct ril_netreg *nd;
|
||||
union {
|
||||
ofono_netreg_status_cb_t status;
|
||||
ofono_netreg_operator_cb_t operator;
|
||||
ofono_netreg_operator_list_cb_t operator_list;
|
||||
ofono_netreg_register_cb_t reg;
|
||||
ofono_netreg_strength_cb_t strength;
|
||||
gpointer ptr;
|
||||
} cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
#define ril_netreg_cbd_free g_free
|
||||
|
||||
#define DBG_(nd,fmt,args...) DBG("%s" fmt, (nd)->log_prefix, ##args)
|
||||
|
||||
static inline struct ril_netreg *ril_netreg_get_data(struct ofono_netreg *ofono)
|
||||
{
|
||||
return ofono ? ofono_netreg_get_data(ofono) : NULL;
|
||||
}
|
||||
|
||||
static struct ril_netreg_cbd *ril_netreg_cbd_new(struct ril_netreg *nd,
|
||||
void *cb, void *data)
|
||||
{
|
||||
struct ril_netreg_cbd *cbd = g_new0(struct ril_netreg_cbd, 1);
|
||||
|
||||
cbd->nd = nd;
|
||||
cbd->cb.ptr = cb;
|
||||
cbd->data = data;
|
||||
return cbd;
|
||||
}
|
||||
|
||||
int ril_netreg_check_if_really_roaming(struct ofono_netreg *netreg,
|
||||
gint status)
|
||||
{
|
||||
if (status == NETWORK_REGISTRATION_STATUS_ROAMING) {
|
||||
/* These functions tolerate NULL argument */
|
||||
const char *net_mcc = ofono_netreg_get_mcc(netreg);
|
||||
const char *net_mnc = ofono_netreg_get_mnc(netreg);
|
||||
struct sim_spdi *spdi = ofono_netreg_get_spdi(netreg);
|
||||
|
||||
if (spdi && net_mcc && net_mnc) {
|
||||
if (sim_spdi_lookup(spdi, net_mcc, net_mnc)) {
|
||||
ofono_info("not roaming based on spdi");
|
||||
return NETWORK_REGISTRATION_STATUS_REGISTERED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static int ril_netreg_check_status(struct ril_netreg *nd, int status)
|
||||
{
|
||||
return (nd && nd->netreg) ?
|
||||
ril_netreg_check_if_really_roaming(nd->netreg, status) :
|
||||
status;
|
||||
}
|
||||
|
||||
static gboolean ril_netreg_status_notify_cb(gpointer user_data)
|
||||
{
|
||||
struct ril_netreg *nd = user_data;
|
||||
const struct ril_registration_state *reg = &nd->network->voice;
|
||||
|
||||
DBG_(nd, "");
|
||||
GASSERT(nd->notify_id);
|
||||
nd->notify_id = 0;
|
||||
ofono_netreg_status_notify(nd->netreg,
|
||||
ril_netreg_check_status(nd, reg->status),
|
||||
reg->lac, reg->ci, reg->access_tech);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void ril_netreg_status_notify(struct ril_network *net, void *user_data)
|
||||
{
|
||||
struct ril_netreg *nd = user_data;
|
||||
|
||||
/* Coalesce multiple notifications into one */
|
||||
if (nd->notify_id) {
|
||||
DBG_(nd, "notification aready queued");
|
||||
} else {
|
||||
DBG_(nd, "queuing notification");
|
||||
nd->notify_id = g_idle_add(ril_netreg_status_notify_cb, nd);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_netreg_registration_status(struct ofono_netreg *netreg,
|
||||
ofono_netreg_status_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_netreg *nd = ril_netreg_get_data(netreg);
|
||||
const struct ril_registration_state *reg = &nd->network->voice;
|
||||
struct ofono_error error;
|
||||
|
||||
DBG_(nd, "");
|
||||
cb(ril_error_ok(&error),
|
||||
ril_netreg_check_status(nd, reg->status),
|
||||
reg->lac, reg->ci, reg->access_tech, data);
|
||||
}
|
||||
|
||||
static gboolean ril_netreg_current_operator_cb(void *user_data)
|
||||
{
|
||||
struct ril_netreg_cbd *cbd = user_data;
|
||||
struct ril_netreg *nd = cbd->nd;
|
||||
ofono_netreg_operator_cb_t cb = cbd->cb.operator;
|
||||
struct ofono_error error;
|
||||
|
||||
DBG_(nd, "");
|
||||
GASSERT(nd->current_operator_id);
|
||||
nd->current_operator_id = 0;
|
||||
|
||||
cb(ril_error_ok(&error), nd->network->operator, cbd->data);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void ril_netreg_current_operator(struct ofono_netreg *netreg,
|
||||
ofono_netreg_operator_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_netreg *nd = ril_netreg_get_data(netreg);
|
||||
|
||||
/*
|
||||
* Calling ofono_netreg_status_notify() may result in
|
||||
* ril_netreg_current_operator() being invoked even if one
|
||||
* is already pending. Since ofono core doesn't associate
|
||||
* any context with individual calls, we can safely assume
|
||||
* that such a call essentially cancels the previous one.
|
||||
*/
|
||||
if (nd->current_operator_id) {
|
||||
g_source_remove(nd->current_operator_id);
|
||||
}
|
||||
|
||||
nd->current_operator_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
|
||||
ril_netreg_current_operator_cb,
|
||||
ril_netreg_cbd_new(nd, cb, data),
|
||||
ril_netreg_cbd_free);
|
||||
}
|
||||
|
||||
static void ril_netreg_list_operators_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_netreg_cbd *cbd = user_data;
|
||||
ofono_netreg_operator_list_cb_t cb = cbd->cb.operator_list;
|
||||
struct ofono_network_operator *list;
|
||||
struct ofono_error error;
|
||||
int noperators = 0, i;
|
||||
GRilIoParser rilp;
|
||||
gboolean ok = TRUE;
|
||||
|
||||
if (status != RIL_E_SUCCESS) {
|
||||
ofono_error("Failed to retrive the list of operators: %s",
|
||||
ril_error_to_string(status));
|
||||
cb(ril_error_failure(&error), 0, NULL, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
|
||||
/* Number of operators at the list (4 strings for every operator) */
|
||||
grilio_parser_get_int32(&rilp, &noperators);
|
||||
GASSERT(!(noperators % 4));
|
||||
noperators /= 4;
|
||||
ofono_info("noperators = %d", noperators);
|
||||
|
||||
list = g_new0(struct ofono_network_operator, noperators);
|
||||
for (i = 0; i < noperators && ok; i++) {
|
||||
struct ofono_network_operator *op = list + i;
|
||||
char *lalpha = grilio_parser_get_utf8(&rilp);
|
||||
char *salpha = grilio_parser_get_utf8(&rilp);
|
||||
char *numeric = grilio_parser_get_utf8(&rilp);
|
||||
char *status = grilio_parser_get_utf8(&rilp);
|
||||
|
||||
/* Try to use long by default */
|
||||
if (lalpha) {
|
||||
strncpy(op->name, lalpha,
|
||||
OFONO_MAX_OPERATOR_NAME_LENGTH);
|
||||
} else if (salpha) {
|
||||
strncpy(op->name, salpha,
|
||||
OFONO_MAX_OPERATOR_NAME_LENGTH);
|
||||
} else {
|
||||
op->name[0] = 0;
|
||||
}
|
||||
|
||||
/* Set the proper status */
|
||||
if (!strcmp(status, "available")) {
|
||||
list[i].status = OPERATOR_STATUS_AVAILABLE;
|
||||
} else if (!strcmp(status, "current")) {
|
||||
list[i].status = OPERATOR_STATUS_CURRENT;
|
||||
} else if (!strcmp(status, "forbidden")) {
|
||||
list[i].status = OPERATOR_STATUS_FORBIDDEN;
|
||||
} else {
|
||||
list[i].status = OPERATOR_STATUS_UNKNOWN;
|
||||
}
|
||||
|
||||
op->tech = -1;
|
||||
ok = ril_parse_mcc_mnc(numeric, op);
|
||||
if (ok) {
|
||||
if (op->tech < 0) {
|
||||
op->tech = cbd->nd->network->voice.access_tech;
|
||||
}
|
||||
DBG("[operator=%s, %s, %s, status: %s]", op->name,
|
||||
op->mcc, op->mnc, status);
|
||||
} else {
|
||||
DBG("failed to parse operator list");
|
||||
}
|
||||
|
||||
g_free(lalpha);
|
||||
g_free(salpha);
|
||||
g_free(numeric);
|
||||
g_free(status);
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
cb(ril_error_ok(&error), noperators, list, cbd->data);
|
||||
} else {
|
||||
cb(ril_error_failure(&error), 0, NULL, cbd->data);
|
||||
}
|
||||
|
||||
g_free(list);
|
||||
}
|
||||
|
||||
static void ril_netreg_list_operators(struct ofono_netreg *netreg,
|
||||
ofono_netreg_operator_list_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_netreg *nd = ril_netreg_get_data(netreg);
|
||||
|
||||
grilio_queue_send_request_full(nd->q, NULL,
|
||||
RIL_REQUEST_QUERY_AVAILABLE_NETWORKS,
|
||||
ril_netreg_list_operators_cb, ril_netreg_cbd_free,
|
||||
ril_netreg_cbd_new(nd, cb, data));
|
||||
}
|
||||
|
||||
static void ril_netreg_register_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_netreg_cbd *cbd = user_data;
|
||||
ofono_netreg_register_cb_t cb = cbd->cb.reg;
|
||||
struct ofono_error error;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
cb(ril_error_ok(&error), cbd->data);
|
||||
} else {
|
||||
ofono_error("registration failed, ril result %d", status);
|
||||
cb(ril_error_failure(&error), cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_netreg_register_auto(struct ofono_netreg *netreg,
|
||||
ofono_netreg_register_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_netreg *nd = ril_netreg_get_data(netreg);
|
||||
|
||||
ofono_info("nw select automatic");
|
||||
grilio_queue_send_request_full(nd->q, NULL,
|
||||
RIL_REQUEST_SET_NETWORK_SELECTION_AUTOMATIC,
|
||||
ril_netreg_register_cb, ril_netreg_cbd_free,
|
||||
ril_netreg_cbd_new(nd, cb, data));
|
||||
}
|
||||
|
||||
static void ril_netreg_register_manual(struct ofono_netreg *netreg,
|
||||
const char *mcc, const char *mnc,
|
||||
ofono_netreg_register_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_netreg *nd = ril_netreg_get_data(netreg);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
ofono_info("nw select manual: %s%s", mcc, mnc);
|
||||
grilio_request_append_format(req, "%s%s+0", mcc, mnc);
|
||||
grilio_queue_send_request_full(nd->q, req,
|
||||
RIL_REQUEST_SET_NETWORK_SELECTION_MANUAL,
|
||||
ril_netreg_register_cb, ril_netreg_cbd_free,
|
||||
ril_netreg_cbd_new(nd, cb, data));
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static int ril_netreg_get_signal_strength(const void *data, guint len)
|
||||
{
|
||||
GRilIoParser rilp;
|
||||
int gw_signal = 0, cdma_dbm = 0, evdo_dbm = 0, lte_signal = 0;
|
||||
int rsrp = 0;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
|
||||
/* RIL_SignalStrength_v6 */
|
||||
/* GW_SignalStrength */
|
||||
grilio_parser_get_int32(&rilp, &gw_signal);
|
||||
grilio_parser_get_int32(&rilp, NULL); /* bitErrorRate */
|
||||
|
||||
/* CDMA_SignalStrength */
|
||||
grilio_parser_get_int32(&rilp, &cdma_dbm);
|
||||
grilio_parser_get_int32(&rilp, NULL); /* ecio */
|
||||
|
||||
/* EVDO_SignalStrength */
|
||||
grilio_parser_get_int32(&rilp, &evdo_dbm);
|
||||
grilio_parser_get_int32(&rilp, NULL); /* ecio */
|
||||
grilio_parser_get_int32(&rilp, NULL); /* signalNoiseRatio */
|
||||
|
||||
/* LTE_SignalStrength */
|
||||
grilio_parser_get_int32(&rilp, <e_signal);
|
||||
grilio_parser_get_int32(&rilp, &rsrp);
|
||||
/* The rest is ignored */
|
||||
|
||||
if (rsrp == INT_MAX) {
|
||||
DBG("gw: %d, cdma: %d, evdo: %d, lte: %d", gw_signal,
|
||||
cdma_dbm, evdo_dbm, lte_signal);
|
||||
} else {
|
||||
DBG("gw: %d, cdma: %d, evdo: %d, lte: %d rsrp: %d", gw_signal,
|
||||
cdma_dbm, evdo_dbm, lte_signal, rsrp);
|
||||
}
|
||||
|
||||
/* Return the first valid one */
|
||||
|
||||
/* Some RILs (namely, from MediaTek) report 0 here AND a valid LTE
|
||||
* RSRP value. If we've got zero, don't report it just yet. */
|
||||
if (gw_signal >= 1 && gw_signal <= 31) {
|
||||
/* Valid values are (0-31, 99) as defined in TS 27.007 */
|
||||
return (gw_signal * 100) / 31;
|
||||
}
|
||||
|
||||
/* Valid values are (0-31, 99) as defined in TS 27.007 */
|
||||
if (lte_signal >= 0 && lte_signal <= 31) {
|
||||
return (lte_signal * 100) / 31;
|
||||
}
|
||||
|
||||
/* RSRP range: 44 to 140 dBm as defined in 3GPP TS 36.133 */
|
||||
if (lte_signal == 99 && rsrp >= 44 && rsrp <= 140) {
|
||||
return 140 - rsrp;
|
||||
}
|
||||
|
||||
/* If we've got zero strength and no valid RSRP, then so be it */
|
||||
if (gw_signal == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* In case of dbm, return the value directly */
|
||||
if (cdma_dbm != -1) {
|
||||
return MIN(cdma_dbm, 100);
|
||||
}
|
||||
|
||||
if (evdo_dbm != -1) {
|
||||
return MIN(evdo_dbm, 100);
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void ril_netreg_strength_notify(GRilIoChannel *io, guint ril_event,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_netreg *nd = user_data;
|
||||
int strength;
|
||||
|
||||
GASSERT(ril_event == RIL_UNSOL_SIGNAL_STRENGTH);
|
||||
strength = ril_netreg_get_signal_strength(data, len);
|
||||
DBG_(nd, "%d", strength);
|
||||
ofono_netreg_strength_notify(nd->netreg, strength);
|
||||
}
|
||||
|
||||
static void ril_netreg_strength_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_netreg_cbd *cbd = user_data;
|
||||
ofono_netreg_strength_cb_t cb = cbd->cb.strength;
|
||||
struct ofono_error error;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
int strength = ril_netreg_get_signal_strength(data, len);
|
||||
cb(ril_error_ok(&error), strength, cbd->data);
|
||||
} else {
|
||||
ofono_error("Failed to retrive the signal strength: %s",
|
||||
ril_error_to_string(status));
|
||||
cb(ril_error_failure(&error), -1, cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_netreg_strength(struct ofono_netreg *netreg,
|
||||
ofono_netreg_strength_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_netreg *nd = ril_netreg_get_data(netreg);
|
||||
GRilIoRequest* req = grilio_request_new();
|
||||
|
||||
grilio_request_set_retry(req, RIL_RETRY_MS, -1);
|
||||
grilio_queue_send_request_full(nd->q, req,
|
||||
RIL_REQUEST_SIGNAL_STRENGTH, ril_netreg_strength_cb,
|
||||
ril_netreg_cbd_free, ril_netreg_cbd_new(nd, cb, data));
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_netreg_nitz_notify(GRilIoChannel *io, guint ril_event,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_netreg *nd = user_data;
|
||||
GRilIoParser rilp;
|
||||
int year, mon, mday, hour, min, sec, tzi, dst = 0;
|
||||
char tzs;
|
||||
gchar *nitz;
|
||||
|
||||
GASSERT(ril_event == RIL_UNSOL_NITZ_TIME_RECEIVED);
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
nitz = grilio_parser_get_utf8(&rilp);
|
||||
|
||||
DBG_(nd, "%s", nitz);
|
||||
|
||||
/*
|
||||
* Format: yy/mm/dd,hh:mm:ss(+/-)tz[,ds]
|
||||
* The ds part is considered optional, initialized to zero.
|
||||
*/
|
||||
if (nitz && sscanf(nitz, "%u/%u/%u,%u:%u:%u%c%u,%u",
|
||||
&year, &mon, &mday, &hour, &min, &sec, &tzs, &tzi,
|
||||
&dst) >= 8 && (tzs == '+' || tzs == '-')) {
|
||||
struct ofono_network_time time;
|
||||
char tz[4];
|
||||
|
||||
snprintf(tz, sizeof(tz), "%c%d", tzs, tzi);
|
||||
time.utcoff = atoi(tz) * 15 * 60;
|
||||
time.dst = dst;
|
||||
time.sec = sec;
|
||||
time.min = min;
|
||||
time.hour = hour;
|
||||
time.mday = mday;
|
||||
time.mon = mon;
|
||||
time.year = 2000 + year;
|
||||
|
||||
ofono_netreg_time_notify(nd->netreg, &time);
|
||||
} else {
|
||||
ofono_warn("Failed to parse NITZ string \"%s\"", nitz);
|
||||
}
|
||||
|
||||
g_free(nitz);
|
||||
}
|
||||
|
||||
static gboolean ril_netreg_register(gpointer user_data)
|
||||
{
|
||||
struct ril_netreg *nd = user_data;
|
||||
|
||||
GASSERT(nd->timer_id);
|
||||
nd->timer_id = 0;
|
||||
ofono_netreg_register(nd->netreg);
|
||||
|
||||
/* Register for network state changes */
|
||||
nd->network_event_id[NETREG_NETWORK_EVENT_OPERATOR_CHANGED] =
|
||||
ril_network_add_operator_changed_handler(nd->network,
|
||||
ril_netreg_status_notify, nd);
|
||||
nd->network_event_id[NETREG_NETWORK_EVENT_VOICE_STATE_CHANGED] =
|
||||
ril_network_add_voice_state_changed_handler(nd->network,
|
||||
ril_netreg_status_notify, nd);
|
||||
|
||||
/* Register for network time updates */
|
||||
nd->ril_event_id[NETREG_RIL_EVENT_NITZ_TIME_RECEIVED] =
|
||||
grilio_channel_add_unsol_event_handler(nd->io,
|
||||
ril_netreg_nitz_notify,
|
||||
RIL_UNSOL_NITZ_TIME_RECEIVED, nd);
|
||||
|
||||
/* Register for signal strength changes */
|
||||
nd->ril_event_id[NETREG_RIL_EVENT_SIGNAL_STRENGTH] =
|
||||
grilio_channel_add_unsol_event_handler(nd->io,
|
||||
ril_netreg_strength_notify,
|
||||
RIL_UNSOL_SIGNAL_STRENGTH, nd);
|
||||
|
||||
/* This makes the timeout a single-shot */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int ril_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_netreg *nd = g_new0(struct ril_netreg, 1);
|
||||
|
||||
nd->log_prefix = (modem->log_prefix && modem->log_prefix[0]) ?
|
||||
g_strconcat(modem->log_prefix, " ", NULL) : g_strdup("");
|
||||
|
||||
DBG_(nd, "%p", netreg);
|
||||
nd->io = grilio_channel_ref(ril_modem_io(modem));
|
||||
nd->q = grilio_queue_new(nd->io);
|
||||
nd->network = ril_network_ref(modem->network);
|
||||
nd->netreg = netreg;
|
||||
|
||||
ofono_netreg_set_data(netreg, nd);
|
||||
nd->timer_id = g_idle_add(ril_netreg_register, nd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_netreg_remove(struct ofono_netreg *netreg)
|
||||
{
|
||||
struct ril_netreg *nd = ril_netreg_get_data(netreg);
|
||||
|
||||
DBG_(nd, "%p", netreg);
|
||||
grilio_queue_cancel_all(nd->q, FALSE);
|
||||
ofono_netreg_set_data(netreg, NULL);
|
||||
|
||||
if (nd->timer_id > 0) {
|
||||
g_source_remove(nd->timer_id);
|
||||
}
|
||||
|
||||
if (nd->notify_id) {
|
||||
g_source_remove(nd->notify_id);
|
||||
}
|
||||
|
||||
if (nd->current_operator_id) {
|
||||
g_source_remove(nd->current_operator_id);
|
||||
}
|
||||
|
||||
ril_network_remove_all_handlers(nd->network, nd->network_event_id);
|
||||
ril_network_unref(nd->network);
|
||||
|
||||
grilio_channel_remove_all_handlers(nd->io, nd->ril_event_id);
|
||||
grilio_channel_unref(nd->io);
|
||||
grilio_queue_unref(nd->q);
|
||||
g_free(nd->log_prefix);
|
||||
g_free(nd);
|
||||
}
|
||||
|
||||
const struct ofono_netreg_driver ril_netreg_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_netreg_probe,
|
||||
.remove = ril_netreg_remove,
|
||||
.registration_status = ril_netreg_registration_status,
|
||||
.current_operator = ril_netreg_current_operator,
|
||||
.list_operators = ril_netreg_list_operators,
|
||||
.register_auto = ril_netreg_register_auto,
|
||||
.register_manual = ril_netreg_register_manual,
|
||||
.strength = ril_netreg_strength
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,984 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_network.h"
|
||||
#include "ril_radio.h"
|
||||
#include "ril_sim_card.h"
|
||||
#include "ril_sim_settings.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <grilio_queue.h>
|
||||
#include <grilio_request.h>
|
||||
#include <grilio_parser.h>
|
||||
|
||||
#include <gutil_misc.h>
|
||||
|
||||
#include <ofono/netreg.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define SET_PREF_MODE_HOLDOFF_SEC RIL_RETRY_SECS
|
||||
|
||||
typedef GObjectClass RilNetworkClass;
|
||||
typedef struct ril_network RilNetwork;
|
||||
|
||||
enum ril_network_timer {
|
||||
TIMER_SET_RAT_HOLDOFF,
|
||||
TIMER_FORCE_CHECK_PREF_MODE,
|
||||
TIMER_COUNT
|
||||
};
|
||||
|
||||
enum ril_network_radio_event {
|
||||
RADIO_EVENT_STATE_CHANGED,
|
||||
RADIO_EVENT_ONLINE_CHANGED,
|
||||
RADIO_EVENT_COUNT
|
||||
};
|
||||
|
||||
enum ril_network_sim_events {
|
||||
SIM_EVENT_STATUS_CHANGED,
|
||||
SIM_EVENT_IO_ACTIVE_CHANGED,
|
||||
SIM_EVENT_COUNT
|
||||
};
|
||||
|
||||
enum ril_network_unsol_event {
|
||||
UNSOL_EVENT_NETWORK_STATE,
|
||||
UNSOL_EVENT_RADIO_CAPABILITY,
|
||||
UNSOL_EVENT_COUNT
|
||||
};
|
||||
|
||||
struct ril_network_priv {
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
struct ril_radio *radio;
|
||||
struct ril_sim_card *simcard;
|
||||
int rat;
|
||||
int lte_network_mode;
|
||||
int network_mode_timeout;
|
||||
char *log_prefix;
|
||||
guint operator_poll_id;
|
||||
guint voice_poll_id;
|
||||
guint data_poll_id;
|
||||
guint timer[TIMER_COUNT];
|
||||
gulong query_rat_id;
|
||||
gulong set_rat_id;
|
||||
gulong unsol_event_id[UNSOL_EVENT_COUNT];
|
||||
gulong settings_event_id;
|
||||
gulong radio_event_id[RADIO_EVENT_COUNT];
|
||||
gulong simcard_event_id[SIM_EVENT_COUNT];
|
||||
struct ofono_network_operator operator;
|
||||
gboolean assert_rat;
|
||||
};
|
||||
|
||||
enum ril_network_signal {
|
||||
SIGNAL_OPERATOR_CHANGED,
|
||||
SIGNAL_VOICE_STATE_CHANGED,
|
||||
SIGNAL_DATA_STATE_CHANGED,
|
||||
SIGNAL_PREF_MODE_CHANGED,
|
||||
SIGNAL_MAX_PREF_MODE_CHANGED,
|
||||
SIGNAL_COUNT
|
||||
};
|
||||
|
||||
#define SIGNAL_OPERATOR_CHANGED_NAME "ril-network-operator-changed"
|
||||
#define SIGNAL_VOICE_STATE_CHANGED_NAME "ril-network-voice-state-changed"
|
||||
#define SIGNAL_DATA_STATE_CHANGED_NAME "ril-network-data-state-changed"
|
||||
#define SIGNAL_PREF_MODE_CHANGED_NAME "ril-network-pref-mode-changed"
|
||||
#define SIGNAL_MAX_PREF_MODE_CHANGED_NAME "ril-network-max-pref-mode-changed"
|
||||
|
||||
static guint ril_network_signals[SIGNAL_COUNT] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE(RilNetwork, ril_network, G_TYPE_OBJECT)
|
||||
#define RIL_NETWORK_TYPE (ril_network_get_type())
|
||||
#define RIL_NETWORK(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj,\
|
||||
RIL_NETWORK_TYPE,RilNetwork))
|
||||
|
||||
#define RIL_NETWORK_SIGNAL(klass,name) \
|
||||
ril_network_signals[SIGNAL_##name##_CHANGED] = \
|
||||
g_signal_new(SIGNAL_##name##_CHANGED_NAME, \
|
||||
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
|
||||
0, NULL, NULL, NULL, G_TYPE_NONE, 0)
|
||||
|
||||
#define DBG_(self,fmt,args...) DBG("%s" fmt, (self)->priv->log_prefix, ##args)
|
||||
|
||||
/* Some assumptions: */
|
||||
G_STATIC_ASSERT(OFONO_RADIO_ACCESS_MODE_ANY == 0);
|
||||
G_STATIC_ASSERT(OFONO_RADIO_ACCESS_MODE_GSM > OFONO_RADIO_ACCESS_MODE_ANY);
|
||||
G_STATIC_ASSERT(OFONO_RADIO_ACCESS_MODE_UMTS > OFONO_RADIO_ACCESS_MODE_GSM);
|
||||
G_STATIC_ASSERT(OFONO_RADIO_ACCESS_MODE_LTE > OFONO_RADIO_ACCESS_MODE_UMTS);
|
||||
|
||||
static void ril_network_query_pref_mode(struct ril_network *self);
|
||||
static void ril_network_check_pref_mode(struct ril_network *self,
|
||||
gboolean immediate);
|
||||
|
||||
static void ril_network_emit(struct ril_network *self,
|
||||
enum ril_network_signal sig)
|
||||
{
|
||||
g_signal_emit(self, ril_network_signals[sig], 0);
|
||||
}
|
||||
|
||||
static void ril_network_stop_timer(struct ril_network *self,
|
||||
enum ril_network_timer tid)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
if (priv->timer[tid]) {
|
||||
g_source_remove(priv->timer[tid]);
|
||||
priv->timer[tid] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_reset_state(struct ril_registration_state *reg)
|
||||
{
|
||||
memset(reg, 0, sizeof(*reg));
|
||||
reg->status = NETWORK_REGISTRATION_STATUS_UNKNOWN;
|
||||
reg->access_tech = -1;
|
||||
reg->ril_tech = -1;
|
||||
reg->lac = -1;
|
||||
reg->ci = -1;
|
||||
}
|
||||
|
||||
static gboolean ril_network_parse_response(struct ril_network *self,
|
||||
const void *data, guint len, struct ril_registration_state *reg)
|
||||
{
|
||||
int nparams, ril_status;
|
||||
gchar *sstatus = NULL, *slac = NULL, *sci = NULL;
|
||||
gchar *stech = NULL, *sreason = NULL, *smax = NULL;
|
||||
GRilIoParser rilp;
|
||||
|
||||
ril_network_reset_state(reg);
|
||||
|
||||
/* Size of response string array. The minimum seen in the wild is 3 */
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
if (!grilio_parser_get_int32(&rilp, &nparams) || nparams < 3) {
|
||||
DBG_(self, "broken response");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
sstatus = grilio_parser_get_utf8(&rilp); /* response[0] */
|
||||
if (!sstatus) {
|
||||
DBG_(self, "No sstatus value returned!");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
slac = grilio_parser_get_utf8(&rilp); /* response[1] */
|
||||
sci = grilio_parser_get_utf8(&rilp); /* response[2] */
|
||||
|
||||
if (nparams > 3) {
|
||||
stech = grilio_parser_get_utf8(&rilp); /* response[3] */
|
||||
}
|
||||
|
||||
ril_status = atoi(sstatus);
|
||||
if (ril_status > 10) {
|
||||
reg->status = ril_status - 10;
|
||||
} else {
|
||||
reg->status = ril_status;
|
||||
}
|
||||
|
||||
/* FIXME: need to review VOICE_REGISTRATION response
|
||||
* as it returns up to 15 parameters ( vs. 6 for DATA ).
|
||||
*
|
||||
* The first four parameters are the same for both
|
||||
* responses ( although status includes values for
|
||||
* emergency calls for VOICE response ).
|
||||
*
|
||||
* Parameters 5 & 6 have different meanings for
|
||||
* voice & data response.
|
||||
*/
|
||||
if (nparams > 4) {
|
||||
/* TODO: different use for CDMA */
|
||||
sreason = grilio_parser_get_utf8(&rilp); /* response[4] */
|
||||
if (nparams > 5) {
|
||||
/* TODO: different use for CDMA */
|
||||
smax = grilio_parser_get_utf8(&rilp); /* response[5] */
|
||||
if (smax) {
|
||||
reg->max_calls = atoi(smax);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Some older RILs don't provide max calls, in that case let's
|
||||
* supply some reasonable default. We don't need more than 2
|
||||
* simultaneous data calls anyway.
|
||||
*/
|
||||
if (reg->max_calls < 1) {
|
||||
reg->max_calls = 2;
|
||||
}
|
||||
|
||||
if (!gutil_parse_int(slac, 16, ®->lac)) {
|
||||
reg->lac = -1;
|
||||
}
|
||||
|
||||
if (!gutil_parse_int(sci, 16, ®->ci)) {
|
||||
reg->ci = -1;
|
||||
}
|
||||
|
||||
reg->access_tech = ril_parse_tech(stech, ®->ril_tech);
|
||||
|
||||
DBG_(self, "%s,%s,%s,%d,%s,%s,%s",
|
||||
registration_status_to_string(reg->status),
|
||||
slac, sci, reg->ril_tech,
|
||||
registration_tech_to_string(reg->access_tech),
|
||||
sreason, smax);
|
||||
|
||||
g_free(sstatus);
|
||||
g_free(slac);
|
||||
g_free(sci);
|
||||
g_free(stech);
|
||||
g_free(sreason);
|
||||
g_free(smax);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void ril_network_op_copy(struct ofono_network_operator *dest,
|
||||
const struct ofono_network_operator *src)
|
||||
{
|
||||
strncpy(dest->mcc, src->mcc, sizeof(dest->mcc));
|
||||
strncpy(dest->mnc, src->mnc, sizeof(dest->mnc));
|
||||
strncpy(dest->name, src->name, sizeof(dest->name));
|
||||
dest->mcc[sizeof(dest->mcc)-1] = 0;
|
||||
dest->mnc[sizeof(dest->mnc)-1] = 0;
|
||||
dest->name[sizeof(dest->name)-1] = 0;
|
||||
dest->status = src->status;
|
||||
dest->tech = src->tech;
|
||||
}
|
||||
|
||||
static gboolean ril_network_op_equal(const struct ofono_network_operator *op1,
|
||||
const struct ofono_network_operator *op2)
|
||||
{
|
||||
if (op1 == op2) {
|
||||
return TRUE;
|
||||
} else if (!op1 || !op2) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return op1->status == op2->status &&
|
||||
op1->tech == op2->tech &&
|
||||
!strncmp(op1->mcc, op2->mcc, sizeof(op2->mcc)) &&
|
||||
!strncmp(op1->mnc, op2->mnc, sizeof(op2->mnc)) &&
|
||||
!strncmp(op1->name, op2->name, sizeof(op2->name));
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_poll_operator_cb(GRilIoChannel *io, int req_status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
GASSERT(priv->operator_poll_id);
|
||||
priv->operator_poll_id = 0;
|
||||
|
||||
if (req_status == RIL_E_SUCCESS) {
|
||||
struct ofono_network_operator op;
|
||||
gboolean changed = FALSE;
|
||||
gchar *lalpha;
|
||||
char *salpha;
|
||||
char *numeric;
|
||||
GRilIoParser rilp;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
grilio_parser_get_int32(&rilp, NULL);
|
||||
lalpha = grilio_parser_get_utf8(&rilp);
|
||||
salpha = grilio_parser_get_utf8(&rilp);
|
||||
numeric = grilio_parser_get_utf8(&rilp);
|
||||
|
||||
op.tech = -1;
|
||||
if (ril_parse_mcc_mnc(numeric, &op)) {
|
||||
if (op.tech < 0) op.tech = self->voice.access_tech;
|
||||
op.status = OPERATOR_STATUS_CURRENT;
|
||||
op.name[0] = 0;
|
||||
if (lalpha) {
|
||||
strncpy(op.name, lalpha, sizeof(op.name));
|
||||
} else if (salpha) {
|
||||
strncpy(op.name, salpha, sizeof(op.name));
|
||||
} else {
|
||||
strncpy(op.name, numeric, sizeof(op.name));
|
||||
}
|
||||
op.name[sizeof(op.name)-1] = 0;
|
||||
if (!self->operator) {
|
||||
self->operator = &priv->operator;
|
||||
ril_network_op_copy(&priv->operator, &op);
|
||||
changed = TRUE;
|
||||
} else if (!ril_network_op_equal(&op, &priv->operator)) {
|
||||
ril_network_op_copy(&priv->operator, &op);
|
||||
changed = TRUE;
|
||||
}
|
||||
} else if (self->operator) {
|
||||
self->operator = NULL;
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
if (self->operator) {
|
||||
DBG_(self, "lalpha=%s, salpha=%s, numeric=%s, "
|
||||
"%s, mcc=%s, mnc=%s, %s",
|
||||
lalpha, salpha, numeric,
|
||||
op.name, op.mcc, op.mnc,
|
||||
registration_tech_to_string(op.tech));
|
||||
} else {
|
||||
DBG_(self, "no operator");
|
||||
}
|
||||
ril_network_emit(self, SIGNAL_OPERATOR_CHANGED);
|
||||
}
|
||||
|
||||
g_free(lalpha);
|
||||
g_free(salpha);
|
||||
g_free(numeric);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_poll_voice_state_cb(GRilIoChannel *io, int req_status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
GASSERT(priv->voice_poll_id);
|
||||
priv->voice_poll_id = 0;
|
||||
|
||||
if (req_status == RIL_E_SUCCESS) {
|
||||
struct ril_registration_state state;
|
||||
|
||||
ril_network_parse_response(self, data, len, &state);
|
||||
if (memcmp(&state, &self->voice, sizeof(state))) {
|
||||
DBG_(self, "voice registration changed");
|
||||
self->voice = state;
|
||||
ril_network_emit(self, SIGNAL_VOICE_STATE_CHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_poll_data_state_cb(GRilIoChannel *io, int req_status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
GASSERT(priv->data_poll_id);
|
||||
priv->data_poll_id = 0;
|
||||
|
||||
if (req_status == RIL_E_SUCCESS) {
|
||||
struct ril_registration_state state;
|
||||
|
||||
ril_network_parse_response(self, data, len, &state);
|
||||
if (memcmp(&state, &self->data, sizeof(state))) {
|
||||
DBG_(self, "data registration changed");
|
||||
self->data = state;
|
||||
ril_network_emit(self, SIGNAL_DATA_STATE_CHANGED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static guint ril_network_poll_and_retry(struct ril_network *self, guint id,
|
||||
int code, GRilIoChannelResponseFunc fn)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
if (id) {
|
||||
/* Retry right away, don't wait for retry timeout to expire */
|
||||
grilio_channel_retry_request(priv->io, id);
|
||||
} else {
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
grilio_request_set_retry(req, RIL_RETRY_SECS*1000, -1);
|
||||
id = grilio_queue_send_request_full(priv->q, req, code, fn,
|
||||
NULL, self);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
static void ril_network_poll_state(struct ril_network *self)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
DBG_(self, "");
|
||||
priv->operator_poll_id = ril_network_poll_and_retry(self,
|
||||
priv->operator_poll_id, RIL_REQUEST_OPERATOR,
|
||||
ril_network_poll_operator_cb);
|
||||
|
||||
ril_network_query_registration_state(self);
|
||||
}
|
||||
|
||||
void ril_network_query_registration_state(struct ril_network *self)
|
||||
{
|
||||
if (self) {
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
DBG_(self, "");
|
||||
priv->voice_poll_id = ril_network_poll_and_retry(self,
|
||||
priv->voice_poll_id,
|
||||
RIL_REQUEST_VOICE_REGISTRATION_STATE,
|
||||
ril_network_poll_voice_state_cb);
|
||||
priv->data_poll_id = ril_network_poll_and_retry(self,
|
||||
priv->data_poll_id,
|
||||
RIL_REQUEST_DATA_REGISTRATION_STATE,
|
||||
ril_network_poll_data_state_cb);
|
||||
}
|
||||
}
|
||||
|
||||
static enum ofono_radio_access_mode ril_network_rat_to_mode(int rat)
|
||||
{
|
||||
switch (rat) {
|
||||
case PREF_NET_TYPE_LTE_CDMA_EVDO:
|
||||
case PREF_NET_TYPE_LTE_GSM_WCDMA:
|
||||
case PREF_NET_TYPE_LTE_CMDA_EVDO_GSM_WCDMA:
|
||||
case PREF_NET_TYPE_LTE_ONLY:
|
||||
case PREF_NET_TYPE_LTE_WCDMA:
|
||||
return OFONO_RADIO_ACCESS_MODE_LTE;
|
||||
case PREF_NET_TYPE_GSM_WCDMA_AUTO:
|
||||
case PREF_NET_TYPE_WCDMA:
|
||||
case PREF_NET_TYPE_GSM_WCDMA:
|
||||
return OFONO_RADIO_ACCESS_MODE_UMTS;
|
||||
default:
|
||||
DBG("unexpected rat mode %d", rat);
|
||||
case PREF_NET_TYPE_GSM_ONLY:
|
||||
return OFONO_RADIO_ACCESS_MODE_GSM;
|
||||
}
|
||||
}
|
||||
|
||||
static int ril_network_mode_to_rat(struct ril_network *self,
|
||||
enum ofono_radio_access_mode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case OFONO_RADIO_ACCESS_MODE_ANY:
|
||||
case OFONO_RADIO_ACCESS_MODE_LTE:
|
||||
if (self->settings->techs & OFONO_RADIO_ACCESS_MODE_LTE) {
|
||||
return self->priv->lte_network_mode;
|
||||
}
|
||||
/* no break */
|
||||
default:
|
||||
case OFONO_RADIO_ACCESS_MODE_UMTS:
|
||||
if (self->settings->techs & OFONO_RADIO_ACCESS_MODE_UMTS) {
|
||||
return PREF_NET_TYPE_GSM_WCDMA_AUTO;
|
||||
}
|
||||
/* no break */
|
||||
case OFONO_RADIO_ACCESS_MODE_GSM:
|
||||
return PREF_NET_TYPE_GSM_ONLY;
|
||||
}
|
||||
}
|
||||
|
||||
static int ril_network_pref_mode_expected(struct ril_network *self)
|
||||
{
|
||||
struct ril_sim_settings *settings = self->settings;
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
/*
|
||||
* On dual-SIM phones such as Jolla C only one slot at a time
|
||||
* is allowed to use LTE. Even if the slot which has been using
|
||||
* LTE gets powered off, we still need to explicitely set its
|
||||
* preferred mode to GSM, to make LTE machinery available to
|
||||
* the other slot. This sort of behaviour might not be necessary
|
||||
* on some hardware and can (should) be made configurable when
|
||||
* it becomes necessary.
|
||||
*/
|
||||
const enum ofono_radio_access_mode max_pref_mode =
|
||||
(priv->radio->state == RADIO_STATE_ON) ? self->max_pref_mode :
|
||||
OFONO_RADIO_ACCESS_MODE_GSM;
|
||||
|
||||
/*
|
||||
* OFONO_RADIO_ACCESS_MODE_ANY is zero. If both pref_mode
|
||||
* and max_pref_mode are not ANY, we pick the smallest value.
|
||||
* Otherwise we take any non-zero value if there is one.
|
||||
*/
|
||||
const enum ofono_radio_access_mode pref_mode =
|
||||
(settings->pref_mode && max_pref_mode) ?
|
||||
MIN(settings->pref_mode, max_pref_mode) :
|
||||
settings->pref_mode ? settings->pref_mode :
|
||||
max_pref_mode;
|
||||
return ril_network_mode_to_rat(self, pref_mode);
|
||||
}
|
||||
|
||||
static gboolean ril_network_can_set_pref_mode(struct ril_network *self)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
/*
|
||||
* With some modems an attempt to set rat significantly slows
|
||||
* down SIM I/O, let's avoid that.
|
||||
*/
|
||||
return priv->radio->online && ril_sim_card_ready(priv->simcard) &&
|
||||
!priv->simcard->sim_io_active &&
|
||||
!priv->timer[TIMER_SET_RAT_HOLDOFF] ;
|
||||
}
|
||||
|
||||
static gboolean ril_network_set_rat_holdoff_cb(gpointer user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
GASSERT(priv->timer[TIMER_SET_RAT_HOLDOFF]);
|
||||
priv->timer[TIMER_SET_RAT_HOLDOFF] = 0;
|
||||
|
||||
ril_network_check_pref_mode(self, FALSE);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void ril_network_set_rat_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
GASSERT(priv->set_rat_id);
|
||||
priv->set_rat_id = 0;
|
||||
if (status != RIL_E_SUCCESS) {
|
||||
ofono_error("failed to set rat mode");
|
||||
}
|
||||
|
||||
ril_network_query_pref_mode(self);
|
||||
}
|
||||
|
||||
static void ril_network_set_rat(struct ril_network *self, int rat)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
if (!priv->set_rat_id && priv->radio->online &&
|
||||
ril_sim_card_ready(priv->simcard) &&
|
||||
/*
|
||||
* With some modems an attempt to set rat significantly
|
||||
* slows down SIM I/O, let's avoid that.
|
||||
*/
|
||||
!priv->simcard->sim_io_active &&
|
||||
!priv->timer[TIMER_SET_RAT_HOLDOFF]) {
|
||||
GRilIoRequest *req = grilio_request_sized_new(8);
|
||||
|
||||
DBG_(self, "setting rat mode %d", rat);
|
||||
grilio_request_append_int32(req, 1); /* count */
|
||||
grilio_request_append_int32(req, rat);
|
||||
|
||||
grilio_request_set_timeout(req, priv->network_mode_timeout);
|
||||
priv->set_rat_id = grilio_queue_send_request_full(priv->q, req,
|
||||
RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE,
|
||||
ril_network_set_rat_cb, NULL, self);
|
||||
grilio_request_unref(req);
|
||||
|
||||
/* We have submitted the request, clear the assertion flag */
|
||||
priv->assert_rat = FALSE;
|
||||
|
||||
/* And don't do it too often */
|
||||
priv->timer[TIMER_SET_RAT_HOLDOFF] =
|
||||
g_timeout_add_seconds(SET_PREF_MODE_HOLDOFF_SEC,
|
||||
ril_network_set_rat_holdoff_cb, self);
|
||||
} else {
|
||||
DBG_(self, "need to set rat mode %d", rat);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_set_pref_mode(struct ril_network *self, int rat)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
if (priv->rat != rat || priv->assert_rat) {
|
||||
ril_network_set_rat(self, rat);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_check_pref_mode(struct ril_network *self,
|
||||
gboolean immediate)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
const int rat = ril_network_pref_mode_expected(self);
|
||||
|
||||
if (priv->timer[TIMER_FORCE_CHECK_PREF_MODE]) {
|
||||
ril_network_stop_timer(self, TIMER_FORCE_CHECK_PREF_MODE);
|
||||
/*
|
||||
* TIMER_FORCE_CHECK_PREF_MODE is scheduled by
|
||||
* ril_network_pref_mode_changed_cb and is meant
|
||||
* to force radio tech check right now.
|
||||
*/
|
||||
immediate = TRUE;
|
||||
}
|
||||
|
||||
if (priv->rat != rat) {
|
||||
DBG_(self, "rat mode %d, expected %d", priv->rat, rat);
|
||||
}
|
||||
|
||||
if (immediate) {
|
||||
ril_network_stop_timer(self, TIMER_SET_RAT_HOLDOFF);
|
||||
}
|
||||
|
||||
if (priv->rat != rat || priv->assert_rat) {
|
||||
if (!priv->timer[TIMER_SET_RAT_HOLDOFF]) {
|
||||
ril_network_set_pref_mode(self, rat);
|
||||
} else {
|
||||
/* OK, later */
|
||||
DBG_(self, "need to set rat mode %d", rat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int ril_network_parse_pref_resp(const void *data, guint len)
|
||||
{
|
||||
GRilIoParser rilp;
|
||||
int pref = -1;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
grilio_parser_get_int32(&rilp, NULL);
|
||||
grilio_parser_get_int32(&rilp, &pref);
|
||||
return pref;
|
||||
}
|
||||
|
||||
static void ril_network_startup_query_pref_mode_cb(GRilIoChannel *io,
|
||||
int status, const void *data, guint len, void *user_data)
|
||||
{
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
const enum ofono_radio_access_mode pref_mode = self->pref_mode;
|
||||
|
||||
priv->rat = ril_network_parse_pref_resp(data, len);
|
||||
self->pref_mode = ril_network_rat_to_mode(priv->rat);
|
||||
DBG_(self, "rat mode %d (%s)", priv->rat,
|
||||
ofono_radio_access_mode_to_string(self->pref_mode));
|
||||
|
||||
if (self->pref_mode != pref_mode) {
|
||||
ril_network_emit(self, SIGNAL_PREF_MODE_CHANGED);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unlike ril_network_query_pref_mode_cb, this one always
|
||||
* checks the preferred mode.
|
||||
*/
|
||||
ril_network_check_pref_mode(self, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_query_pref_mode_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
const enum ofono_radio_access_mode pref_mode = self->pref_mode;
|
||||
|
||||
/* This request never fails because in case of error it gets retried */
|
||||
GASSERT(status == RIL_E_SUCCESS);
|
||||
GASSERT(priv->query_rat_id);
|
||||
|
||||
priv->query_rat_id = 0;
|
||||
priv->rat = ril_network_parse_pref_resp(data, len);
|
||||
self->pref_mode = ril_network_rat_to_mode(priv->rat);
|
||||
DBG_(self, "rat mode %d (%s)", priv->rat,
|
||||
ofono_radio_access_mode_to_string(self->pref_mode));
|
||||
|
||||
if (self->pref_mode != pref_mode) {
|
||||
ril_network_emit(self, SIGNAL_PREF_MODE_CHANGED);
|
||||
}
|
||||
|
||||
if (ril_network_can_set_pref_mode(self)) {
|
||||
ril_network_check_pref_mode(self, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_query_pref_mode(struct ril_network *self)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
grilio_request_set_retry(req, RIL_RETRY_SECS*1000, -1);
|
||||
grilio_queue_cancel_request(priv->q, priv->query_rat_id, FALSE);
|
||||
priv->query_rat_id = grilio_queue_send_request_full(priv->q, req,
|
||||
RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE,
|
||||
ril_network_query_pref_mode_cb, NULL, self);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
void ril_network_set_max_pref_mode(struct ril_network *self,
|
||||
enum ofono_radio_access_mode max_mode,
|
||||
gboolean force_check)
|
||||
{
|
||||
if (self && (self->max_pref_mode != max_mode || force_check)) {
|
||||
if (self->max_pref_mode != max_mode) {
|
||||
DBG_(self, "rat mode %d (%s)", max_mode,
|
||||
ofono_radio_access_mode_to_string(max_mode));
|
||||
self->max_pref_mode = max_mode;
|
||||
ril_network_emit(self, SIGNAL_MAX_PREF_MODE_CHANGED);
|
||||
}
|
||||
ril_network_check_pref_mode(self, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void ril_network_assert_pref_mode(struct ril_network *self, gboolean immediate)
|
||||
{
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
priv->assert_rat = TRUE;
|
||||
ril_network_check_pref_mode(self, immediate);
|
||||
}
|
||||
|
||||
gulong ril_network_add_operator_changed_handler(struct ril_network *self,
|
||||
ril_network_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_OPERATOR_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong ril_network_add_voice_state_changed_handler(struct ril_network *self,
|
||||
ril_network_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_VOICE_STATE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong ril_network_add_data_state_changed_handler(struct ril_network *self,
|
||||
ril_network_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_DATA_STATE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong ril_network_add_pref_mode_changed_handler(struct ril_network *self,
|
||||
ril_network_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong ril_network_add_max_pref_mode_changed_handler(struct ril_network *self,
|
||||
ril_network_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_MAX_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
void ril_network_remove_handler(struct ril_network *self, gulong id)
|
||||
{
|
||||
if (G_LIKELY(self) && G_LIKELY(id)) {
|
||||
g_signal_handler_disconnect(self, id);
|
||||
}
|
||||
}
|
||||
|
||||
void ril_network_remove_handlers(struct ril_network *self, gulong *ids, int n)
|
||||
{
|
||||
gutil_disconnect_handlers(self, ids, n);
|
||||
}
|
||||
|
||||
static void ril_network_state_changed_cb(GRilIoChannel *io, guint code,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
|
||||
DBG_(self, "");
|
||||
GASSERT(code == RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED);
|
||||
ril_network_poll_state(self);
|
||||
}
|
||||
|
||||
static void ril_network_radio_capability_changed_cb(GRilIoChannel *io,
|
||||
guint code, const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
|
||||
DBG_(self, "");
|
||||
GASSERT(code == RIL_UNSOL_RADIO_CAPABILITY);
|
||||
ril_network_assert_pref_mode(self, FALSE);
|
||||
}
|
||||
|
||||
static void ril_network_radio_state_cb(struct ril_radio *radio, void *data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(data);
|
||||
|
||||
ril_network_check_pref_mode(self, FALSE);
|
||||
if (radio->state == RADIO_STATE_ON) {
|
||||
ril_network_poll_state(self);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_radio_online_cb(struct ril_radio *radio, void *data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(data);
|
||||
|
||||
if (ril_network_can_set_pref_mode(self)) {
|
||||
ril_network_check_pref_mode(self, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean ril_network_check_pref_mode_cb(gpointer user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
GASSERT(priv->timer[TIMER_FORCE_CHECK_PREF_MODE]);
|
||||
priv->timer[TIMER_FORCE_CHECK_PREF_MODE] = 0;
|
||||
|
||||
DBG_(self, "checking pref mode");
|
||||
ril_network_check_pref_mode(self, TRUE);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void ril_network_pref_mode_changed_cb(struct ril_sim_settings *settings,
|
||||
void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
/*
|
||||
* Postpone ril_network_check_pref_mode because other pref_mode
|
||||
* listeners (namely, ril_data) may want to tweak max_pref_mode
|
||||
*/
|
||||
if (!priv->timer[TIMER_FORCE_CHECK_PREF_MODE]) {
|
||||
DBG_(self, "scheduling pref mode check");
|
||||
priv->timer[TIMER_FORCE_CHECK_PREF_MODE] =
|
||||
g_idle_add(ril_network_check_pref_mode_cb, self);
|
||||
} else {
|
||||
DBG_(self, "pref mode check already scheduled");
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_sim_status_changed_cb(struct ril_sim_card *sc,
|
||||
void *user_data)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(user_data);
|
||||
|
||||
if (ril_network_can_set_pref_mode(self)) {
|
||||
ril_network_check_pref_mode(self, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
|
||||
const char *log_prefix, struct ril_radio *radio,
|
||||
struct ril_sim_card *simcard,
|
||||
struct ril_sim_settings *settings,
|
||||
const struct ril_slot_config *config)
|
||||
{
|
||||
struct ril_network *self = g_object_new(RIL_NETWORK_TYPE, NULL);
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
|
||||
self->settings = ril_sim_settings_ref(settings);
|
||||
priv->io = grilio_channel_ref(io);
|
||||
priv->q = grilio_queue_new(priv->io);
|
||||
priv->radio = ril_radio_ref(radio);
|
||||
priv->simcard = ril_sim_card_ref(simcard);
|
||||
priv->log_prefix = (log_prefix && log_prefix[0]) ?
|
||||
g_strconcat(log_prefix, " ", NULL) : g_strdup("");
|
||||
DBG_(self, "");
|
||||
|
||||
/* Copy relevant config values */
|
||||
priv->lte_network_mode = config->lte_network_mode;
|
||||
priv->network_mode_timeout = config->network_mode_timeout;
|
||||
|
||||
/* Register listeners */
|
||||
priv->unsol_event_id[UNSOL_EVENT_NETWORK_STATE] =
|
||||
grilio_channel_add_unsol_event_handler(priv->io,
|
||||
ril_network_state_changed_cb,
|
||||
RIL_UNSOL_RESPONSE_VOICE_NETWORK_STATE_CHANGED, self);
|
||||
priv->unsol_event_id[UNSOL_EVENT_RADIO_CAPABILITY] =
|
||||
grilio_channel_add_unsol_event_handler(priv->io,
|
||||
ril_network_radio_capability_changed_cb,
|
||||
RIL_UNSOL_RADIO_CAPABILITY, self);
|
||||
priv->radio_event_id[RADIO_EVENT_STATE_CHANGED] =
|
||||
ril_radio_add_state_changed_handler(priv->radio,
|
||||
ril_network_radio_state_cb, self);
|
||||
priv->radio_event_id[RADIO_EVENT_ONLINE_CHANGED] =
|
||||
ril_radio_add_online_changed_handler(priv->radio,
|
||||
ril_network_radio_online_cb, self);
|
||||
priv->simcard_event_id[SIM_EVENT_STATUS_CHANGED] =
|
||||
ril_sim_card_add_status_changed_handler(priv->simcard,
|
||||
ril_network_sim_status_changed_cb, self);
|
||||
priv->simcard_event_id[SIM_EVENT_IO_ACTIVE_CHANGED] =
|
||||
ril_sim_card_add_sim_io_active_changed_handler(priv->simcard,
|
||||
ril_network_sim_status_changed_cb, self);
|
||||
priv->settings_event_id =
|
||||
ril_sim_settings_add_pref_mode_changed_handler(settings,
|
||||
ril_network_pref_mode_changed_cb, self);
|
||||
|
||||
/*
|
||||
* Query the initial state. Querying network state before the radio
|
||||
* has been turned on makes RIL unhappy.
|
||||
*/
|
||||
grilio_queue_send_request_full(priv->q, NULL,
|
||||
RIL_REQUEST_GET_PREFERRED_NETWORK_TYPE,
|
||||
ril_network_startup_query_pref_mode_cb, NULL, self);
|
||||
if (radio->state == RADIO_STATE_ON) {
|
||||
ril_network_poll_state(self);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
struct ril_network *ril_network_ref(struct ril_network *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
g_object_ref(RIL_NETWORK(self));
|
||||
return self;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ril_network_unref(struct ril_network *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
g_object_unref(RIL_NETWORK(self));
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_network_init(struct ril_network *self)
|
||||
{
|
||||
struct ril_network_priv *priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
|
||||
RIL_NETWORK_TYPE, struct ril_network_priv);
|
||||
|
||||
self->priv = priv;
|
||||
ril_network_reset_state(&self->voice);
|
||||
ril_network_reset_state(&self->data);
|
||||
priv->rat = -1;
|
||||
}
|
||||
|
||||
static void ril_network_finalize(GObject *object)
|
||||
{
|
||||
struct ril_network *self = RIL_NETWORK(object);
|
||||
struct ril_network_priv *priv = self->priv;
|
||||
enum ril_network_timer tid;
|
||||
|
||||
DBG_(self, "");
|
||||
|
||||
for (tid=0; tid<TIMER_COUNT; tid++) {
|
||||
ril_network_stop_timer(self, tid);
|
||||
}
|
||||
|
||||
grilio_queue_cancel_all(priv->q, FALSE);
|
||||
grilio_channel_remove_all_handlers(priv->io, priv->unsol_event_id);
|
||||
grilio_channel_unref(priv->io);
|
||||
grilio_queue_unref(priv->q);
|
||||
ril_radio_remove_all_handlers(priv->radio, priv->radio_event_id);
|
||||
ril_radio_unref(priv->radio);
|
||||
ril_sim_card_remove_all_handlers(priv->simcard, priv->simcard_event_id);
|
||||
ril_sim_card_unref(priv->simcard);
|
||||
ril_sim_settings_remove_handler(self->settings,
|
||||
priv->settings_event_id);
|
||||
ril_sim_settings_unref(self->settings);
|
||||
g_free(priv->log_prefix);
|
||||
G_OBJECT_CLASS(ril_network_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void ril_network_class_init(RilNetworkClass *klass)
|
||||
{
|
||||
G_OBJECT_CLASS(klass)->finalize = ril_network_finalize;
|
||||
g_type_class_add_private(klass, sizeof(struct ril_network_priv));
|
||||
RIL_NETWORK_SIGNAL(klass, OPERATOR);
|
||||
RIL_NETWORK_SIGNAL(klass, VOICE_STATE);
|
||||
RIL_NETWORK_SIGNAL(klass, DATA_STATE);
|
||||
RIL_NETWORK_SIGNAL(klass, PREF_MODE);
|
||||
RIL_NETWORK_SIGNAL(klass, MAX_PREF_MODE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_NETWORK_H
|
||||
#define RIL_NETWORK_H
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
struct ofono_network_operator;
|
||||
|
||||
struct ril_registration_state {
|
||||
int status; /* enum network_registration_status */
|
||||
int access_tech; /* enum access_technology or -1 if none */
|
||||
int ril_tech;
|
||||
int max_calls;
|
||||
int lac;
|
||||
int ci;
|
||||
};
|
||||
|
||||
struct ril_network {
|
||||
GObject object;
|
||||
struct ril_network_priv *priv;
|
||||
struct ril_registration_state voice;
|
||||
struct ril_registration_state data;
|
||||
const struct ofono_network_operator *operator;
|
||||
enum ofono_radio_access_mode pref_mode;
|
||||
enum ofono_radio_access_mode max_pref_mode;
|
||||
struct ril_sim_settings *settings;
|
||||
};
|
||||
|
||||
struct ofono_sim;
|
||||
typedef void (*ril_network_cb_t)(struct ril_network *net, void *arg);
|
||||
|
||||
struct ril_network *ril_network_new(const char *path, GRilIoChannel *io,
|
||||
const char *log_prefix, struct ril_radio *radio,
|
||||
struct ril_sim_card *sim_card,
|
||||
struct ril_sim_settings *settings,
|
||||
const struct ril_slot_config *ril_slot_config);
|
||||
struct ril_network *ril_network_ref(struct ril_network *net);
|
||||
void ril_network_unref(struct ril_network *net);
|
||||
|
||||
void ril_network_set_max_pref_mode(struct ril_network *net,
|
||||
enum ofono_radio_access_mode max_pref_mode,
|
||||
gboolean force_check);
|
||||
void ril_network_assert_pref_mode(struct ril_network *net, gboolean immediate);
|
||||
void ril_network_query_registration_state(struct ril_network *net);
|
||||
gulong ril_network_add_operator_changed_handler(struct ril_network *net,
|
||||
ril_network_cb_t cb, void *arg);
|
||||
gulong ril_network_add_voice_state_changed_handler(struct ril_network *net,
|
||||
ril_network_cb_t cb, void *arg);
|
||||
gulong ril_network_add_data_state_changed_handler(struct ril_network *net,
|
||||
ril_network_cb_t cb, void *arg);
|
||||
gulong ril_network_add_pref_mode_changed_handler(struct ril_network *net,
|
||||
ril_network_cb_t cb, void *arg);
|
||||
gulong ril_network_add_max_pref_mode_changed_handler(struct ril_network *net,
|
||||
ril_network_cb_t cb, void *arg);
|
||||
void ril_network_remove_handler(struct ril_network *net, gulong id);
|
||||
void ril_network_remove_handlers(struct ril_network *net, gulong *ids, int n);
|
||||
|
||||
#define ril_network_remove_all_handlers(net, ids) \
|
||||
ril_network_remove_handlers(net, ids, G_N_ELEMENTS(ids))
|
||||
|
||||
#endif /* RIL_NETWORK_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,162 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "gdbus.h"
|
||||
#include "ofono.h"
|
||||
|
||||
#define RIL_OEM_RAW_INTERFACE "org.ofono.OemRaw"
|
||||
#define RIL_OEM_RAW_TIMEOUT (60*1000) /* 60 sec */
|
||||
|
||||
struct ril_oem_raw {
|
||||
GRilIoQueue *q;
|
||||
DBusConnection *conn;
|
||||
char *path;
|
||||
char *log_prefix;
|
||||
};
|
||||
|
||||
#define DBG_(oem,fmt,args...) DBG("%s" fmt, (oem)->log_prefix, ##args)
|
||||
|
||||
static void ril_oem_raw_send_cb(GRilIoChannel *io, int ril_status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
DBusMessage *msg = user_data;
|
||||
DBusMessage *reply;
|
||||
|
||||
if (ril_status == RIL_E_SUCCESS) {
|
||||
DBusMessageIter it, array;
|
||||
const guchar* bytes = data;
|
||||
guint i;
|
||||
|
||||
reply = dbus_message_new_method_return(msg);
|
||||
dbus_message_iter_init_append(reply, &it);
|
||||
dbus_message_iter_open_container(&it, DBUS_TYPE_ARRAY,
|
||||
DBUS_TYPE_BYTE_AS_STRING, &array);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
guchar byte = bytes[i];
|
||||
dbus_message_iter_append_basic(&array, DBUS_TYPE_BYTE,
|
||||
&byte);
|
||||
}
|
||||
|
||||
dbus_message_iter_close_container(&it, &array);
|
||||
} else if (ril_status == GRILIO_STATUS_TIMEOUT) {
|
||||
DBG("Timed out");
|
||||
reply = __ofono_error_timed_out(msg);
|
||||
} else {
|
||||
DBG("Error %s", ril_error_to_string(ril_status));
|
||||
reply = __ofono_error_failed(msg);
|
||||
}
|
||||
|
||||
__ofono_dbus_pending_reply(&msg, reply);
|
||||
}
|
||||
|
||||
static DBusMessage *ril_oem_raw_send(DBusConnection *conn, DBusMessage *msg,
|
||||
void *user_data)
|
||||
{
|
||||
DBusMessageIter it;
|
||||
struct ril_oem_raw *oem = user_data;
|
||||
|
||||
dbus_message_iter_init(msg, &it);
|
||||
if (dbus_message_iter_get_arg_type(&it) == DBUS_TYPE_ARRAY &&
|
||||
dbus_message_iter_get_element_type(&it) == DBUS_TYPE_BYTE) {
|
||||
char *data;
|
||||
int data_len;
|
||||
DBusMessageIter array;
|
||||
GRilIoRequest *req;
|
||||
|
||||
/* Fetch the data */
|
||||
dbus_message_iter_recurse(&it, &array);
|
||||
dbus_message_iter_get_fixed_array(&array, &data, &data_len);
|
||||
DBG_(oem, "%d bytes", data_len);
|
||||
|
||||
/*
|
||||
* And forward it to rild. Set a timeout because rild may
|
||||
* never respond to invalid requests.
|
||||
*/
|
||||
req = grilio_request_sized_new(data_len);
|
||||
grilio_request_set_timeout(req, RIL_OEM_RAW_TIMEOUT);
|
||||
grilio_request_append_bytes(req, data, data_len);
|
||||
grilio_queue_send_request_full(oem->q, req,
|
||||
RIL_REQUEST_OEM_HOOK_RAW, ril_oem_raw_send_cb,
|
||||
NULL, dbus_message_ref(msg));
|
||||
grilio_request_unref(req);
|
||||
return NULL;
|
||||
} else {
|
||||
DBG_(oem, "Unexpected signature");
|
||||
return __ofono_error_invalid_args(msg);
|
||||
}
|
||||
}
|
||||
|
||||
static const GDBusMethodTable ril_oem_raw_methods[] = {
|
||||
{ GDBUS_ASYNC_METHOD("Send",
|
||||
GDBUS_ARGS({ "request", "ay" }),
|
||||
GDBUS_ARGS({ "response", "ay" }),
|
||||
ril_oem_raw_send) },
|
||||
{ }
|
||||
};
|
||||
|
||||
struct ril_oem_raw *ril_oem_raw_new(struct ril_modem *modem,
|
||||
const char *log_prefix)
|
||||
{
|
||||
struct ril_oem_raw *oem = g_new0(struct ril_oem_raw, 1);
|
||||
|
||||
DBG("%s", ril_modem_get_path(modem));
|
||||
oem->path = g_strdup(ril_modem_get_path(modem));
|
||||
oem->conn = dbus_connection_ref(ofono_dbus_get_connection());
|
||||
oem->q = grilio_queue_new(ril_modem_io(modem));
|
||||
oem->log_prefix = (log_prefix && log_prefix[0]) ?
|
||||
g_strconcat(log_prefix, " ", NULL) : g_strdup("");
|
||||
|
||||
/* Register D-Bus interface */
|
||||
if (g_dbus_register_interface(oem->conn, oem->path,
|
||||
RIL_OEM_RAW_INTERFACE, ril_oem_raw_methods,
|
||||
NULL, NULL, oem, NULL)) {
|
||||
ofono_modem_add_interface(modem->ofono, RIL_OEM_RAW_INTERFACE);
|
||||
return oem;
|
||||
} else {
|
||||
ofono_error("OemRaw D-Bus register failed");
|
||||
ril_oem_raw_free(oem);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ril_oem_raw_free(struct ril_oem_raw *oem)
|
||||
{
|
||||
if (oem) {
|
||||
DBG("%s", oem->path);
|
||||
g_dbus_unregister_interface(oem->conn, oem->path,
|
||||
RIL_OEM_RAW_INTERFACE);
|
||||
dbus_connection_unref(oem->conn);
|
||||
|
||||
grilio_queue_cancel_all(oem->q, TRUE);
|
||||
grilio_queue_unref(oem->q);
|
||||
|
||||
g_free(oem->log_prefix);
|
||||
g_free(oem->path);
|
||||
g_free(oem);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_PLUGIN_H
|
||||
#define RIL_PLUGIN_H
|
||||
|
||||
#include "ril_types.h"
|
||||
#include "sailfish_manager.h"
|
||||
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/call-barring.h>
|
||||
#include <ofono/call-forwarding.h>
|
||||
#include <ofono/call-settings.h>
|
||||
#include <ofono/call-volume.h>
|
||||
#include <ofono/cbs.h>
|
||||
#include <ofono/devinfo.h>
|
||||
#include <ofono/gprs-context.h>
|
||||
#include <ofono/gprs.h>
|
||||
#include <ofono/netreg.h>
|
||||
#include <ofono/phonebook.h>
|
||||
#include <ofono/radio-settings.h>
|
||||
#include <ofono/sim.h>
|
||||
#include <ofono/sms.h>
|
||||
#include <ofono/stk.h>
|
||||
#include <ofono/ussd.h>
|
||||
#include <ofono/voicecall.h>
|
||||
#include <ofono/netmon.h>
|
||||
|
||||
#include <grilio_queue.h>
|
||||
#include <grilio_request.h>
|
||||
#include <grilio_parser.h>
|
||||
|
||||
#define RILMODEM_DRIVER "ril"
|
||||
|
||||
struct ril_modem {
|
||||
GRilIoChannel *io;
|
||||
const char *imei;
|
||||
const char *imeisv;
|
||||
const char *log_prefix;
|
||||
const char *ecclist_file;
|
||||
struct ofono_modem *ofono;
|
||||
struct sailfish_cell_info *cell_info;
|
||||
struct ril_radio *radio;
|
||||
struct ril_data *data;
|
||||
struct ril_network *network;
|
||||
struct ril_sim_card *sim_card;
|
||||
struct ril_sim_settings *sim_settings;
|
||||
struct ril_slot_config config;
|
||||
};
|
||||
|
||||
struct ril_oem_raw;
|
||||
struct ril_oem_raw *ril_oem_raw_new(struct ril_modem *modem,
|
||||
const char *log_prefix);
|
||||
void ril_oem_raw_free(struct ril_oem_raw *raw);
|
||||
|
||||
struct ril_modem *ril_modem_create(GRilIoChannel *io, const char *log_prefix,
|
||||
const char *path, const char *imei, const char *imeisv,
|
||||
const char *ecclist_file, const struct ril_slot_config *config,
|
||||
struct ril_radio *radio, struct ril_network *network,
|
||||
struct ril_sim_card *card, struct ril_data *data,
|
||||
struct ril_sim_settings *settings,
|
||||
struct sailfish_cell_info *cell_info);
|
||||
void ril_modem_delete(struct ril_modem *modem);
|
||||
struct ofono_sim *ril_modem_ofono_sim(struct ril_modem *modem);
|
||||
struct ofono_gprs *ril_modem_ofono_gprs(struct ril_modem *modem);
|
||||
struct ofono_netreg *ril_modem_ofono_netreg(struct ril_modem *modem);
|
||||
|
||||
#define ril_modem_get_path(modem) ofono_modem_get_path((modem)->ofono)
|
||||
#define ril_modem_4g_enabled(modem) ((modem)->config.enable_4g)
|
||||
#define ril_modem_slot(modem) ((modem)->config.slot)
|
||||
#define ril_modem_io(modem) ((modem)->io)
|
||||
|
||||
int ril_sim_app_type(struct ofono_sim *sim);
|
||||
int ril_netreg_check_if_really_roaming(struct ofono_netreg *reg, gint status);
|
||||
|
||||
extern const struct ofono_call_barring_driver ril_call_barring_driver;
|
||||
extern const struct ofono_call_forwarding_driver ril_call_forwarding_driver;
|
||||
extern const struct ofono_call_settings_driver ril_call_settings_driver;
|
||||
extern const struct ofono_call_volume_driver ril_call_volume_driver;
|
||||
extern const struct ofono_cbs_driver ril_cbs_driver;
|
||||
extern const struct ofono_devinfo_driver ril_devinfo_driver;
|
||||
extern const struct ofono_gprs_context_driver ril_gprs_context_driver;
|
||||
extern const struct ofono_gprs_driver ril_gprs_driver;
|
||||
extern const struct ofono_modem_driver ril_modem_driver;
|
||||
extern const struct ofono_netreg_driver ril_netreg_driver;
|
||||
extern const struct ofono_phonebook_driver ril_phonebook_driver;
|
||||
extern const struct ofono_radio_settings_driver ril_radio_settings_driver;
|
||||
extern const struct ofono_sim_driver ril_sim_driver;
|
||||
extern const struct ofono_sms_driver ril_sms_driver;
|
||||
extern const struct ofono_stk_driver ril_stk_driver;
|
||||
extern const struct ofono_ussd_driver ril_ussd_driver;
|
||||
extern const struct ofono_voicecall_driver ril_voicecall_driver;
|
||||
extern const struct ofono_netmon_driver ril_netmon_driver;
|
||||
|
||||
#endif /* RIL_PLUGIN_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,492 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_radio.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <grilio_queue.h>
|
||||
#include <grilio_request.h>
|
||||
#include <grilio_parser.h>
|
||||
|
||||
#include <gutil_misc.h>
|
||||
|
||||
typedef GObjectClass RilRadioClass;
|
||||
typedef struct ril_radio RilRadio;
|
||||
|
||||
/*
|
||||
* Object states:
|
||||
*
|
||||
* 1. Idle (!pending && !retry)
|
||||
* 2. Power on/off request pending (pending)
|
||||
* 3. Power on retry has been scheduled (retry)
|
||||
*/
|
||||
struct ril_radio_priv {
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
gulong state_event_id;
|
||||
char *log_prefix;
|
||||
GHashTable *req_table;
|
||||
guint pending_id;
|
||||
guint retry_id;
|
||||
guint state_changed_while_request_pending;
|
||||
enum ril_radio_state last_known_state;
|
||||
gboolean power_cycle;
|
||||
gboolean next_state_valid;
|
||||
gboolean next_state;
|
||||
};
|
||||
|
||||
enum ril_radio_signal {
|
||||
SIGNAL_STATE_CHANGED,
|
||||
SIGNAL_ONLINE_CHANGED,
|
||||
SIGNAL_COUNT
|
||||
};
|
||||
|
||||
#define POWER_RETRY_SECS (1)
|
||||
|
||||
#define SIGNAL_STATE_CHANGED_NAME "ril-radio-state-changed"
|
||||
#define SIGNAL_ONLINE_CHANGED_NAME "ril-radio-online-changed"
|
||||
|
||||
static guint ril_radio_signals[SIGNAL_COUNT] = { 0 };
|
||||
|
||||
#define NEW_SIGNAL(klass,name) \
|
||||
ril_radio_signals[SIGNAL_##name##_CHANGED] = \
|
||||
g_signal_new(SIGNAL_##name##_CHANGED_NAME, \
|
||||
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
|
||||
0, NULL, NULL, NULL, G_TYPE_NONE, 0)
|
||||
|
||||
G_DEFINE_TYPE(RilRadio, ril_radio, G_TYPE_OBJECT)
|
||||
#define RIL_RADIO_TYPE (ril_radio_get_type())
|
||||
#define RIL_RADIO(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj,RIL_RADIO_TYPE,RilRadio))
|
||||
|
||||
#define DBG_(self,fmt,args...) DBG("%s" fmt, (self)->priv->log_prefix, ##args)
|
||||
|
||||
static void ril_radio_submit_power_request(struct ril_radio *self, gboolean on);
|
||||
|
||||
static inline gboolean ril_radio_power_should_be_on(struct ril_radio *self)
|
||||
{
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
return (self->online || g_hash_table_size(priv->req_table) > 0) &&
|
||||
!priv->power_cycle;
|
||||
}
|
||||
|
||||
static inline gboolean ril_radio_state_off(enum ril_radio_state radio_state)
|
||||
{
|
||||
return radio_state == RADIO_STATE_OFF;
|
||||
}
|
||||
|
||||
static inline gboolean ril_radio_state_on(enum ril_radio_state radio_state)
|
||||
{
|
||||
return !ril_radio_state_off(radio_state);
|
||||
}
|
||||
|
||||
static inline void ril_radio_emit_signal(struct ril_radio *self,
|
||||
enum ril_radio_signal id)
|
||||
{
|
||||
g_signal_emit(self, ril_radio_signals[id], 0);
|
||||
}
|
||||
|
||||
static gboolean ril_radio_power_request_retry_cb(gpointer user_data)
|
||||
{
|
||||
struct ril_radio *self = RIL_RADIO(user_data);
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
DBG_(self, "");
|
||||
GASSERT(priv->retry_id);
|
||||
priv->retry_id = 0;
|
||||
ril_radio_submit_power_request(self,
|
||||
ril_radio_power_should_be_on(self));
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void ril_radio_cancel_retry(struct ril_radio *self)
|
||||
{
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
if (priv->retry_id) {
|
||||
DBG_(self, "retry cancelled");
|
||||
g_source_remove(priv->retry_id);
|
||||
priv->retry_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_radio_check_state(struct ril_radio *self)
|
||||
{
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
if (!priv->pending_id) {
|
||||
gboolean should_be_on = ril_radio_power_should_be_on(self);
|
||||
|
||||
if (ril_radio_state_on(priv->last_known_state) ==
|
||||
should_be_on) {
|
||||
/* All is good, cancel pending retry if there is one */
|
||||
ril_radio_cancel_retry(self);
|
||||
} else if (priv->state_changed_while_request_pending) {
|
||||
/* Hmm... RIL's reaction was inadequate, repeat */
|
||||
ril_radio_submit_power_request(self, should_be_on);
|
||||
} else if (!priv->retry_id) {
|
||||
/* There has been no reaction so far, wait a bit */
|
||||
DBG_(self, "retry scheduled");
|
||||
priv->retry_id = g_timeout_add_seconds(POWER_RETRY_SECS,
|
||||
ril_radio_power_request_retry_cb, self);
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't update public state while something is pending */
|
||||
if (!priv->pending_id && !priv->retry_id &&
|
||||
self->state != priv->last_known_state) {
|
||||
DBG_(self, "%s -> %s", ril_radio_state_to_string(self->state),
|
||||
ril_radio_state_to_string(priv->last_known_state));
|
||||
self->state = priv->last_known_state;
|
||||
ril_radio_emit_signal(self, SIGNAL_STATE_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_radio_power_request_done(struct ril_radio *self)
|
||||
{
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
GASSERT(priv->pending_id);
|
||||
priv->pending_id = 0;
|
||||
|
||||
if (priv->next_state_valid) {
|
||||
ril_radio_submit_power_request(self, priv->next_state);
|
||||
} else {
|
||||
ril_radio_check_state(self);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_radio_power_request_cb(GRilIoChannel *channel, int ril_status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_radio *self = RIL_RADIO(user_data);
|
||||
|
||||
if (ril_status != RIL_E_SUCCESS) {
|
||||
ofono_error("Power request failed: %s",
|
||||
ril_error_to_string(ril_status));
|
||||
}
|
||||
|
||||
ril_radio_power_request_done(self);
|
||||
}
|
||||
|
||||
static void ril_radio_submit_power_request(struct ril_radio *self, gboolean on)
|
||||
{
|
||||
/*
|
||||
* RIL_REQUEST_RADIO_POWER
|
||||
*
|
||||
* "data" is int *
|
||||
* ((int *)data)[0] is > 0 for "Radio On"
|
||||
* ((int *)data)[0] is == 0 for "Radio Off"
|
||||
*
|
||||
* "response" is NULL
|
||||
**/
|
||||
GRilIoRequest *req = grilio_request_array_int32_new(1, on);
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
priv->next_state_valid = FALSE;
|
||||
priv->next_state = on;
|
||||
priv->state_changed_while_request_pending = 0;
|
||||
ril_radio_cancel_retry(self);
|
||||
|
||||
GASSERT(!priv->pending_id);
|
||||
grilio_request_set_blocking(req, TRUE);
|
||||
priv->pending_id = grilio_queue_send_request_full(priv->q, req,
|
||||
RIL_REQUEST_RADIO_POWER, ril_radio_power_request_cb,
|
||||
NULL, self);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_radio_power_request(struct ril_radio *self, gboolean on,
|
||||
gboolean allow_repeat)
|
||||
{
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
const char *on_off = on ? "on" : "off";
|
||||
|
||||
if (priv->pending_id) {
|
||||
if (allow_repeat || priv->next_state != on) {
|
||||
/* Wait for the pending request to complete */
|
||||
priv->next_state_valid = TRUE;
|
||||
priv->next_state = on;
|
||||
DBG_(self, "%s (queued)", on_off);
|
||||
} else {
|
||||
DBG_(self, "%s (ignored)", on_off);
|
||||
}
|
||||
} else {
|
||||
if (ril_radio_state_on(priv->last_known_state) == on) {
|
||||
DBG_(self, "%s (already)", on_off);
|
||||
ril_radio_check_state(self);
|
||||
} else {
|
||||
DBG_(self, "%s", on_off);
|
||||
ril_radio_submit_power_request(self, on);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ril_radio_confirm_power_on(struct ril_radio *self)
|
||||
{
|
||||
if (G_LIKELY(self) && ril_radio_power_should_be_on(self)) {
|
||||
ril_radio_power_request(self, TRUE, TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
void ril_radio_power_cycle(struct ril_radio *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
if (ril_radio_state_off(priv->last_known_state)) {
|
||||
DBG_(self, "power is already off");
|
||||
GASSERT(!priv->power_cycle);
|
||||
} else if (priv->power_cycle) {
|
||||
DBG_(self, "already in progress");
|
||||
} else {
|
||||
DBG_(self, "initiated");
|
||||
priv->power_cycle = TRUE;
|
||||
if (!priv->pending_id) {
|
||||
ril_radio_submit_power_request(self, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ril_radio_power_on(struct ril_radio *self, gpointer tag)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
if (!g_hash_table_contains(priv->req_table, tag)) {
|
||||
gboolean was_on = ril_radio_power_should_be_on(self);
|
||||
|
||||
DBG_(self, "%p", tag);
|
||||
g_hash_table_insert(priv->req_table, tag, tag);
|
||||
if (!was_on && ril_radio_power_should_be_on(self)) {
|
||||
ril_radio_power_request(self, TRUE, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ril_radio_power_off(struct ril_radio *self, gpointer tag)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
if (g_hash_table_remove(priv->req_table, tag)) {
|
||||
DBG_(self, "%p", tag);
|
||||
if (!ril_radio_power_should_be_on(self)) {
|
||||
/* The last one turns the lights off */
|
||||
ril_radio_power_request(self, FALSE, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ril_radio_set_online(struct ril_radio *self, gboolean online)
|
||||
{
|
||||
if (G_LIKELY(self) && self->online != online) {
|
||||
gboolean on, was_on = ril_radio_power_should_be_on(self);
|
||||
self->online = online;
|
||||
on = ril_radio_power_should_be_on(self);
|
||||
if (was_on != on) {
|
||||
ril_radio_power_request(self, on, FALSE);
|
||||
}
|
||||
ril_radio_emit_signal(self, SIGNAL_ONLINE_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
gulong ril_radio_add_state_changed_handler(struct ril_radio *self,
|
||||
ril_radio_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_STATE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong ril_radio_add_online_changed_handler(struct ril_radio *self,
|
||||
ril_radio_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_ONLINE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
void ril_radio_remove_handler(struct ril_radio *self, gulong id)
|
||||
{
|
||||
if (G_LIKELY(self) && G_LIKELY(id)) {
|
||||
g_signal_handler_disconnect(self, id);
|
||||
}
|
||||
}
|
||||
|
||||
void ril_radio_remove_handlers(struct ril_radio *self, gulong *ids, int count)
|
||||
{
|
||||
gutil_disconnect_handlers(self, ids, count);
|
||||
}
|
||||
|
||||
enum ril_radio_state ril_radio_state_parse(const void *data, guint len)
|
||||
{
|
||||
GRilIoParser rilp;
|
||||
int radio_state;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
if (grilio_parser_get_int32(&rilp, &radio_state)) {
|
||||
return radio_state;
|
||||
} else {
|
||||
ofono_error("Error parsing radio state");
|
||||
return RADIO_STATE_UNAVAILABLE;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_radio_state_changed(GRilIoChannel *io, guint code,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_radio *self = RIL_RADIO(user_data);
|
||||
enum ril_radio_state radio_state = ril_radio_state_parse(data, len);
|
||||
|
||||
GASSERT(code == RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED);
|
||||
if (radio_state != RADIO_STATE_UNAVAILABLE) {
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
DBG_(self, "%s", ril_radio_state_to_string(radio_state));
|
||||
GASSERT(!priv->pending_id || !priv->retry_id);
|
||||
|
||||
if (priv->power_cycle && ril_radio_state_off(radio_state)) {
|
||||
DBG_(self, "switched off for power cycle");
|
||||
priv->power_cycle = FALSE;
|
||||
}
|
||||
|
||||
priv->last_known_state = radio_state;
|
||||
|
||||
if (priv->pending_id) {
|
||||
if (ril_radio_state_on(radio_state) ==
|
||||
ril_radio_power_should_be_on(self)) {
|
||||
DBG_(self, "dropping pending request");
|
||||
/*
|
||||
* All right, the modem has switched to the
|
||||
* desired state, drop the request.
|
||||
*/
|
||||
grilio_queue_cancel_request(priv->q,
|
||||
priv->pending_id, FALSE);
|
||||
|
||||
/*
|
||||
* This will zero pending_id and call
|
||||
* ril_radio_check_state() if necesary:
|
||||
*/
|
||||
ril_radio_power_request_done(self);
|
||||
|
||||
/* We are done */
|
||||
return;
|
||||
} else {
|
||||
/* Something weird is going on */
|
||||
priv->state_changed_while_request_pending++;
|
||||
}
|
||||
}
|
||||
|
||||
ril_radio_check_state(self);
|
||||
}
|
||||
}
|
||||
|
||||
struct ril_radio *ril_radio_new(GRilIoChannel *io)
|
||||
{
|
||||
struct ril_radio *self = g_object_new(RIL_RADIO_TYPE, NULL);
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
priv->io = grilio_channel_ref(io);
|
||||
priv->q = grilio_queue_new(priv->io);
|
||||
priv->log_prefix =
|
||||
(io && io->name && io->name[0] && strcmp(io->name, "RIL")) ?
|
||||
g_strconcat(io->name, " ", NULL) : g_strdup("");
|
||||
DBG_(self, "");
|
||||
priv->state_event_id = grilio_channel_add_unsol_event_handler(priv->io,
|
||||
ril_radio_state_changed,
|
||||
RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, self);
|
||||
return self;
|
||||
}
|
||||
|
||||
struct ril_radio *ril_radio_ref(struct ril_radio *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
g_object_ref(RIL_RADIO(self));
|
||||
return self;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ril_radio_unref(struct ril_radio *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
g_object_unref(RIL_RADIO(self));
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_radio_init(struct ril_radio *self)
|
||||
{
|
||||
struct ril_radio_priv *priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
|
||||
RIL_RADIO_TYPE, struct ril_radio_priv);
|
||||
self->priv = priv;
|
||||
priv->req_table = g_hash_table_new_full(g_direct_hash, g_direct_equal,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
static void ril_radio_dispose(GObject *object)
|
||||
{
|
||||
struct ril_radio *self = RIL_RADIO(object);
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
if (priv->state_event_id) {
|
||||
grilio_channel_remove_handler(priv->io, priv->state_event_id);
|
||||
priv->state_event_id = 0;
|
||||
}
|
||||
if (priv->pending_id) {
|
||||
grilio_queue_cancel_request(priv->q, priv->pending_id, FALSE);
|
||||
priv->pending_id = 0;
|
||||
}
|
||||
priv->next_state_valid = FALSE;
|
||||
ril_radio_cancel_retry(self);
|
||||
grilio_queue_cancel_all(priv->q, FALSE);
|
||||
G_OBJECT_CLASS(ril_radio_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void ril_radio_finalize(GObject *object)
|
||||
{
|
||||
struct ril_radio *self = RIL_RADIO(object);
|
||||
struct ril_radio_priv *priv = self->priv;
|
||||
|
||||
DBG_(self, "");
|
||||
g_free(priv->log_prefix);
|
||||
grilio_channel_unref(priv->io);
|
||||
grilio_queue_unref(priv->q);
|
||||
g_hash_table_unref(priv->req_table);
|
||||
G_OBJECT_CLASS(ril_radio_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void ril_radio_class_init(RilRadioClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
object_class->dispose = ril_radio_dispose;
|
||||
object_class->finalize = ril_radio_finalize;
|
||||
g_type_class_add_private(klass, sizeof(struct ril_radio_priv));
|
||||
NEW_SIGNAL(klass, STATE);
|
||||
NEW_SIGNAL(klass, ONLINE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_RADIO_H
|
||||
#define RIL_RADIO_H
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
struct ril_radio {
|
||||
GObject object;
|
||||
struct ril_radio_priv *priv;
|
||||
enum ril_radio_state state;
|
||||
gboolean online;
|
||||
};
|
||||
|
||||
typedef void (*ril_radio_cb_t)(struct ril_radio *radio, void *arg);
|
||||
|
||||
struct ril_radio *ril_radio_new(GRilIoChannel *io);
|
||||
struct ril_radio *ril_radio_ref(struct ril_radio *radio);
|
||||
void ril_radio_unref(struct ril_radio *radio);
|
||||
|
||||
void ril_radio_power_on(struct ril_radio *radio, gpointer tag);
|
||||
void ril_radio_power_off(struct ril_radio *radio, gpointer tag);
|
||||
void ril_radio_power_cycle(struct ril_radio *radio);
|
||||
void ril_radio_confirm_power_on(struct ril_radio *radio);
|
||||
void ril_radio_set_online(struct ril_radio *radio, gboolean online);
|
||||
gulong ril_radio_add_state_changed_handler(struct ril_radio *radio,
|
||||
ril_radio_cb_t cb, void *arg);
|
||||
gulong ril_radio_add_online_changed_handler(struct ril_radio *radio,
|
||||
ril_radio_cb_t cb, void *arg);
|
||||
void ril_radio_remove_handler(struct ril_radio *radio, gulong id);
|
||||
void ril_radio_remove_handlers(struct ril_radio *radio, gulong *ids, int n);
|
||||
enum ril_radio_state ril_radio_state_parse(const void *data, guint len);
|
||||
|
||||
#define ril_radio_remove_all_handlers(r,ids) \
|
||||
ril_radio_remove_handlers(r, ids, G_N_ELEMENTS(ids))
|
||||
|
||||
#endif /* RIL_RADIO_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_RADIO_CAPS_H
|
||||
#define RIL_RADIO_CAPS_H
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
struct ril_data_manager;
|
||||
struct ril_radio_caps;
|
||||
struct ril_radio_caps_manager;
|
||||
struct ril_radio_capability;
|
||||
|
||||
typedef void (*ril_radio_caps_manager_cb_t)(struct ril_radio_caps_manager *mgr,
|
||||
void *user_data);
|
||||
/* ril_radio_capability pointer is NULL if functionality is unsupported */
|
||||
typedef void (*ril_radio_caps_check_cb_t)
|
||||
(const struct ril_radio_capability *cap, void *user_data);
|
||||
|
||||
/* The check can be cancelled with grilio_channel_cancel_request */
|
||||
guint ril_radio_caps_check(GRilIoChannel *io, ril_radio_caps_check_cb_t cb,
|
||||
void *user_data);
|
||||
|
||||
/* There should be a single ril_radio_caps_manager shared by all all modems */
|
||||
struct ril_radio_caps_manager *ril_radio_caps_manager_new
|
||||
(struct ril_data_manager *dm);
|
||||
struct ril_radio_caps_manager *ril_radio_caps_manager_ref
|
||||
(struct ril_radio_caps_manager *mgr);
|
||||
void ril_radio_caps_manager_unref(struct ril_radio_caps_manager *mgr);
|
||||
gulong ril_radio_caps_manager_add_aborted_handler
|
||||
(struct ril_radio_caps_manager *mgr,
|
||||
ril_radio_caps_manager_cb_t cb, void *arg);
|
||||
void ril_radio_caps_manager_remove_handler(struct ril_radio_caps_manager *mgr,
|
||||
gulong id);
|
||||
|
||||
/* And one ril_radio_caps object per modem */
|
||||
struct ril_radio_caps *ril_radio_caps_new(struct ril_radio_caps_manager *mgr,
|
||||
const char *log_prefix, GRilIoChannel *io,
|
||||
struct ril_data *data, struct ril_radio *radio,
|
||||
struct ril_sim_card *sim, struct ril_network *net,
|
||||
const struct ril_slot_config *config,
|
||||
const struct ril_radio_capability *cap);
|
||||
struct ril_radio_caps *ril_radio_caps_ref(struct ril_radio_caps *caps);
|
||||
void ril_radio_caps_unref(struct ril_radio_caps *caps);
|
||||
|
||||
#endif /* RIL_RADIO_CAPS_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_sim_settings.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
struct ril_radio_settings {
|
||||
struct ofono_radio_settings *rs;
|
||||
struct ril_sim_settings *settings;
|
||||
const char *log_prefix;
|
||||
char *allocated_log_prefix;
|
||||
guint source_id;
|
||||
};
|
||||
|
||||
struct ril_radio_settings_cbd {
|
||||
struct ril_radio_settings *rsd;
|
||||
union _ofono_radio_settings_cb {
|
||||
ofono_radio_settings_rat_mode_set_cb_t rat_mode_set;
|
||||
ofono_radio_settings_rat_mode_query_cb_t rat_mode_query;
|
||||
ofono_radio_settings_available_rats_query_cb_t available_rats;
|
||||
gpointer ptr;
|
||||
} cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
#define DBG_(rsd,fmt,args...) DBG("%s" fmt, (rsd)->log_prefix, ##args)
|
||||
|
||||
static inline struct ril_radio_settings *ril_radio_settings_get_data(
|
||||
struct ofono_radio_settings *rs)
|
||||
{
|
||||
return ofono_radio_settings_get_data(rs);
|
||||
}
|
||||
|
||||
static void ril_radio_settings_later(struct ril_radio_settings *rsd,
|
||||
GSourceFunc fn, void *cb, void *data)
|
||||
{
|
||||
struct ril_radio_settings_cbd *cbd;
|
||||
|
||||
cbd = g_new0(struct ril_radio_settings_cbd, 1);
|
||||
cbd->rsd = rsd;
|
||||
cbd->cb.ptr = cb;
|
||||
cbd->data = data;
|
||||
|
||||
GASSERT(!rsd->source_id);
|
||||
rsd->source_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE,
|
||||
fn, cbd, g_free);
|
||||
}
|
||||
|
||||
static gboolean ril_radio_settings_set_rat_mode_cb(gpointer user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_radio_settings_cbd *cbd = user_data;
|
||||
struct ril_radio_settings *rsd = cbd->rsd;
|
||||
|
||||
GASSERT(rsd->source_id);
|
||||
rsd->source_id = 0;
|
||||
cbd->cb.rat_mode_set(ril_error_ok(&error), cbd->data);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void ril_radio_settings_set_rat_mode(struct ofono_radio_settings *rs,
|
||||
enum ofono_radio_access_mode mode,
|
||||
ofono_radio_settings_rat_mode_set_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_radio_settings *rsd = ril_radio_settings_get_data(rs);
|
||||
DBG_(rsd, "%s", ofono_radio_access_mode_to_string(mode));
|
||||
ril_sim_settings_set_pref_mode(rsd->settings, mode);
|
||||
ril_radio_settings_later(rsd, ril_radio_settings_set_rat_mode_cb,
|
||||
cb, data);
|
||||
}
|
||||
|
||||
static gboolean ril_radio_settings_query_rat_mode_cb(gpointer user_data)
|
||||
{
|
||||
struct ril_radio_settings_cbd *cbd = user_data;
|
||||
struct ril_radio_settings *rsd = cbd->rsd;
|
||||
enum ofono_radio_access_mode mode = rsd->settings->pref_mode;
|
||||
struct ofono_error error;
|
||||
|
||||
DBG_(rsd, "rat mode %s", ofono_radio_access_mode_to_string(mode));
|
||||
GASSERT(rsd->source_id);
|
||||
rsd->source_id = 0;
|
||||
cbd->cb.rat_mode_query(ril_error_ok(&error), mode, cbd->data);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void ril_radio_settings_query_rat_mode(struct ofono_radio_settings *rs,
|
||||
ofono_radio_settings_rat_mode_query_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_radio_settings *rsd = ril_radio_settings_get_data(rs);
|
||||
|
||||
DBG_(rsd, "");
|
||||
ril_radio_settings_later(rsd, ril_radio_settings_query_rat_mode_cb,
|
||||
cb, data);
|
||||
}
|
||||
|
||||
static gboolean ril_radio_settings_query_available_rats_cb(gpointer data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_radio_settings_cbd *cbd = data;
|
||||
struct ril_radio_settings *rsd = cbd->rsd;
|
||||
|
||||
GASSERT(rsd->source_id);
|
||||
rsd->source_id = 0;
|
||||
cbd->cb.available_rats(ril_error_ok(&error), rsd->settings->techs,
|
||||
cbd->data);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void ril_radio_settings_query_available_rats(
|
||||
struct ofono_radio_settings *rs,
|
||||
ofono_radio_settings_available_rats_query_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_radio_settings *rsd = ril_radio_settings_get_data(rs);
|
||||
|
||||
DBG_(rsd, "");
|
||||
ril_radio_settings_later(rsd,
|
||||
ril_radio_settings_query_available_rats_cb, cb, data);
|
||||
}
|
||||
|
||||
static gboolean ril_radio_settings_register(gpointer user_data)
|
||||
{
|
||||
struct ril_radio_settings *rsd = user_data;
|
||||
GASSERT(rsd->source_id);
|
||||
rsd->source_id = 0;
|
||||
ofono_radio_settings_register(rsd->rs);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static int ril_radio_settings_probe(struct ofono_radio_settings *rs,
|
||||
unsigned int vendor, void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_radio_settings *rsd = g_new0(struct ril_radio_settings, 1);
|
||||
|
||||
DBG("%s", modem->log_prefix);
|
||||
rsd->rs = rs;
|
||||
rsd->settings = ril_sim_settings_ref(modem->sim_settings);
|
||||
rsd->source_id = g_idle_add(ril_radio_settings_register, rsd);
|
||||
|
||||
if (modem->log_prefix && modem->log_prefix[0]) {
|
||||
rsd->log_prefix = rsd->allocated_log_prefix =
|
||||
g_strconcat(modem->log_prefix, " ", NULL);
|
||||
} else {
|
||||
rsd->log_prefix = "";
|
||||
}
|
||||
|
||||
ofono_radio_settings_set_data(rs, rsd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_radio_settings_remove(struct ofono_radio_settings *rs)
|
||||
{
|
||||
struct ril_radio_settings *rsd = ril_radio_settings_get_data(rs);
|
||||
|
||||
DBG_(rsd, "");
|
||||
ofono_radio_settings_set_data(rs, NULL);
|
||||
if (rsd->source_id) {
|
||||
g_source_remove(rsd->source_id);
|
||||
}
|
||||
ril_sim_settings_unref(rsd->settings);
|
||||
g_free(rsd->allocated_log_prefix);
|
||||
g_free(rsd);
|
||||
}
|
||||
|
||||
const struct ofono_radio_settings_driver ril_radio_settings_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_radio_settings_probe,
|
||||
.remove = ril_radio_settings_remove,
|
||||
.query_rat_mode = ril_radio_settings_query_rat_mode,
|
||||
.set_rat_mode = ril_radio_settings_set_rat_mode,
|
||||
.query_available_rats = ril_radio_settings_query_available_rats
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,803 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_sim_card.h"
|
||||
#include "ril_radio.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <grilio_queue.h>
|
||||
#include <grilio_request.h>
|
||||
#include <grilio_parser.h>
|
||||
|
||||
#include <gutil_misc.h>
|
||||
|
||||
/*
|
||||
* First we wait for USIM app to get activated by itself. If that
|
||||
* doesn't happen within UICC_SUBSCRIPTION_START_MS we poke the SIM
|
||||
* with SET_UICC_SUBSCRIPTION request, resubmitting it if it times out.
|
||||
* If nothing happens within UICC_SUBSCRIPTION_TIMEOUT_MS we give up.
|
||||
*
|
||||
* Submitting SET_UICC_SUBSCRIPTION request when rild doesn't expect
|
||||
* it sometimes breaks pretty much everything. Unfortunately, there no
|
||||
* reliable way to find out when rild expects it and when it doesn't :/
|
||||
*/
|
||||
#define UICC_SUBSCRIPTION_START_MS (5000)
|
||||
#define UICC_SUBSCRIPTION_TIMEOUT_MS (30000)
|
||||
|
||||
/* SIM I/O idle timeout is measured in the number of idle loops.
|
||||
* When active SIM I/O is going on, the idle loop count very rarely
|
||||
* exceeds 1 between the requests, so 10 is more than enough. Idle
|
||||
* loop is actually more accurate criteria than a timeout because
|
||||
* it doesn't depend that much on the system load. */
|
||||
#define SIM_IO_IDLE_LOOPS (10)
|
||||
|
||||
typedef GObjectClass RilSimCardClass;
|
||||
typedef struct ril_sim_card RilSimCard;
|
||||
|
||||
enum ril_sim_card_event {
|
||||
EVENT_SIM_STATUS_CHANGED,
|
||||
EVENT_UICC_SUBSCRIPTION_STATUS_CHANGED,
|
||||
EVENT_COUNT
|
||||
};
|
||||
|
||||
struct ril_sim_card_priv {
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
int flags;
|
||||
guint status_req_id;
|
||||
guint sub_req_id;
|
||||
guint sub_start_timer;
|
||||
gulong event_id[EVENT_COUNT];
|
||||
guint sim_io_idle_id;
|
||||
guint sim_io_idle_count;
|
||||
GHashTable* sim_io_pending;
|
||||
};
|
||||
|
||||
enum ril_sim_card_signal {
|
||||
SIGNAL_STATUS_RECEIVED,
|
||||
SIGNAL_STATUS_CHANGED,
|
||||
SIGNAL_STATE_CHANGED,
|
||||
SIGNAL_APP_CHANGED,
|
||||
SIGNAL_SIM_IO_ACTIVE_CHANGED,
|
||||
SIGNAL_COUNT
|
||||
};
|
||||
|
||||
#define SIGNAL_STATUS_RECEIVED_NAME "ril-simcard-status-received"
|
||||
#define SIGNAL_STATUS_CHANGED_NAME "ril-simcard-status-changed"
|
||||
#define SIGNAL_STATE_CHANGED_NAME "ril-simcard-state-changed"
|
||||
#define SIGNAL_APP_CHANGED_NAME "ril-simcard-app-changed"
|
||||
#define SIGNAL_SIM_IO_ACTIVE_CHANGED_NAME "ril-simcard-sim-io-active-changed"
|
||||
|
||||
static guint ril_sim_card_signals[SIGNAL_COUNT] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE(RilSimCard, ril_sim_card, G_TYPE_OBJECT)
|
||||
#define RIL_SIMCARD_TYPE (ril_sim_card_get_type())
|
||||
#define RIL_SIMCARD(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), \
|
||||
RIL_SIMCARD_TYPE, RilSimCard))
|
||||
|
||||
#define NEW_SIGNAL(klass,name) NEW_SIGNAL_(klass,name##_CHANGED)
|
||||
#define NEW_SIGNAL_(klass,name) \
|
||||
ril_sim_card_signals[SIGNAL_##name] = \
|
||||
g_signal_new(SIGNAL_##name##_NAME, \
|
||||
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
|
||||
0, NULL, NULL, NULL, G_TYPE_NONE, 0)
|
||||
|
||||
#define RIL_SIMCARD_STATE_CHANGED (0x01)
|
||||
#define RIL_SIMCARD_STATUS_CHANGED (0x02)
|
||||
|
||||
static gboolean ril_sim_card_app_equal(const struct ril_sim_card_app *a1,
|
||||
const struct ril_sim_card_app *a2)
|
||||
{
|
||||
if (a1 == a2) {
|
||||
return TRUE;
|
||||
} else if (!a1 || !a2) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return a1->app_type == a2->app_type &&
|
||||
a1->app_state == a2->app_state &&
|
||||
a1->perso_substate == a2->perso_substate &&
|
||||
a1->pin_replaced == a2->pin_replaced &&
|
||||
a1->pin1_state == a2->pin1_state &&
|
||||
a1->pin2_state == a2->pin2_state &&
|
||||
!g_strcmp0(a1->aid, a2->aid) &&
|
||||
!g_strcmp0(a1->label, a2->label);
|
||||
}
|
||||
}
|
||||
|
||||
static int ril_sim_card_status_compare(const struct ril_sim_card_status *s1,
|
||||
const struct ril_sim_card_status *s2)
|
||||
{
|
||||
if (s1 == s2) {
|
||||
return 0;
|
||||
} else if (!s1 || !s2) {
|
||||
return RIL_SIMCARD_STATE_CHANGED | RIL_SIMCARD_STATUS_CHANGED;
|
||||
} else {
|
||||
int diff = 0;
|
||||
|
||||
if (s1->card_state != s2->card_state) {
|
||||
diff |= RIL_SIMCARD_STATE_CHANGED;
|
||||
}
|
||||
|
||||
if (s1->pin_state != s2->pin_state ||
|
||||
s1->gsm_umts_index != s2->gsm_umts_index ||
|
||||
s1->cdma_index != s2->cdma_index ||
|
||||
s1->ims_index != s2->ims_index ||
|
||||
s1->num_apps != s2->num_apps) {
|
||||
diff |= RIL_SIMCARD_STATUS_CHANGED;
|
||||
} else {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < s1->num_apps; i++) {
|
||||
if (!ril_sim_card_app_equal(s1->apps + i,
|
||||
s2->apps + i)) {
|
||||
diff |= RIL_SIMCARD_STATUS_CHANGED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return diff;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_sim_card_status_free(struct ril_sim_card_status *status)
|
||||
{
|
||||
if (status) {
|
||||
if (status->apps) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < status->num_apps; i++) {
|
||||
g_free(status->apps[i].aid);
|
||||
g_free(status->apps[i].label);
|
||||
}
|
||||
g_free(status->apps);
|
||||
}
|
||||
g_free(status);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_sim_card_tx_start(struct ril_sim_card *self)
|
||||
{
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
GRILIO_TRANSACTION_STATE tx_state =
|
||||
grilio_queue_transaction_state(priv->q);
|
||||
|
||||
if (tx_state == GRILIO_TRANSACTION_NONE) {
|
||||
tx_state = grilio_queue_transaction_start(priv->q);
|
||||
DBG("status tx for slot %u %s", self->slot,
|
||||
(tx_state == GRILIO_TRANSACTION_STARTED) ?
|
||||
"started" : "starting");
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_sim_card_tx_check(struct ril_sim_card *self)
|
||||
{
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
if (grilio_queue_transaction_state(priv->q) !=
|
||||
GRILIO_TRANSACTION_NONE) {
|
||||
const struct ril_sim_card_status *status = self->status;
|
||||
|
||||
if (status && status->card_state == RIL_CARDSTATE_PRESENT) {
|
||||
/* Transaction (if there is any) is finished when
|
||||
* both GET_SIM_STATUS and SET_UICC_SUBSCRIPTION
|
||||
* complete or get dropped */
|
||||
if (!priv->status_req_id && !priv->sub_req_id &&
|
||||
status->gsm_umts_index >= 0 &&
|
||||
status->gsm_umts_index < status->num_apps) {
|
||||
DBG("status tx for slot %u finished",
|
||||
self->slot);
|
||||
grilio_queue_transaction_finish(priv->q);
|
||||
}
|
||||
} else {
|
||||
DBG("status tx for slot %u cancelled", self->slot);
|
||||
grilio_queue_transaction_finish(priv->q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_sim_card_subscription_done(struct ril_sim_card *self)
|
||||
{
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
if (priv->sub_start_timer) {
|
||||
/* Don't need this timer anymore */
|
||||
g_source_remove(priv->sub_start_timer);
|
||||
priv->sub_start_timer = 0;
|
||||
}
|
||||
if (priv->sub_req_id) {
|
||||
/* Some RILs never reply to SET_UICC_SUBSCRIPTION requst,
|
||||
* so we better drop rather than cancel it (so that it gets
|
||||
* removed from the list of pending requests) */
|
||||
grilio_channel_drop_request(priv->io, priv->sub_req_id);
|
||||
priv->sub_req_id = 0;
|
||||
}
|
||||
ril_sim_card_tx_check(self);
|
||||
}
|
||||
|
||||
static void ril_sim_card_subscribe_cb(GRilIoChannel* io, int status,
|
||||
const void* data, guint len, void* user_data)
|
||||
{
|
||||
struct ril_sim_card *self = RIL_SIMCARD(user_data);
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
GASSERT(status == GRILIO_STATUS_OK);
|
||||
GASSERT(priv->sub_req_id);
|
||||
priv->sub_req_id = 0;
|
||||
DBG("UICC subscription OK for slot %u", self->slot);
|
||||
ril_sim_card_subscription_done(self);
|
||||
}
|
||||
|
||||
static void ril_sim_card_subscribe(struct ril_sim_card *self, int app_index)
|
||||
{
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
GRilIoRequest *req = grilio_request_sized_new(16);
|
||||
const guint sub_id = self->slot;
|
||||
guint code;
|
||||
|
||||
DBG("%u,%d,%u", self->slot, app_index, sub_id);
|
||||
grilio_request_append_int32(req, self->slot);
|
||||
grilio_request_append_int32(req, app_index);
|
||||
grilio_request_append_int32(req, sub_id);
|
||||
grilio_request_append_int32(req, RIL_UICC_SUBSCRIPTION_ACTIVATE);
|
||||
|
||||
grilio_request_set_retry(req, 0, -1);
|
||||
grilio_request_set_timeout(req, UICC_SUBSCRIPTION_TIMEOUT_MS);
|
||||
code = (priv->io->ril_version <= 9 &&
|
||||
(priv->flags & RIL_SIM_CARD_V9_UICC_SUBSCRIPTION_WORKAROUND)) ?
|
||||
RIL_REQUEST_V9_SET_UICC_SUBSCRIPTION :
|
||||
RIL_REQUEST_SET_UICC_SUBSCRIPTION;
|
||||
if (priv->sub_req_id) {
|
||||
/* Some RILs never reply to SET_UICC_SUBSCRIPTION requst,
|
||||
* so we better drop rather than cancel it (so that it gets
|
||||
* removed from the list of pending requests) */
|
||||
grilio_channel_drop_request(priv->io, priv->sub_req_id);
|
||||
}
|
||||
|
||||
/* Don't allow any requests other that GET_SIM_STATUS until
|
||||
* we are done with the subscription */
|
||||
ril_sim_card_tx_start(self);
|
||||
priv->sub_req_id = grilio_queue_send_request_full(priv->q,
|
||||
req, code, ril_sim_card_subscribe_cb, NULL, self);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static int ril_sim_card_select_app(const struct ril_sim_card_status *status)
|
||||
{
|
||||
int i, selected_app = -1;
|
||||
|
||||
for (i = 0; i < status->num_apps; i++) {
|
||||
const int type = status->apps[i].app_type;
|
||||
if (type == RIL_APPTYPE_USIM || type == RIL_APPTYPE_RUIM) {
|
||||
selected_app = i;
|
||||
break;
|
||||
} else if (type != RIL_APPTYPE_UNKNOWN && selected_app == -1) {
|
||||
selected_app = i;
|
||||
}
|
||||
}
|
||||
|
||||
DBG("%d", selected_app);
|
||||
return selected_app;
|
||||
}
|
||||
|
||||
static void ril_sim_card_update_app(struct ril_sim_card *self)
|
||||
{
|
||||
const struct ril_sim_card_app *old_app = self->app;
|
||||
const struct ril_sim_card_status *status = self->status;
|
||||
int app_index;
|
||||
|
||||
if (status->card_state == RIL_CARDSTATE_PRESENT) {
|
||||
if (status->gsm_umts_index >= 0 &&
|
||||
status->gsm_umts_index < status->num_apps) {
|
||||
app_index = status->gsm_umts_index;
|
||||
ril_sim_card_subscription_done(self);
|
||||
} else {
|
||||
app_index = ril_sim_card_select_app(status);
|
||||
if (app_index >= 0 && !self->priv->sub_start_timer) {
|
||||
ril_sim_card_subscribe(self, app_index);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
app_index = -1;
|
||||
ril_sim_card_subscription_done(self);
|
||||
}
|
||||
|
||||
if (app_index >= 0 &&
|
||||
status->apps[app_index].app_type != RIL_APPTYPE_UNKNOWN) {
|
||||
self->app = status->apps + app_index;
|
||||
} else {
|
||||
self->app = NULL;
|
||||
}
|
||||
|
||||
if (!ril_sim_card_app_equal(old_app, self->app)) {
|
||||
g_signal_emit(self, ril_sim_card_signals
|
||||
[SIGNAL_APP_CHANGED], 0);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean ril_sim_card_sub_start_timeout(gpointer user_data)
|
||||
{
|
||||
struct ril_sim_card *self = RIL_SIMCARD(user_data);
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
DBG("%u", self->slot);
|
||||
GASSERT(priv->sub_start_timer);
|
||||
priv->sub_start_timer = 0;
|
||||
ril_sim_card_update_app(self);
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static void ril_sim_card_update_status(struct ril_sim_card *self,
|
||||
struct ril_sim_card_status *status)
|
||||
{
|
||||
const int diff = ril_sim_card_status_compare(self->status, status);
|
||||
|
||||
if (diff) {
|
||||
struct ril_sim_card_status *old_status = self->status;
|
||||
|
||||
self->status = status;
|
||||
if (diff & RIL_SIMCARD_STATE_CHANGED &&
|
||||
status->card_state == RIL_CARDSTATE_PRESENT) {
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
/*
|
||||
* SIM card has just appeared, give it some time to
|
||||
* activate the USIM app
|
||||
*/
|
||||
if (priv->sub_start_timer) {
|
||||
g_source_remove(priv->sub_start_timer);
|
||||
}
|
||||
DBG("started subscription timeout for slot %u",
|
||||
self->slot);
|
||||
priv->sub_start_timer =
|
||||
g_timeout_add(UICC_SUBSCRIPTION_START_MS,
|
||||
ril_sim_card_sub_start_timeout, self);
|
||||
}
|
||||
ril_sim_card_update_app(self);
|
||||
g_signal_emit(self, ril_sim_card_signals
|
||||
[SIGNAL_STATUS_RECEIVED], 0);
|
||||
if (diff & RIL_SIMCARD_STATUS_CHANGED) {
|
||||
DBG("status changed");
|
||||
g_signal_emit(self, ril_sim_card_signals
|
||||
[SIGNAL_STATUS_CHANGED], 0);
|
||||
}
|
||||
if (diff & RIL_SIMCARD_STATE_CHANGED) {
|
||||
DBG("state changed");
|
||||
g_signal_emit(self, ril_sim_card_signals
|
||||
[SIGNAL_STATE_CHANGED], 0);
|
||||
}
|
||||
ril_sim_card_status_free(old_status);
|
||||
} else {
|
||||
ril_sim_card_update_app(self);
|
||||
ril_sim_card_status_free(status);
|
||||
g_signal_emit(self, ril_sim_card_signals
|
||||
[SIGNAL_STATUS_RECEIVED], 0);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean ril_sim_card_app_parse(GRilIoParser *rilp,
|
||||
struct ril_sim_card_app *app)
|
||||
{
|
||||
gint32 app_type, app_state, perso_substate;
|
||||
gint32 pin_replaced, pin1_state, pin2_state;
|
||||
|
||||
grilio_parser_get_int32(rilp, &app_type);
|
||||
grilio_parser_get_int32(rilp, &app_state);
|
||||
|
||||
/*
|
||||
* Consider RIL_APPSTATE_ILLEGAL also READY. Even if app state is
|
||||
* RIL_APPSTATE_ILLEGAL (-1), ICC operations must be permitted.
|
||||
* Network access requests will anyway be rejected and ME will be
|
||||
* in limited service.
|
||||
*/
|
||||
if (app_state == RIL_APPSTATE_ILLEGAL) {
|
||||
DBG("RIL_APPSTATE_ILLEGAL => RIL_APPSTATE_READY");
|
||||
app_state = RIL_APPSTATE_READY;
|
||||
}
|
||||
|
||||
grilio_parser_get_int32(rilp, &perso_substate);
|
||||
app->aid = grilio_parser_get_utf8(rilp);
|
||||
app->label = grilio_parser_get_utf8(rilp);
|
||||
|
||||
if (grilio_parser_get_int32(rilp, &pin_replaced) &&
|
||||
grilio_parser_get_int32(rilp, &pin1_state) &&
|
||||
grilio_parser_get_int32(rilp, &pin2_state)) {
|
||||
|
||||
app->app_type = app_type;
|
||||
app->app_state = app_state;
|
||||
app->perso_substate = perso_substate;
|
||||
app->pin_replaced = pin_replaced;
|
||||
app->pin1_state = pin1_state;
|
||||
app->pin2_state = pin2_state;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static struct ril_sim_card_status *ril_sim_card_status_parse(const void *data,
|
||||
guint len)
|
||||
{
|
||||
GRilIoParser rilp;
|
||||
gint32 card_state, pin_state, gsm_umts_index, cdma_index;
|
||||
gint32 ims_index, num_apps;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
|
||||
if (!grilio_parser_get_int32(&rilp, &card_state) ||
|
||||
!grilio_parser_get_int32(&rilp, &pin_state) ||
|
||||
!grilio_parser_get_int32(&rilp, &gsm_umts_index) ||
|
||||
!grilio_parser_get_int32(&rilp, &cdma_index) ||
|
||||
!grilio_parser_get_int32(&rilp, &ims_index) ||
|
||||
!grilio_parser_get_int32(&rilp, &num_apps)) {
|
||||
ofono_error("Failed to parse SIM card status request");
|
||||
return NULL;
|
||||
} else if (num_apps < 0 || num_apps > RIL_CARD_MAX_APPS) {
|
||||
ofono_error("Invalid SIM app count %d", num_apps);
|
||||
return NULL;
|
||||
} else {
|
||||
int i;
|
||||
struct ril_sim_card_status *status =
|
||||
g_new0(struct ril_sim_card_status, 1);
|
||||
|
||||
DBG("card_state=%d, universal_pin_state=%d, gsm_umts_index=%d, "
|
||||
"cdma_index=%d, ims_index=%d, num_apps=%d",
|
||||
card_state, pin_state, gsm_umts_index, cdma_index,
|
||||
ims_index, num_apps);
|
||||
|
||||
status->card_state = card_state;
|
||||
status->pin_state = pin_state;
|
||||
status->gsm_umts_index = gsm_umts_index;
|
||||
status->cdma_index = cdma_index;
|
||||
status->ims_index = ims_index;
|
||||
status->num_apps = num_apps;
|
||||
|
||||
if (num_apps > 0) {
|
||||
status->apps =
|
||||
g_new0(struct ril_sim_card_app, num_apps);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_apps; i++) {
|
||||
struct ril_sim_card_app *app = status->apps + i;
|
||||
|
||||
if (ril_sim_card_app_parse(&rilp, app)) {
|
||||
DBG("app[%d]: type=%d, state=%d, "
|
||||
"perso_substate=%d, aid_ptr=%s, "
|
||||
"label=%s, pin1_replaced=%d, pin1=%d, "
|
||||
"pin2=%d", i, app->app_type,
|
||||
app->app_state, app->perso_substate,
|
||||
app->aid, app->label,
|
||||
app->pin_replaced, app->pin1_state,
|
||||
app->pin2_state);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == num_apps) {
|
||||
GASSERT(grilio_parser_at_end(&rilp));
|
||||
return status;
|
||||
} else {
|
||||
ril_sim_card_status_free(status);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_sim_card_status_cb(GRilIoChannel *io, int ril_status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_sim_card *self = RIL_SIMCARD(user_data);
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
GASSERT(priv->status_req_id);
|
||||
priv->status_req_id = 0;
|
||||
|
||||
if (ril_status == RIL_E_SUCCESS) {
|
||||
struct ril_sim_card_status *status =
|
||||
ril_sim_card_status_parse(data, len);
|
||||
|
||||
if (status) {
|
||||
ril_sim_card_update_status(self, status);
|
||||
}
|
||||
}
|
||||
|
||||
ril_sim_card_tx_check(self);
|
||||
}
|
||||
|
||||
void ril_sim_card_reset(struct ril_sim_card *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
struct ril_sim_card_status *status =
|
||||
g_new0(struct ril_sim_card_status, 1);
|
||||
|
||||
/* Simulate removal and re-submit the SIM status query */
|
||||
status->card_state = RIL_CARDSTATE_ABSENT;
|
||||
status->gsm_umts_index = -1;
|
||||
status->cdma_index = -1;
|
||||
status->ims_index = -1;
|
||||
ril_sim_card_update_status(self, status);
|
||||
ril_sim_card_request_status(self);
|
||||
}
|
||||
}
|
||||
|
||||
void ril_sim_card_request_status(struct ril_sim_card *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
if (priv->status_req_id) {
|
||||
/* Retry right away, don't wait for retry
|
||||
* timeout to expire */
|
||||
grilio_channel_retry_request(priv->io,
|
||||
priv->status_req_id);
|
||||
} else {
|
||||
GRilIoRequest* req = grilio_request_new();
|
||||
|
||||
/* Start the transaction to not allow any other
|
||||
* requests to interfere with SIM status query */
|
||||
ril_sim_card_tx_start(self);
|
||||
grilio_request_set_retry(req, RIL_RETRY_SECS*1000, -1);
|
||||
priv->status_req_id =
|
||||
grilio_queue_send_request_full(priv->q,
|
||||
req, RIL_REQUEST_GET_SIM_STATUS,
|
||||
ril_sim_card_status_cb, NULL, self);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_sim_card_update_sim_io_active(struct ril_sim_card *self)
|
||||
{
|
||||
/* SIM I/O is considered active for certain period of time after
|
||||
* the last request has completed. That's because SIM_IO requests
|
||||
* are usually submitted in large quantities and quick succession.
|
||||
* Some RILs don't like being bothered while they are doing SIM I/O
|
||||
* and some time after that too. That sucks but what else can we
|
||||
* do about it? */
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
const gboolean active = priv->sim_io_idle_id ||
|
||||
g_hash_table_size(priv->sim_io_pending);
|
||||
|
||||
if (self->sim_io_active != active) {
|
||||
self->sim_io_active = active;
|
||||
DBG("SIM I/O for slot %u is %sactive", self->slot,
|
||||
active ? "" : "in");
|
||||
g_signal_emit(self, ril_sim_card_signals
|
||||
[SIGNAL_SIM_IO_ACTIVE_CHANGED], 0);
|
||||
}
|
||||
}
|
||||
|
||||
void ril_sim_card_sim_io_started(struct ril_sim_card *self, guint id)
|
||||
{
|
||||
if (G_LIKELY(self) && G_LIKELY(id)) {
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
gpointer key = GINT_TO_POINTER(id);
|
||||
|
||||
g_hash_table_insert(priv->sim_io_pending, key, key);
|
||||
if (priv->sim_io_idle_id) {
|
||||
g_source_remove(priv->sim_io_idle_id);
|
||||
priv->sim_io_idle_id = 0;
|
||||
priv->sim_io_idle_count = 0;
|
||||
}
|
||||
ril_sim_card_update_sim_io_active(self);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean ril_sim_card_sim_io_idle_cb(gpointer user_data)
|
||||
{
|
||||
struct ril_sim_card *self = RIL_SIMCARD(user_data);
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
if (++(priv->sim_io_idle_count) >= SIM_IO_IDLE_LOOPS) {
|
||||
priv->sim_io_idle_id = 0;
|
||||
priv->sim_io_idle_count = 0;
|
||||
ril_sim_card_update_sim_io_active(self);
|
||||
return G_SOURCE_REMOVE;
|
||||
} else {
|
||||
return G_SOURCE_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
void ril_sim_card_sim_io_finished(struct ril_sim_card *self, guint id)
|
||||
{
|
||||
if (G_LIKELY(self) && G_LIKELY(id)) {
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
gpointer key = GINT_TO_POINTER(id);
|
||||
|
||||
if (g_hash_table_remove(priv->sim_io_pending, key) &&
|
||||
!g_hash_table_size(priv->sim_io_pending)) {
|
||||
/* Reset the idle loop count */
|
||||
if (priv->sim_io_idle_id) {
|
||||
g_source_remove(priv->sim_io_idle_id);
|
||||
priv->sim_io_idle_count = 0;
|
||||
}
|
||||
priv->sim_io_idle_id =
|
||||
g_idle_add(ril_sim_card_sim_io_idle_cb, self);
|
||||
}
|
||||
ril_sim_card_update_sim_io_active(self);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_sim_card_status_changed(GRilIoChannel *io, guint code,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_sim_card *self = RIL_SIMCARD(user_data);
|
||||
|
||||
ril_sim_card_request_status(self);
|
||||
}
|
||||
|
||||
struct ril_sim_card *ril_sim_card_new(GRilIoChannel *io, guint slot, int flags)
|
||||
{
|
||||
struct ril_sim_card *self = g_object_new(RIL_SIMCARD_TYPE, NULL);
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
/*
|
||||
* We need to know the RIL version (for UICC subscription hack),
|
||||
* so we must be connected. The caller is supposed to make sure
|
||||
* that we get connected first.
|
||||
*/
|
||||
DBG("%u", slot);
|
||||
GASSERT(io->connected);
|
||||
|
||||
self->slot = slot;
|
||||
priv->io = grilio_channel_ref(io);
|
||||
priv->q = grilio_queue_new(io);
|
||||
priv->flags = flags;
|
||||
|
||||
priv->event_id[EVENT_SIM_STATUS_CHANGED] =
|
||||
grilio_channel_add_unsol_event_handler(priv->io,
|
||||
ril_sim_card_status_changed,
|
||||
RIL_UNSOL_RESPONSE_SIM_STATUS_CHANGED, self);
|
||||
priv->event_id[EVENT_UICC_SUBSCRIPTION_STATUS_CHANGED] =
|
||||
grilio_channel_add_unsol_event_handler(priv->io,
|
||||
ril_sim_card_status_changed,
|
||||
RIL_UNSOL_UICC_SUBSCRIPTION_STATUS_CHANGED, self);
|
||||
ril_sim_card_request_status(self);
|
||||
return self;
|
||||
}
|
||||
|
||||
struct ril_sim_card *ril_sim_card_ref(struct ril_sim_card *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
g_object_ref(RIL_SIMCARD(self));
|
||||
return self;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ril_sim_card_unref(struct ril_sim_card *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
g_object_unref(RIL_SIMCARD(self));
|
||||
}
|
||||
}
|
||||
|
||||
gboolean ril_sim_card_ready(struct ril_sim_card *self)
|
||||
{
|
||||
return self && self->app &&
|
||||
((self->app->app_state == RIL_APPSTATE_READY) ||
|
||||
(self->app->app_state == RIL_APPSTATE_SUBSCRIPTION_PERSO &&
|
||||
self->app->perso_substate == RIL_PERSOSUBSTATE_READY));
|
||||
}
|
||||
|
||||
gulong ril_sim_card_add_status_received_handler(struct ril_sim_card *self,
|
||||
ril_sim_card_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_STATUS_RECEIVED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong ril_sim_card_add_status_changed_handler(struct ril_sim_card *self,
|
||||
ril_sim_card_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_STATUS_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong ril_sim_card_add_state_changed_handler(struct ril_sim_card *self,
|
||||
ril_sim_card_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_STATE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong ril_sim_card_add_app_changed_handler(struct ril_sim_card *self,
|
||||
ril_sim_card_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_APP_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong ril_sim_card_add_sim_io_active_changed_handler(struct ril_sim_card *self,
|
||||
ril_sim_card_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_SIM_IO_ACTIVE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
void ril_sim_card_remove_handler(struct ril_sim_card *self, gulong id)
|
||||
{
|
||||
if (G_LIKELY(self) && G_LIKELY(id)) {
|
||||
g_signal_handler_disconnect(self, id);
|
||||
}
|
||||
}
|
||||
|
||||
void ril_sim_card_remove_handlers(struct ril_sim_card *self, gulong *ids, int n)
|
||||
{
|
||||
gutil_disconnect_handlers(self, ids, n);
|
||||
}
|
||||
|
||||
static void ril_sim_card_init(struct ril_sim_card *self)
|
||||
{
|
||||
struct ril_sim_card_priv *priv = G_TYPE_INSTANCE_GET_PRIVATE(self,
|
||||
RIL_SIMCARD_TYPE, struct ril_sim_card_priv);
|
||||
|
||||
self->priv = priv;
|
||||
priv->sim_io_pending = g_hash_table_new(g_direct_hash, g_direct_equal);
|
||||
}
|
||||
|
||||
static void ril_sim_card_dispose(GObject *object)
|
||||
{
|
||||
struct ril_sim_card *self = RIL_SIMCARD(object);
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
grilio_channel_remove_handlers(priv->io, priv->event_id, EVENT_COUNT);
|
||||
grilio_queue_cancel_all(priv->q, TRUE);
|
||||
G_OBJECT_CLASS(ril_sim_card_parent_class)->dispose(object);
|
||||
}
|
||||
|
||||
static void ril_sim_card_finalize(GObject *object)
|
||||
{
|
||||
struct ril_sim_card *self = RIL_SIMCARD(object);
|
||||
struct ril_sim_card_priv *priv = self->priv;
|
||||
|
||||
if (priv->sim_io_idle_id) {
|
||||
g_source_remove(priv->sim_io_idle_id);
|
||||
}
|
||||
if (priv->sub_start_timer) {
|
||||
g_source_remove(priv->sub_start_timer);
|
||||
}
|
||||
g_hash_table_destroy(priv->sim_io_pending);
|
||||
grilio_channel_unref(priv->io);
|
||||
grilio_queue_unref(priv->q);
|
||||
ril_sim_card_status_free(self->status);
|
||||
G_OBJECT_CLASS(ril_sim_card_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void ril_sim_card_class_init(RilSimCardClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
|
||||
object_class->dispose = ril_sim_card_dispose;
|
||||
object_class->finalize = ril_sim_card_finalize;
|
||||
g_type_class_add_private(klass, sizeof(struct ril_sim_card_priv));
|
||||
NEW_SIGNAL_(klass,STATUS_RECEIVED);
|
||||
NEW_SIGNAL(klass,STATUS);
|
||||
NEW_SIGNAL(klass,STATE);
|
||||
NEW_SIGNAL(klass,APP);
|
||||
NEW_SIGNAL(klass,SIM_IO_ACTIVE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_SIM_CARD_H
|
||||
#define RIL_SIM_CARD_H
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
struct ril_sim_card_app {
|
||||
enum ril_app_type app_type;
|
||||
enum ril_app_state app_state;
|
||||
enum ril_perso_substate perso_substate;
|
||||
char *aid;
|
||||
char *label;
|
||||
guint pin_replaced;
|
||||
enum ril_pin_state pin1_state;
|
||||
enum ril_pin_state pin2_state;
|
||||
};
|
||||
|
||||
struct ril_sim_card_status {
|
||||
enum ril_card_state card_state;
|
||||
enum ril_pin_state pin_state;
|
||||
int gsm_umts_index;
|
||||
int cdma_index;
|
||||
int ims_index;
|
||||
int num_apps;
|
||||
struct ril_sim_card_app *apps;
|
||||
};
|
||||
|
||||
struct ril_sim_card {
|
||||
GObject object;
|
||||
struct ril_sim_card_priv *priv;
|
||||
struct ril_sim_card_status *status;
|
||||
const struct ril_sim_card_app *app;
|
||||
gboolean sim_io_active;
|
||||
guint slot;
|
||||
};
|
||||
|
||||
typedef void (*ril_sim_card_cb_t)(struct ril_sim_card *sc, void *arg);
|
||||
|
||||
/* Flags for ril_sim_card_new */
|
||||
#define RIL_SIM_CARD_V9_UICC_SUBSCRIPTION_WORKAROUND (0x01)
|
||||
|
||||
struct ril_sim_card *ril_sim_card_new(GRilIoChannel *io, guint slot, int flags);
|
||||
struct ril_sim_card *ril_sim_card_ref(struct ril_sim_card *sc);
|
||||
void ril_sim_card_unref(struct ril_sim_card *sc);
|
||||
void ril_sim_card_reset(struct ril_sim_card *sc);
|
||||
void ril_sim_card_request_status(struct ril_sim_card *sc);
|
||||
void ril_sim_card_sim_io_started(struct ril_sim_card *sc, guint id);
|
||||
void ril_sim_card_sim_io_finished(struct ril_sim_card *sc, guint id);
|
||||
gboolean ril_sim_card_ready(struct ril_sim_card *sc);
|
||||
gulong ril_sim_card_add_status_received_handler(struct ril_sim_card *sc,
|
||||
ril_sim_card_cb_t cb, void *arg);
|
||||
gulong ril_sim_card_add_status_changed_handler(struct ril_sim_card *sc,
|
||||
ril_sim_card_cb_t cb, void *arg);
|
||||
gulong ril_sim_card_add_state_changed_handler(struct ril_sim_card *sc,
|
||||
ril_sim_card_cb_t cb, void *arg);
|
||||
gulong ril_sim_card_add_app_changed_handler(struct ril_sim_card *sc,
|
||||
ril_sim_card_cb_t cb, void *arg);
|
||||
gulong ril_sim_card_add_sim_io_active_changed_handler(struct ril_sim_card *sc,
|
||||
ril_sim_card_cb_t cb, void *arg);
|
||||
void ril_sim_card_remove_handler(struct ril_sim_card *sc, gulong id);
|
||||
void ril_sim_card_remove_handlers(struct ril_sim_card *sc, gulong *ids, int n);
|
||||
|
||||
/* Inline wrappers */
|
||||
static inline enum ril_app_type ril_sim_card_app_type(struct ril_sim_card *sc)
|
||||
{ return (sc && sc->app) ? sc->app->app_type : RIL_APPTYPE_UNKNOWN; }
|
||||
static inline const char *ril_sim_card_app_aid(struct ril_sim_card *sc)
|
||||
{ return (sc && sc->app) ? sc->app->aid : NULL; }
|
||||
|
||||
#define ril_sim_card_remove_all_handlers(net, ids) \
|
||||
ril_sim_card_remove_handlers(net, ids, G_N_ELEMENTS(ids))
|
||||
|
||||
#endif /* RIL_SIM_CARD_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_sim_settings.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "sailfish_watch.h"
|
||||
|
||||
#include <gutil_misc.h>
|
||||
|
||||
#define RIL_PREF_MODE_DEFAULT(self) (\
|
||||
((self)->techs & OFONO_RADIO_ACCESS_MODE_LTE) ? \
|
||||
OFONO_RADIO_ACCESS_MODE_LTE : \
|
||||
((self)->techs & OFONO_RADIO_ACCESS_MODE_UMTS) ? \
|
||||
OFONO_RADIO_ACCESS_MODE_UMTS : \
|
||||
OFONO_RADIO_ACCESS_MODE_GSM)
|
||||
|
||||
typedef GObjectClass RilSimSettingsClass;
|
||||
typedef struct ril_sim_settings RilSimSettings;
|
||||
|
||||
enum sailfish_watch_events {
|
||||
WATCH_EVENT_IMSI,
|
||||
WATCH_EVENT_COUNT
|
||||
};
|
||||
|
||||
struct ril_sim_settings_priv {
|
||||
gulong watch_event_id[WATCH_EVENT_COUNT];
|
||||
struct sailfish_watch *watch;
|
||||
char *imsi;
|
||||
};
|
||||
|
||||
enum ril_sim_settings_signal {
|
||||
SIGNAL_IMSI_CHANGED,
|
||||
SIGNAL_PREF_MODE_CHANGED,
|
||||
SIGNAL_COUNT
|
||||
};
|
||||
|
||||
#define SIGNAL_IMSI_CHANGED_NAME "ril-sim-settings-imsi-changed"
|
||||
#define SIGNAL_PREF_MODE_CHANGED_NAME "ril-sim-settings-pref-mode-changed"
|
||||
|
||||
static guint ril_sim_settings_signals[SIGNAL_COUNT] = { 0 };
|
||||
|
||||
G_DEFINE_TYPE(RilSimSettings, ril_sim_settings, G_TYPE_OBJECT)
|
||||
#define RIL_SIM_SETTINGS_TYPE (ril_sim_settings_get_type())
|
||||
#define RIL_SIM_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
|
||||
RIL_SIM_SETTINGS_TYPE, RilSimSettings))
|
||||
|
||||
#define NEW_SIGNAL(klass,name) \
|
||||
ril_sim_settings_signals[SIGNAL_##name##_CHANGED] = \
|
||||
g_signal_new(SIGNAL_##name##_CHANGED_NAME, \
|
||||
G_OBJECT_CLASS_TYPE(klass), G_SIGNAL_RUN_FIRST, \
|
||||
0, NULL, NULL, NULL, G_TYPE_NONE, 0)
|
||||
|
||||
/* Skip the leading slash from the modem path: */
|
||||
#define DBG_(obj,fmt,args...) DBG("%s " fmt, (obj)->path+1, ##args)
|
||||
|
||||
static void ril_sim_settings_signal_emit(struct ril_sim_settings *self,
|
||||
enum ril_sim_settings_signal id)
|
||||
{
|
||||
g_signal_emit(self, ril_sim_settings_signals[id], 0);
|
||||
}
|
||||
|
||||
void ril_sim_settings_set_pref_mode(struct ril_sim_settings *self,
|
||||
enum ofono_radio_access_mode mode)
|
||||
{
|
||||
if (G_LIKELY(self) && self->pref_mode != mode) {
|
||||
self->pref_mode = mode;
|
||||
ril_sim_settings_signal_emit(self, SIGNAL_PREF_MODE_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_sim_settings_imsi_changed(struct sailfish_watch *watch,
|
||||
void *user_data)
|
||||
{
|
||||
struct ril_sim_settings *self = RIL_SIM_SETTINGS(user_data);
|
||||
struct ril_sim_settings_priv *priv = self->priv;
|
||||
|
||||
if (g_strcmp0(priv->imsi, watch->imsi)) {
|
||||
g_free(priv->imsi);
|
||||
self->imsi = priv->imsi = g_strdup(watch->imsi);
|
||||
ril_sim_settings_signal_emit(self, SIGNAL_IMSI_CHANGED);
|
||||
}
|
||||
}
|
||||
|
||||
struct ril_sim_settings *ril_sim_settings_new(const char *path,
|
||||
enum ofono_radio_access_mode techs)
|
||||
{
|
||||
struct ril_sim_settings *self = NULL;
|
||||
|
||||
if (G_LIKELY(path)) {
|
||||
struct ril_sim_settings_priv *priv;
|
||||
|
||||
self = g_object_new(RIL_SIM_SETTINGS_TYPE, NULL);
|
||||
priv = self->priv;
|
||||
self->techs = techs;
|
||||
self->pref_mode = RIL_PREF_MODE_DEFAULT(self);
|
||||
priv->watch = sailfish_watch_new(path);
|
||||
priv->watch_event_id[WATCH_EVENT_IMSI] =
|
||||
sailfish_watch_add_imsi_changed_handler(priv->watch,
|
||||
ril_sim_settings_imsi_changed, self);
|
||||
self->imsi = priv->imsi = g_strdup(priv->watch->imsi);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
struct ril_sim_settings *ril_sim_settings_ref(struct ril_sim_settings *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
g_object_ref(RIL_SIM_SETTINGS(self));
|
||||
return self;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ril_sim_settings_unref(struct ril_sim_settings *self)
|
||||
{
|
||||
if (G_LIKELY(self)) {
|
||||
g_object_unref(RIL_SIM_SETTINGS(self));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gulong ril_sim_settings_add_imsi_changed_handler(struct ril_sim_settings *self,
|
||||
ril_sim_settings_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_IMSI_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
gulong ril_sim_settings_add_pref_mode_changed_handler(
|
||||
struct ril_sim_settings *self,
|
||||
ril_sim_settings_cb_t cb, void *arg)
|
||||
{
|
||||
return (G_LIKELY(self) && G_LIKELY(cb)) ? g_signal_connect(self,
|
||||
SIGNAL_PREF_MODE_CHANGED_NAME, G_CALLBACK(cb), arg) : 0;
|
||||
}
|
||||
|
||||
void ril_sim_settings_remove_handler(struct ril_sim_settings *self, gulong id)
|
||||
{
|
||||
if (G_LIKELY(self) && G_LIKELY(id)) {
|
||||
g_signal_handler_disconnect(self, id);
|
||||
}
|
||||
}
|
||||
|
||||
void ril_sim_settings_remove_handlers(struct ril_sim_settings *self,
|
||||
gulong *ids, int count)
|
||||
{
|
||||
gutil_disconnect_handlers(self, ids, count);
|
||||
}
|
||||
|
||||
static void ril_sim_settings_init(struct ril_sim_settings *self)
|
||||
{
|
||||
self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, RIL_SIM_SETTINGS_TYPE,
|
||||
struct ril_sim_settings_priv);
|
||||
}
|
||||
|
||||
static void ril_sim_settings_finalize(GObject *object)
|
||||
{
|
||||
struct ril_sim_settings *self = RIL_SIM_SETTINGS(object);
|
||||
struct ril_sim_settings_priv *priv = self->priv;
|
||||
|
||||
sailfish_watch_remove_all_handlers(priv->watch, priv->watch_event_id);
|
||||
sailfish_watch_unref(priv->watch);
|
||||
g_free(priv->imsi);
|
||||
G_OBJECT_CLASS(ril_sim_settings_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void ril_sim_settings_class_init(RilSimSettingsClass *klass)
|
||||
{
|
||||
G_OBJECT_CLASS(klass)->finalize = ril_sim_settings_finalize;
|
||||
g_type_class_add_private(klass, sizeof(struct ril_sim_settings_priv));
|
||||
NEW_SIGNAL(klass, IMSI);
|
||||
NEW_SIGNAL(klass, PREF_MODE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_SIM_SETTINGS_H
|
||||
#define RIL_SIM_SETTINGS_H
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
struct ril_sim_settings_priv;
|
||||
|
||||
struct ril_sim_settings {
|
||||
GObject object;
|
||||
struct ril_sim_settings_priv *priv;
|
||||
const char *imsi;
|
||||
enum ofono_radio_access_mode techs;
|
||||
enum ofono_radio_access_mode pref_mode;
|
||||
};
|
||||
|
||||
typedef void (*ril_sim_settings_cb_t)(struct ril_sim_settings *s, void *arg);
|
||||
|
||||
struct ril_sim_settings *ril_sim_settings_new(const char *path,
|
||||
enum ofono_radio_access_mode techs);
|
||||
struct ril_sim_settings *ril_sim_settings_ref(struct ril_sim_settings *s);
|
||||
void ril_sim_settings_unref(struct ril_sim_settings *s);
|
||||
void ril_sim_settings_set_pref_mode(struct ril_sim_settings *s,
|
||||
enum ofono_radio_access_mode mode);
|
||||
gulong ril_sim_settings_add_imsi_changed_handler(struct ril_sim_settings *s,
|
||||
ril_sim_settings_cb_t cb, void *arg);
|
||||
gulong ril_sim_settings_add_pref_mode_changed_handler(struct ril_sim_settings *s,
|
||||
ril_sim_settings_cb_t cb, void *arg);
|
||||
void ril_sim_settings_remove_handler(struct ril_sim_settings *s, gulong id);
|
||||
void ril_sim_settings_remove_handlers(struct ril_sim_settings *s, gulong *ids,
|
||||
int count);
|
||||
|
||||
#endif /* RIL_SIM_SETTINGS_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,516 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "smsutil.h"
|
||||
#include "util.h"
|
||||
#include "simutil.h"
|
||||
|
||||
#define RIL_SMS_ACK_RETRY_MS 1000
|
||||
#define RIL_SMS_ACK_RETRY_COUNT 10
|
||||
|
||||
#define SIM_EFSMS_FILEID 0x6F3C
|
||||
#define EFSMS_LENGTH 176
|
||||
|
||||
#define TYPE_LOCAL 129
|
||||
#define TYPE_INTERNATIONAL 145
|
||||
|
||||
static unsigned char sim_path[4] = {0x3F, 0x00, 0x7F, 0x10};
|
||||
|
||||
enum ril_sms_events {
|
||||
SMS_EVENT_NEW_SMS,
|
||||
SMS_EVENT_NEW_STATUS_REPORT,
|
||||
SMS_EVENT_NEW_SMS_ON_SIM,
|
||||
SMS_EVENT_COUNT
|
||||
};
|
||||
|
||||
struct ril_sms {
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
struct ril_modem *modem;
|
||||
struct ofono_sms *sms;
|
||||
struct ofono_sim_context *sim_context;
|
||||
gulong event_id[SMS_EVENT_COUNT];
|
||||
guint timer_id;
|
||||
};
|
||||
|
||||
struct ril_sms_cbd {
|
||||
union _ofono_sms_cb {
|
||||
ofono_sms_sca_set_cb_t sca_set;
|
||||
ofono_sms_sca_query_cb_t sca_query;
|
||||
ofono_sms_submit_cb_t submit;
|
||||
gpointer ptr;
|
||||
} cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
struct ril_sms_on_sim_req {
|
||||
struct ril_sms *sd;
|
||||
int record;
|
||||
};
|
||||
|
||||
#define ril_sms_cbd_free g_free
|
||||
#define ril_sms_on_sim_req_free g_free
|
||||
|
||||
static inline struct ril_sms *ril_sms_get_data(struct ofono_sms *sms)
|
||||
{
|
||||
return ofono_sms_get_data(sms);
|
||||
}
|
||||
|
||||
struct ril_sms_cbd *ril_sms_cbd_new(struct ril_sms *sd, void *cb, void *data)
|
||||
{
|
||||
struct ril_sms_cbd *cbd = g_new0(struct ril_sms_cbd, 1);
|
||||
|
||||
cbd->cb.ptr = cb;
|
||||
cbd->data = data;
|
||||
return cbd;
|
||||
}
|
||||
|
||||
struct ril_sms_on_sim_req *ril_sms_on_sim_req_new(struct ril_sms *sd, int rec)
|
||||
{
|
||||
struct ril_sms_on_sim_req *cbd = g_new0(struct ril_sms_on_sim_req, 1);
|
||||
|
||||
cbd->sd = sd;
|
||||
cbd->record = rec;
|
||||
return cbd;
|
||||
}
|
||||
|
||||
static void ril_sms_sca_set_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_sms_cbd *cbd = user_data;
|
||||
ofono_sms_sca_set_cb_t cb = cbd->cb.sca_set;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
cb(ril_error_ok(&error), cbd->data);
|
||||
} else {
|
||||
ofono_error("csca setting failed");
|
||||
cb(ril_error_failure(&error), cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_sms_sca_set(struct ofono_sms *sms,
|
||||
const struct ofono_phone_number *sca,
|
||||
ofono_sms_sca_set_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_sms *sd = ril_sms_get_data(sms);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
char number[OFONO_MAX_PHONE_NUMBER_LENGTH + 4];
|
||||
|
||||
if (sca->type == TYPE_LOCAL) {
|
||||
snprintf(number, sizeof(number), "\"%s\"", sca->number);
|
||||
} else {
|
||||
snprintf(number, sizeof(number), "\"+%s\"", sca->number);
|
||||
}
|
||||
|
||||
DBG("Setting sca: %s", number);
|
||||
grilio_request_append_utf8(req, number);
|
||||
grilio_queue_send_request_full(sd->q, req,
|
||||
RIL_REQUEST_SET_SMSC_ADDRESS, ril_sms_sca_set_cb,
|
||||
ril_sms_cbd_free, ril_sms_cbd_new(sd, cb, data));
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_sms_sca_query_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_sms_cbd *cbd = user_data;
|
||||
ofono_sms_sca_query_cb_t cb = cbd->cb.sca_query;
|
||||
struct ofono_error error;
|
||||
GRilIoParser rilp;
|
||||
gchar *temp_buf;
|
||||
|
||||
if (status != RIL_E_SUCCESS) {
|
||||
ofono_error("csca query failed");
|
||||
cb(ril_error_failure(&error), NULL, cbd->data);
|
||||
return;
|
||||
}
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
temp_buf = grilio_parser_get_utf8(&rilp);
|
||||
|
||||
if (temp_buf) {
|
||||
/* RIL gives address in quotes */
|
||||
gchar *number = strtok(temp_buf, "\"");
|
||||
struct ofono_phone_number sca;
|
||||
|
||||
strncpy(sca.number, number, OFONO_MAX_PHONE_NUMBER_LENGTH);
|
||||
sca.number[OFONO_MAX_PHONE_NUMBER_LENGTH] = '\0';
|
||||
if (sca.number[0] == '+') {
|
||||
number = number + 1;
|
||||
sca.type = TYPE_INTERNATIONAL;
|
||||
} else {
|
||||
sca.type = TYPE_LOCAL;
|
||||
}
|
||||
|
||||
DBG("csca_query_cb: %s, %d", sca.number, sca.type);
|
||||
cb(ril_error_ok(&error), &sca, cbd->data);
|
||||
g_free(temp_buf);
|
||||
} else {
|
||||
ofono_error("return value invalid");
|
||||
cb(ril_error_failure(&error), NULL, cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_sms_sca_query(struct ofono_sms *sms,
|
||||
ofono_sms_sca_query_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_sms *sd = ril_sms_get_data(sms);
|
||||
|
||||
DBG("Sending csca_query");
|
||||
grilio_queue_send_request_full(sd->q, NULL,
|
||||
RIL_REQUEST_GET_SMSC_ADDRESS, ril_sms_sca_query_cb,
|
||||
ril_sms_cbd_free, ril_sms_cbd_new(sd, cb, data));
|
||||
}
|
||||
|
||||
static void ril_sms_submit_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_sms_cbd *cbd = user_data;
|
||||
ofono_sms_submit_cb_t cb = cbd->cb.submit;
|
||||
struct ofono_error error;
|
||||
int mr = 0;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
GRilIoParser rilp;
|
||||
int err = -1;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
|
||||
/* TP-Message-Reference for GSM/
|
||||
* BearerData MessageId for CDMA
|
||||
*/
|
||||
grilio_parser_get_int32(&rilp, &mr);
|
||||
grilio_parser_skip_string(&rilp);
|
||||
|
||||
/* error: 3GPP 27.005, 3.2.5, -1 if unknown or not applicable */
|
||||
grilio_parser_get_int32(&rilp, &err);
|
||||
DBG("sms msg ref: %d, error: %d", mr, err);
|
||||
ril_error_init_ok(&error);
|
||||
} else if (status == RIL_E_GENERIC_FAILURE) {
|
||||
ofono_info("not allowed by MO SMS control, do not retry");
|
||||
error.type = OFONO_ERROR_TYPE_CMS;
|
||||
error.error = 500;
|
||||
} else {
|
||||
ofono_error("sms sending failed, retry");
|
||||
ril_error_init_failure(&error);
|
||||
}
|
||||
|
||||
cb(&error, mr, cbd->data);
|
||||
}
|
||||
|
||||
static void ril_sms_submit(struct ofono_sms *sms, const unsigned char *pdu,
|
||||
int pdu_len, int tpdu_len, int mms,
|
||||
ofono_sms_submit_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_sms *sd = ril_sms_get_data(sms);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
int smsc_len;
|
||||
char *tpdu;
|
||||
|
||||
DBG("pdu_len: %d, tpdu_len: %d mms: %d", pdu_len, tpdu_len, mms);
|
||||
|
||||
grilio_request_append_int32(req, 2); /* Number of strings */
|
||||
|
||||
/* SMSC address:
|
||||
*
|
||||
* smsc_len == 1, then zero-length SMSC was spec'd
|
||||
* RILD expects a NULL string in this case instead
|
||||
* of a zero-length string.
|
||||
*/
|
||||
smsc_len = pdu_len - tpdu_len;
|
||||
if (smsc_len > 1) {
|
||||
/* TODO: encode SMSC & write to parcel */
|
||||
DBG("SMSC address specified (smsc_len %d); NOT-IMPLEMENTED",
|
||||
smsc_len);
|
||||
}
|
||||
|
||||
grilio_request_append_utf8(req, NULL); /* default SMSC address */
|
||||
|
||||
/* TPDU:
|
||||
*
|
||||
* 'pdu' is a raw hexadecimal string
|
||||
* encode_hex() turns it into an ASCII/hex UTF8 buffer
|
||||
* grilio_request_append_utf8() encodes utf8 -> utf16
|
||||
*/
|
||||
tpdu = encode_hex(pdu + smsc_len, tpdu_len, 0);
|
||||
grilio_request_append_utf8(req, tpdu);
|
||||
|
||||
DBG("%s", tpdu);
|
||||
grilio_queue_send_request_full(sd->q, req,
|
||||
mms ? RIL_REQUEST_SEND_SMS_EXPECT_MORE : RIL_REQUEST_SEND_SMS,
|
||||
ril_sms_submit_cb, ril_sms_cbd_free,
|
||||
ril_sms_cbd_new(sd, cb, data));
|
||||
grilio_request_unref(req);
|
||||
g_free(tpdu);
|
||||
}
|
||||
|
||||
static void ril_ack_delivery_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
if (status != RIL_E_SUCCESS) {
|
||||
ofono_error("SMS acknowledgement failed: "
|
||||
"Further SMS reception is not guaranteed");
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_ack_delivery(struct ril_sms *sd, gboolean error)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_sized_new(12);
|
||||
const int code = (error ? 0 : 0xff);
|
||||
|
||||
DBG("(%d,%d)", error, code);
|
||||
grilio_request_append_int32(req, 2); /* Array size*/
|
||||
grilio_request_append_int32(req, error); /* Success (1)/Failure (0) */
|
||||
grilio_request_append_int32(req, code); /* error code */
|
||||
|
||||
/* ACK the incoming NEW_SMS */
|
||||
grilio_request_set_retry(req, RIL_SMS_ACK_RETRY_MS,
|
||||
RIL_SMS_ACK_RETRY_COUNT);
|
||||
grilio_queue_send_request_full(sd->q, req,
|
||||
RIL_REQUEST_SMS_ACKNOWLEDGE, ril_ack_delivery_cb, NULL, NULL);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_sms_notify(GRilIoChannel *io, guint ril_event,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_sms *sd = user_data;
|
||||
GRilIoParser rilp;
|
||||
char *ril_pdu;
|
||||
int ril_pdu_len;
|
||||
unsigned int smsc_len;
|
||||
long ril_buf_len;
|
||||
guchar *ril_data;
|
||||
|
||||
ril_pdu = NULL;
|
||||
ril_data = NULL;
|
||||
|
||||
DBG("event: %d; data_len: %d", ril_event, len);
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
ril_pdu = grilio_parser_get_utf8(&rilp);
|
||||
if (ril_pdu == NULL)
|
||||
goto error;
|
||||
|
||||
ril_pdu_len = strlen(ril_pdu);
|
||||
|
||||
DBG("ril_pdu_len is %d", ril_pdu_len);
|
||||
ril_data = decode_hex(ril_pdu, ril_pdu_len, &ril_buf_len, -1);
|
||||
if (ril_data == NULL)
|
||||
goto error;
|
||||
|
||||
/* The first octect in the pdu contains the SMSC address length
|
||||
* which is the X following octects it reads. We add 1 octet to
|
||||
* the read length to take into account this read octet in order
|
||||
* to calculate the proper tpdu length.
|
||||
*/
|
||||
smsc_len = ril_data[0] + 1;
|
||||
ofono_info("sms received, smsc_len is %d", smsc_len);
|
||||
DBG("(%s)", ril_pdu);
|
||||
|
||||
if (ril_event == RIL_UNSOL_RESPONSE_NEW_SMS) {
|
||||
/* Last parameter is 'tpdu_len' ( substract SMSC length ) */
|
||||
ofono_sms_deliver_notify(sd->sms, ril_data, ril_buf_len,
|
||||
ril_buf_len - smsc_len);
|
||||
} else {
|
||||
GASSERT(ril_event == RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT);
|
||||
ofono_sms_status_notify(sd->sms, ril_data, ril_buf_len,
|
||||
ril_buf_len - smsc_len);
|
||||
}
|
||||
|
||||
g_free(ril_pdu);
|
||||
g_free(ril_data);
|
||||
ril_ack_delivery(sd, TRUE);
|
||||
return;
|
||||
|
||||
error:
|
||||
g_free(ril_pdu);
|
||||
g_free(ril_data);
|
||||
ril_ack_delivery(sd, FALSE);
|
||||
ofono_error("Unable to parse NEW_SMS notification");
|
||||
}
|
||||
|
||||
static void ril_new_sms_on_sim_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
DBG("%d", status);
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
ofono_info("sms deleted from sim");
|
||||
} else {
|
||||
ofono_error("deleting sms from sim failed");
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_request_delete_sms_om_sim(struct ril_sms *sd, int record)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_sized_new(8);
|
||||
|
||||
DBG("Deleting record: %d", record);
|
||||
|
||||
grilio_request_append_int32(req, 1); /* Array length */
|
||||
grilio_request_append_int32(req, record);
|
||||
grilio_queue_send_request_full(sd->q, req,
|
||||
RIL_REQUEST_DELETE_SMS_ON_SIM,
|
||||
ril_new_sms_on_sim_cb, NULL, NULL);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_sms_on_sim_cb(int ok, int total_length, int record,
|
||||
const unsigned char *sdata, int length, void *userdata)
|
||||
{
|
||||
struct ril_sms_on_sim_req *cbd = userdata;
|
||||
struct ril_sms *sd = cbd->sd;
|
||||
|
||||
/*
|
||||
* It seems when reading EFsms RIL returns the whole record including
|
||||
* the first status byte therefore we ignore that as we are only
|
||||
* interested of the following pdu
|
||||
*/
|
||||
/* The first octect in the pdu contains the SMSC address length
|
||||
* which is the X following octects it reads. We add 1 octet to
|
||||
* the read length to take into account this read octet in order
|
||||
* to calculate the proper tpdu length.
|
||||
*/
|
||||
if (ok) {
|
||||
unsigned int smsc_len = sdata[1] + 1;
|
||||
ofono_sms_deliver_notify(sd->sms, sdata + 1, length - 1,
|
||||
length - smsc_len - 1);
|
||||
ril_request_delete_sms_om_sim(sd, cbd->record);
|
||||
} else {
|
||||
ofono_error("cannot read sms from sim");
|
||||
}
|
||||
|
||||
ril_sms_on_sim_req_free(cbd);
|
||||
}
|
||||
|
||||
static void ril_sms_on_sim(GRilIoChannel *io, guint ril_event,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_sms *sd = user_data;
|
||||
struct ofono_sim *sim = ril_modem_ofono_sim(sd->modem);
|
||||
int data_len = 0, rec = 0;
|
||||
GRilIoParser rilp;
|
||||
|
||||
ofono_info("new sms on sim");
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
if (sim &&
|
||||
grilio_parser_get_int32(&rilp, &data_len) && data_len > 0 &&
|
||||
grilio_parser_get_int32(&rilp, &rec)) {
|
||||
DBG("rec %d", rec);
|
||||
if (sd->sim_context) {
|
||||
ofono_sim_read_record(sd->sim_context,
|
||||
SIM_EFSMS_FILEID,
|
||||
OFONO_SIM_FILE_STRUCTURE_FIXED,
|
||||
rec, EFSMS_LENGTH,
|
||||
sim_path, sizeof(sim_path),
|
||||
ril_sms_on_sim_cb,
|
||||
ril_sms_on_sim_req_new(sd,rec));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean ril_sms_register(gpointer user_data)
|
||||
{
|
||||
struct ril_sms *sd = user_data;
|
||||
|
||||
DBG("");
|
||||
GASSERT(sd->timer_id);
|
||||
sd->timer_id = 0;
|
||||
ofono_sms_register(sd->sms);
|
||||
|
||||
/* Register event handlers */
|
||||
sd->event_id[SMS_EVENT_NEW_SMS] =
|
||||
grilio_channel_add_unsol_event_handler(sd->io, ril_sms_notify,
|
||||
RIL_UNSOL_RESPONSE_NEW_SMS, sd);
|
||||
sd->event_id[SMS_EVENT_NEW_STATUS_REPORT] =
|
||||
grilio_channel_add_unsol_event_handler(sd->io, ril_sms_notify,
|
||||
RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT, sd);
|
||||
sd->event_id[SMS_EVENT_NEW_SMS_ON_SIM] =
|
||||
grilio_channel_add_unsol_event_handler(sd->io, ril_sms_on_sim,
|
||||
RIL_UNSOL_RESPONSE_NEW_SMS_ON_SIM, sd);
|
||||
|
||||
/* Single-shot */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int ril_sms_probe(struct ofono_sms *sms, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ofono_sim *sim = ril_modem_ofono_sim(modem);
|
||||
struct ril_sms *sd = g_new0(struct ril_sms, 1);
|
||||
|
||||
sd->modem = modem;
|
||||
sd->sms = sms;
|
||||
sd->io = grilio_channel_ref(ril_modem_io(modem));
|
||||
sd->sim_context = ofono_sim_context_create(sim);
|
||||
sd->q = grilio_queue_new(sd->io);
|
||||
sd->timer_id = g_idle_add(ril_sms_register, sd);
|
||||
ofono_sms_set_data(sms, sd);
|
||||
|
||||
GASSERT(sd->sim_context);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_sms_remove(struct ofono_sms *sms)
|
||||
{
|
||||
unsigned int i;
|
||||
struct ril_sms *sd = ril_sms_get_data(sms);
|
||||
|
||||
DBG("");
|
||||
ofono_sms_set_data(sms, NULL);
|
||||
|
||||
if (sd->sim_context) {
|
||||
ofono_sim_context_free(sd->sim_context);
|
||||
}
|
||||
|
||||
for (i=0; i<G_N_ELEMENTS(sd->event_id); i++) {
|
||||
grilio_channel_remove_handler(sd->io, sd->event_id[i]);
|
||||
|
||||
}
|
||||
|
||||
if (sd->timer_id > 0) {
|
||||
g_source_remove(sd->timer_id);
|
||||
}
|
||||
|
||||
grilio_channel_unref(sd->io);
|
||||
grilio_queue_cancel_all(sd->q, FALSE);
|
||||
grilio_queue_unref(sd->q);
|
||||
g_free(sd);
|
||||
}
|
||||
|
||||
const struct ofono_sms_driver ril_sms_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_sms_probe,
|
||||
.remove = ril_sms_remove,
|
||||
.sca_query = ril_sms_sca_query,
|
||||
.sca_set = ril_sms_sca_set,
|
||||
.submit = ril_sms_submit,
|
||||
.bearer_query = NULL, /* FIXME: needs investigation. */
|
||||
.bearer_set = NULL
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,302 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2017 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#ifndef UI_LANG
|
||||
# define UI_LANG "/var/lib/environment/nemo/locale.conf"
|
||||
#endif
|
||||
|
||||
enum ril_stk_events {
|
||||
STK_EVENT_PROACTIVE_COMMAND,
|
||||
STK_EVENT_SESSION_END,
|
||||
STK_EVENT_NOTIFY,
|
||||
STK_EVENT_COUNT
|
||||
};
|
||||
|
||||
struct ril_stk {
|
||||
struct ofono_stk *stk;
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
gulong event_id[STK_EVENT_COUNT];
|
||||
};
|
||||
|
||||
struct ril_stk_cbd {
|
||||
union _ofono_stk_cb {
|
||||
ofono_stk_envelope_cb_t envelope;
|
||||
ofono_stk_generic_cb_t generic;
|
||||
gpointer ptr;
|
||||
} cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
#define ril_stk_cbd_free g_free
|
||||
|
||||
static inline struct ril_stk *ril_stk_get_data(struct ofono_stk *stk)
|
||||
{
|
||||
return ofono_stk_get_data(stk);
|
||||
}
|
||||
|
||||
struct ril_stk_cbd *ril_stk_cbd_new(void *cb, void *data)
|
||||
{
|
||||
struct ril_stk_cbd *cbd = g_new0(struct ril_stk_cbd, 1);
|
||||
|
||||
cbd->cb.ptr = cb;
|
||||
cbd->data = data;
|
||||
return cbd;
|
||||
}
|
||||
|
||||
static void ril_stk_envelope_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_stk_cbd *cbd = user_data;
|
||||
ofono_stk_envelope_cb_t cb = cbd->cb.envelope;
|
||||
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
DBG("%u bytes(s)", len);
|
||||
cb(ril_error_ok(&error), NULL, 0, cbd->data);
|
||||
} else {
|
||||
DBG("Envelope reply failure: %s", ril_error_to_string(status));
|
||||
cb(ril_error_failure(&error), NULL, 0, cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_stk_envelope(struct ofono_stk *stk, int length,
|
||||
const unsigned char *cmd, ofono_stk_envelope_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_stk *sd = ril_stk_get_data(stk);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
char *hex_envelope = encode_hex(cmd, length, 0);
|
||||
|
||||
DBG("%s", hex_envelope);
|
||||
grilio_request_append_utf8(req, hex_envelope);
|
||||
g_free(hex_envelope);
|
||||
grilio_queue_send_request_full(sd->q, req,
|
||||
RIL_REQUEST_STK_SEND_ENVELOPE_COMMAND,
|
||||
ril_stk_envelope_cb, ril_stk_cbd_free,
|
||||
ril_stk_cbd_new(cb, data));
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_stk_terminal_response_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_stk_cbd *cbd = user_data;
|
||||
ofono_stk_generic_cb_t cb = cbd->cb.generic;
|
||||
|
||||
DBG("");
|
||||
if (status == RIL_E_SUCCESS) {
|
||||
cb(ril_error_ok(&error), cbd->data);
|
||||
} else {
|
||||
ofono_error("Error in sending terminal response");
|
||||
cb(ril_error_failure(&error), cbd->data);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_stk_terminal_response(struct ofono_stk *stk, int length,
|
||||
const unsigned char *resp,
|
||||
ofono_stk_generic_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_stk *sd = ril_stk_get_data(stk);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
char *hex_tr = encode_hex(resp, length, 0);
|
||||
|
||||
DBG("rilmodem terminal response: %s", hex_tr);
|
||||
grilio_request_append_utf8(req, hex_tr);
|
||||
g_free(hex_tr);
|
||||
grilio_queue_send_request_full(sd->q, req,
|
||||
RIL_REQUEST_STK_SEND_TERMINAL_RESPONSE,
|
||||
ril_stk_terminal_response_cb,
|
||||
ril_stk_cbd_free, ril_stk_cbd_new(cb, data));
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_stk_user_confirmation(struct ofono_stk *stk,
|
||||
ofono_bool_t confirm)
|
||||
{
|
||||
struct ril_stk *sd = ril_stk_get_data(stk);
|
||||
GRilIoRequest *req = grilio_request_sized_new(8);
|
||||
|
||||
DBG("%d", confirm);
|
||||
grilio_request_append_int32(req, 1); /* size of array */
|
||||
grilio_request_append_int32(req, confirm); /* yes/no */
|
||||
|
||||
grilio_queue_send_request(sd->q, req,
|
||||
RIL_REQUEST_STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_stk_pcmd_notify(GRilIoChannel *io, guint code,
|
||||
const void *data, guint data_len, void *user_data)
|
||||
{
|
||||
struct ril_stk *sd = user_data;
|
||||
GRilIoParser rilp;
|
||||
char *pcmd;
|
||||
guchar *pdu;
|
||||
long len = 0;
|
||||
|
||||
GASSERT(code == RIL_UNSOL_STK_PROACTIVE_COMMAND);
|
||||
grilio_parser_init(&rilp, data, data_len);
|
||||
pcmd = grilio_parser_get_utf8(&rilp);
|
||||
DBG("pcmd: %s", pcmd);
|
||||
|
||||
pdu = decode_hex(pcmd, strlen(pcmd), &len, -1);
|
||||
g_free(pcmd);
|
||||
|
||||
ofono_stk_proactive_command_notify(sd->stk, len, pdu);
|
||||
g_free(pdu);
|
||||
}
|
||||
|
||||
static void ril_stk_event_notify(GRilIoChannel *io, guint code,
|
||||
const void *data, guint data_len, void *user_data)
|
||||
{
|
||||
struct ril_stk *sd = user_data;
|
||||
GRilIoParser rilp;
|
||||
char *pcmd = NULL;
|
||||
guchar *pdu = NULL;
|
||||
long len;
|
||||
|
||||
/* Proactive command has been handled by the modem. */
|
||||
GASSERT(code == RIL_UNSOL_STK_EVENT_NOTIFY);
|
||||
grilio_parser_init(&rilp, data, data_len);
|
||||
pcmd = grilio_parser_get_utf8(&rilp);
|
||||
DBG("pcmd: %s", pcmd);
|
||||
pdu = decode_hex(pcmd, strlen(pcmd), &len, -1);
|
||||
g_free(pcmd);
|
||||
|
||||
ofono_stk_proactive_command_handled_notify(sd->stk, len, pdu);
|
||||
g_free(pdu);
|
||||
}
|
||||
|
||||
static void ril_stk_session_end_notify(GRilIoChannel *io, guint code,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_stk *sd = user_data;
|
||||
|
||||
DBG("");
|
||||
GASSERT(code == RIL_UNSOL_STK_SESSION_END);
|
||||
ofono_stk_proactive_session_end_notify(sd->stk);
|
||||
}
|
||||
|
||||
static void ril_stk_agent_ready(struct ofono_stk *stk)
|
||||
{
|
||||
struct ril_stk *sd = ril_stk_get_data(stk);
|
||||
|
||||
DBG("");
|
||||
if (!sd->event_id[STK_EVENT_PROACTIVE_COMMAND]) {
|
||||
DBG("Subscribing notifications");
|
||||
sd->event_id[STK_EVENT_PROACTIVE_COMMAND] =
|
||||
grilio_channel_add_unsol_event_handler(sd->io,
|
||||
ril_stk_pcmd_notify,
|
||||
RIL_UNSOL_STK_PROACTIVE_COMMAND, sd);
|
||||
|
||||
GASSERT(!sd->event_id[STK_EVENT_SESSION_END]);
|
||||
sd->event_id[STK_EVENT_SESSION_END] =
|
||||
grilio_channel_add_unsol_event_handler(sd->io,
|
||||
ril_stk_session_end_notify,
|
||||
RIL_UNSOL_STK_SESSION_END, sd);
|
||||
|
||||
GASSERT(!sd->event_id[STK_EVENT_NOTIFY]);
|
||||
sd->event_id[STK_EVENT_NOTIFY] =
|
||||
grilio_channel_add_unsol_event_handler(sd->io,
|
||||
ril_stk_event_notify,
|
||||
RIL_UNSOL_STK_EVENT_NOTIFY, sd);
|
||||
|
||||
grilio_queue_send_request(sd->q, NULL,
|
||||
RIL_REQUEST_REPORT_STK_SERVICE_IS_RUNNING);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_stk_set_lang()
|
||||
{
|
||||
GError *error = NULL;
|
||||
GIOChannel* chan = g_io_channel_new_file(UI_LANG, "r", &error);
|
||||
if (chan) {
|
||||
GString* buf = g_string_new(NULL);
|
||||
gsize term;
|
||||
while (g_io_channel_read_line_string(chan, buf, &term, NULL) ==
|
||||
G_IO_STATUS_NORMAL) {
|
||||
char* lang;
|
||||
g_string_set_size(buf, term);
|
||||
lang = strstr(buf->str, "LANG=");
|
||||
if (lang) {
|
||||
setenv("LANG", lang + 5, TRUE);
|
||||
}
|
||||
}
|
||||
g_string_free(buf, TRUE);
|
||||
g_io_channel_unref(chan);
|
||||
} else {
|
||||
DBG("%s: %s", UI_LANG, error->message);
|
||||
g_error_free(error);
|
||||
}
|
||||
}
|
||||
|
||||
static int ril_stk_probe(struct ofono_stk *stk, unsigned int vendor, void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_stk *sd = g_new0(struct ril_stk, 1);
|
||||
|
||||
DBG("");
|
||||
sd->stk = stk;
|
||||
sd->io = grilio_channel_ref(ril_modem_io(modem));
|
||||
sd->q = grilio_queue_new(sd->io);
|
||||
|
||||
ofono_stk_set_data(stk, sd);
|
||||
ofono_stk_register(stk);
|
||||
ril_stk_set_lang();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_stk_remove(struct ofono_stk *stk)
|
||||
{
|
||||
struct ril_stk *sd = ril_stk_get_data(stk);
|
||||
unsigned int i;
|
||||
|
||||
DBG("");
|
||||
ofono_stk_set_data(stk, NULL);
|
||||
|
||||
for (i=0; i<G_N_ELEMENTS(sd->event_id); i++) {
|
||||
grilio_channel_remove_handler(sd->io, sd->event_id[i]);
|
||||
}
|
||||
|
||||
grilio_channel_unref(sd->io);
|
||||
grilio_queue_cancel_all(sd->q, FALSE);
|
||||
grilio_queue_unref(sd->q);
|
||||
g_free(sd);
|
||||
}
|
||||
|
||||
const struct ofono_stk_driver ril_stk_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_stk_probe,
|
||||
.remove = ril_stk_remove,
|
||||
.envelope = ril_stk_envelope,
|
||||
.terminal_response = ril_stk_terminal_response,
|
||||
.user_confirmation = ril_stk_user_confirmation,
|
||||
.ready = ril_stk_agent_ready
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,251 +0,0 @@
|
||||
# This is a sample configuration file for Jolla ril driver
|
||||
#
|
||||
# This file is expected to be installed in /etc/ofono
|
||||
#
|
||||
# Configuration for each modem is defined in its own [ril_x] section,
|
||||
# common settings are in the [Settings] section, all other sections
|
||||
# are ignored.
|
||||
#
|
||||
# If any value from [ril_x] section (except "socket") is defined
|
||||
# in the [Settings] section, it becomes the default for all modems.
|
||||
# Default values can still be redefined at [ril_x] level.
|
||||
#
|
||||
|
||||
[Settings]
|
||||
|
||||
# This option stops RIL plugin from creating any RIL modems.
|
||||
# If it's set to true, all [ril_x] sections are ignored even
|
||||
# if they are present, and no default configurtation is created.
|
||||
#
|
||||
# Default is false
|
||||
#
|
||||
#EmptyConfig=false
|
||||
|
||||
# User and group for the ofono process. RIL clients are typically
|
||||
# expected to run under radio:radio.
|
||||
#
|
||||
# Default is radio:radio
|
||||
#
|
||||
#Identity=radio:radio
|
||||
|
||||
# If the phone has more than one SIM slot, the 3G/LTE module may be
|
||||
# shared by all modems, meaning that only one of the slots can use
|
||||
# 3G/LTE. In order to "hand 4G over" to the other slot, the modem
|
||||
# currently using 3G/LTE has to drop to GSM, release 3G/LTE module
|
||||
# and only then 3G/LTE can be used by the other modem. This setting
|
||||
# allows to disable this behaviour (say, if your phone has independent
|
||||
# 3G/LTE modules for each slot or you don't need 4G for both slots).
|
||||
# Obviously, it only has any effect if you have more than one SIM.
|
||||
#
|
||||
# Default is true (switch the current data modem to 2G when changing
|
||||
# the data modems)
|
||||
#
|
||||
#3GLTEHandover=true
|
||||
|
||||
# RIL_REQUEST_SET_RADIO_CAPABILITY may or may not be supported by your RIL.
|
||||
# This option allows you to forcibly enable or disable use of this request.
|
||||
# It's involved in 3G/LTE handover between the modems, meaning that it only
|
||||
# makes sense if you have more than one slot.
|
||||
#
|
||||
# Possible values are auto, on and off
|
||||
#
|
||||
# Default is auto (enable for RIL version >= 11)
|
||||
#
|
||||
#SetRadioCapability=auto
|
||||
|
||||
[ril_0]
|
||||
|
||||
# Required entry, defines the RIL socket path
|
||||
socket=/dev/socket/rild
|
||||
|
||||
# Subscription string. Some (mostly, older) RILs require that 4 bytes
|
||||
# (usually SUB1 or SUB2) are written to the socket before rild starts
|
||||
# talking to us.
|
||||
#
|
||||
# Not sent by default.
|
||||
#
|
||||
#sub=SUB1
|
||||
|
||||
# RIL logging prefix, to tell one socket from another in the log.
|
||||
# Makes sense if you have more than one modem configured.
|
||||
#
|
||||
# No prefix by default.
|
||||
#
|
||||
#name=RIL1
|
||||
|
||||
# Slot id for SET_UICC_SUBSCRIPTION request.
|
||||
#
|
||||
# By default the first modem becomes slot 0, the next one slot 1 and so on.
|
||||
#
|
||||
#slot=0
|
||||
|
||||
# RIL request timeout, in milliseconds.
|
||||
#
|
||||
# The default is zero (no timeout)
|
||||
#
|
||||
#timeout=0
|
||||
|
||||
# Comma-separated list of radio technologies supported by the modem.
|
||||
# Valid technologies are "gsm", "umts" and "lte". The special value
|
||||
# "all" means that all technologies are supported.
|
||||
#
|
||||
# The default is all
|
||||
#
|
||||
#technologies=all
|
||||
|
||||
# This one is deprecated, use the technologies entry instead (above).
|
||||
#
|
||||
#enable4G=true
|
||||
|
||||
# RIL_REQUEST_SET_UICC_SUBSCRIPTION is 115 in RIL version 9 (or earlier)
|
||||
# and 122 in RIL version 10 and later. Since ofono doesn't know in advance
|
||||
# which RIL version it's dealing with, it makes the decision at runtime.
|
||||
# Settings it to false disables the workaround and always sends 122.
|
||||
#
|
||||
# Default is true (select SET_UICC_SUBSCRIPTION based on the RIL version)
|
||||
#
|
||||
#uiccWorkaround=true
|
||||
|
||||
# Points to the file containing comma-separated ECC (Emergency List Codes)
|
||||
# list, e.g. 911,112,*911,#911. The file is tracked by ofono and when its
|
||||
# contents changes, it's reflected in the EmergencyNumbers property of
|
||||
# org.ofono.VoiceCallManager.
|
||||
#
|
||||
# If necessary, the contents of the file can be synchronized with the
|
||||
# Android system property by adding something like this to /init.rc:
|
||||
#
|
||||
# on property:ril.ecclist=*
|
||||
# write /var/lib/ofono/ril.ecclist ${ril.ecclist}
|
||||
# chmod 0644 /var/lib/ofono/ril.ecclist
|
||||
#
|
||||
#ecclistFile=/var/lib/ofono/ril.ecclist
|
||||
|
||||
# RIL_REQUEST_ALLOW_DATA may or may not be supported by your RIL.
|
||||
# This option allows you to forcibly enable or disable use of this request.
|
||||
# Possible values are auto, on and off
|
||||
#
|
||||
# Default is auto (enable for RIL version >= 11)
|
||||
#
|
||||
#allowDataReq=auto
|
||||
|
||||
# Since RIL interface doesn't provide the standard way of querying the
|
||||
# number of pin retries left, some RIL implementation (namely Qualcomm)
|
||||
# allow to query the retry count by sending the empty pin. If your RIL
|
||||
# actually does check the empty pin (and decrements the retry count)
|
||||
# then you should turn this feature off.
|
||||
#
|
||||
# Default is true
|
||||
#
|
||||
#emptyPinQuery=true
|
||||
|
||||
# Different RILs use different data call structures which don't necessarily
|
||||
# match the format specified in the data list header. The header may have
|
||||
# version 9 but the list may contain RIL_Data_Call_Response_v6 structures,
|
||||
# list version 10 may contain RIL_Data_Call_Response_v11 and so on. By default
|
||||
# ofono assumes that the version from the list header matches the contents
|
||||
# but sometimes you have to explicitly tell ofono which one to use.
|
||||
# Possible values are 6, 9, 11 and auto.
|
||||
#
|
||||
# Default is auto
|
||||
#
|
||||
#dataCallFormat=auto
|
||||
|
||||
# Data call may fail with status 65535 which according to ril.h means that
|
||||
# we need to retry silently. The maximum number of retries is limited by
|
||||
# this parameter. Usually, one retry is enough. The first retry occurs
|
||||
# immediately, the subsequent ones after dataCallRetryDelay (see below)
|
||||
#
|
||||
# Default is 4
|
||||
#
|
||||
#dataCallRetryLimit=4
|
||||
|
||||
# Delay between data call retries, in milliseconds. Note that the first
|
||||
# retry occurs immediately after the first failure, the delays are only
|
||||
# applied if the first retry fails too.
|
||||
#
|
||||
# Default is 200 ms
|
||||
#
|
||||
#dataCallRetryDelay=200
|
||||
|
||||
# Additional local and remote hangup reasons. Remote reasons are checked
|
||||
# first. Normally, RIL plugin figures it out automatically. You would only
|
||||
# need to define these if your RIL does something unusual.
|
||||
#
|
||||
# No default
|
||||
#
|
||||
#remoteHangupReasons=20
|
||||
#localHangupReasons=23
|
||||
|
||||
# Voice call support. Some devices like USB modems and tablets don't support
|
||||
# voice calls. By default, voice calls are enabled and this option allows you
|
||||
# to disable voice call handling.
|
||||
#
|
||||
# Default true
|
||||
#
|
||||
#enableVoicecall=true
|
||||
|
||||
# Support for Cell Broadcast System (CBS). By default, its enabled but if
|
||||
# your rild and/or modem is not happy about it, you can turn it off.
|
||||
#
|
||||
# Default true
|
||||
#
|
||||
#enableCellBroadcast=true
|
||||
|
||||
# Timeout for the modem to show up, in milliseconds. Those that don't
|
||||
# show up before this timeout expires, will be dropped (ignored).
|
||||
#
|
||||
# In some fairly rare cases it makes sense to shorten this timeout for
|
||||
# optional modems (which may or may not be available), to speed up the
|
||||
# boot up process.
|
||||
#
|
||||
# The default is 20000 (20 seconds)
|
||||
#
|
||||
#startTimeout=20000
|
||||
|
||||
# This allows to use deprecated RIL_REQUEST_GET_IMEI instead of
|
||||
# RIL_REQUEST_DEVICE_IDENTITY to query IMEI from the modem. Some
|
||||
# RILs (e.g. MTK) still don't understand RIL_REQUEST_DEVICE_IDENTITY.
|
||||
#
|
||||
# Default is false (use RIL_REQUEST_DEVICE_IDENTITY)
|
||||
#
|
||||
#legacyImeiQuery=false
|
||||
|
||||
# Some devices don't support LTE RAT mode PREF_NET_TYPE_LTE_GSM_WCDMA.
|
||||
# This option allows to set a custom LTE mode.
|
||||
#
|
||||
# The default is 9 (PREF_NET_TYPE_LTE_GSM_WCDMA)
|
||||
#
|
||||
#lteNetworkMode=9
|
||||
|
||||
# Timeout for RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE, in milliseconds.
|
||||
#
|
||||
# The default is 20000 (20 seconds)
|
||||
#
|
||||
#networkModeTimeout=20000
|
||||
|
||||
# Cycle radio power at startup.
|
||||
#
|
||||
# The default is true (cycle the power)
|
||||
#
|
||||
#radioPowerCycle=true
|
||||
|
||||
# With some RILs it seems to be necessary to kick (RIL_REQUEST_RADIO_POWER)
|
||||
# the modems with power on after one of the modems has been powered off.
|
||||
# Otherwise bad things may happen (like the modem never registering
|
||||
# on the network).
|
||||
#
|
||||
# On the other hand, with some RILs it's causing some trouble (like this
|
||||
# extra RIL_REQUEST_RADIO_POWER getting stuck indefinitely).
|
||||
#
|
||||
# The default is true for historical reasons
|
||||
#
|
||||
#confirmRadioPowerOn=true
|
||||
|
||||
# Normally we should be able to have two simultaneously active data
|
||||
# contexts - one for mobile data and one for MMS. Some devices however
|
||||
# require that mobile data is disconnected before we can send or receive
|
||||
# MMS. In other words, activation of the second data context fails.
|
||||
#
|
||||
# The default is false (more than one context is supported)
|
||||
#
|
||||
#singleDataContext=false
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_TYPES_H
|
||||
#define RIL_TYPES_H
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <grilio_types.h>
|
||||
#include <gutil_macros.h>
|
||||
|
||||
struct ofono_modem;
|
||||
struct ofono_sim;
|
||||
|
||||
#include <ofono/types.h>
|
||||
#include <ofono/radio-settings.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "ril_constants.h"
|
||||
|
||||
#define RIL_RETRY_SECS (2)
|
||||
#define RIL_RETRY_MS (RIL_RETRY_SECS*1000)
|
||||
|
||||
struct ril_data;
|
||||
struct ril_data_call;
|
||||
struct ril_modem;
|
||||
struct ril_radio;
|
||||
struct ril_network;
|
||||
struct ril_sim_card;
|
||||
struct ril_vendor_hook;
|
||||
|
||||
struct ril_slot_config {
|
||||
guint slot;
|
||||
enum ofono_radio_access_mode techs;
|
||||
int lte_network_mode;
|
||||
int network_mode_timeout;
|
||||
gboolean query_available_band_mode;
|
||||
gboolean empty_pin_query;
|
||||
gboolean radio_power_cycle;
|
||||
gboolean confirm_radio_power_on;
|
||||
gboolean enable_voicecall;
|
||||
gboolean enable_cbs;
|
||||
GUtilInts *local_hangup_reasons;
|
||||
GUtilInts *remote_hangup_reasons;
|
||||
};
|
||||
|
||||
#endif /* RIL_TYPES_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,226 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "smsutil.h"
|
||||
#include "util.h"
|
||||
|
||||
#define USSD_CANCEL_TIMEOUT_SEC (20)
|
||||
|
||||
struct ril_ussd {
|
||||
struct ofono_ussd *ussd;
|
||||
GRilIoChannel *io;
|
||||
GRilIoQueue *q;
|
||||
guint timer_id;
|
||||
gulong event_id;
|
||||
};
|
||||
|
||||
struct ril_ussd_cbd {
|
||||
ofono_ussd_cb_t cb;
|
||||
gpointer data;
|
||||
};
|
||||
|
||||
#define ril_ussd_cbd_free g_free
|
||||
|
||||
static inline struct ril_ussd *ril_ussd_get_data(struct ofono_ussd *ussd)
|
||||
{
|
||||
return ofono_ussd_get_data(ussd);
|
||||
}
|
||||
|
||||
static struct ril_ussd_cbd *ril_ussd_cbd_new(ofono_ussd_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_ussd_cbd *cbd = g_new0(struct ril_ussd_cbd, 1);
|
||||
|
||||
cbd->cb = cb;
|
||||
cbd->data = data;
|
||||
return cbd;
|
||||
}
|
||||
|
||||
static void ril_ussd_cancel_cb(GRilIoChannel *io, int status,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
struct ril_ussd_cbd *cbd = user_data;
|
||||
|
||||
/* Always report sucessful completion, otherwise ofono may get
|
||||
* stuck in the USSD_STATE_ACTIVE state */
|
||||
cbd->cb(ril_error_ok(&error), cbd->data);
|
||||
}
|
||||
|
||||
static void ril_ussd_request(struct ofono_ussd *ussd, int dcs,
|
||||
const unsigned char *pdu, int len, ofono_ussd_cb_t cb, void *data)
|
||||
{
|
||||
struct ofono_error error;
|
||||
enum sms_charset charset;
|
||||
struct ril_ussd *ud = ril_ussd_get_data(ussd);
|
||||
|
||||
ofono_info("send ussd, len:%d", len);
|
||||
if (cbs_dcs_decode(dcs, NULL, NULL, &charset, NULL, NULL, NULL)) {
|
||||
if (charset == SMS_CHARSET_7BIT) {
|
||||
unsigned char unpacked_buf[182];
|
||||
long written = 0;
|
||||
|
||||
unpack_7bit_own_buf(pdu, len, 0, TRUE,
|
||||
sizeof(unpacked_buf)-1, &written, 0,
|
||||
unpacked_buf);
|
||||
|
||||
unpacked_buf[written] = 0;
|
||||
if (written >= 1) {
|
||||
/*
|
||||
* When USSD was packed, additional CR
|
||||
* might have been added (according to
|
||||
* 23.038 6.1.2.3.1). So if the last
|
||||
* character is CR, it should be removed
|
||||
* here.
|
||||
*
|
||||
* Over 2 characters long USSD string must
|
||||
* end with # (checked in valid_ussd_string),
|
||||
* so it should be safe to remove extra CR.
|
||||
*/
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
int length = strlen((char *)unpacked_buf);
|
||||
while (length > 2 &&
|
||||
unpacked_buf[length-1] == '\r') {
|
||||
unpacked_buf[--length] = 0;
|
||||
}
|
||||
grilio_request_append_utf8_chars(req, (char*)
|
||||
unpacked_buf, length);
|
||||
grilio_queue_send_request(ud->q, req,
|
||||
RIL_REQUEST_SEND_USSD);
|
||||
grilio_request_unref(req);
|
||||
cb(ril_error_ok(&error), data);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cb(ril_error_failure(&error), data);
|
||||
}
|
||||
|
||||
static void ril_ussd_cancel(struct ofono_ussd *ussd,
|
||||
ofono_ussd_cb_t cb, void *data)
|
||||
{
|
||||
struct ril_ussd *ud = ril_ussd_get_data(ussd);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
ofono_info("send ussd cancel");
|
||||
grilio_request_set_timeout(req, USSD_CANCEL_TIMEOUT_SEC * 1000);
|
||||
grilio_queue_send_request_full(ud->q, req, RIL_REQUEST_CANCEL_USSD,
|
||||
ril_ussd_cancel_cb, ril_ussd_cbd_free,
|
||||
ril_ussd_cbd_new(cb, data));
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
|
||||
static void ril_ussd_notify(GRilIoChannel *io, guint code,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_ussd *ud = user_data;
|
||||
GRilIoParser rilp;
|
||||
char *type;
|
||||
guint32 n = 0;
|
||||
|
||||
ofono_info("ussd received");
|
||||
|
||||
GASSERT(code == RIL_UNSOL_ON_USSD);
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
grilio_parser_get_uint32(&rilp, &n);
|
||||
type = grilio_parser_get_utf8(&rilp);
|
||||
|
||||
if (type) {
|
||||
int ussdtype = g_ascii_xdigit_value(*type);
|
||||
char *msg = (n > 1) ? grilio_parser_get_utf8(&rilp) : NULL;
|
||||
|
||||
if (msg) {
|
||||
const int msglen = strlen(msg);
|
||||
DBG("ussd length %d", msglen);
|
||||
ofono_ussd_notify(ud->ussd, ussdtype, 0xFF,
|
||||
(const unsigned char *)msg, msglen);
|
||||
/* msg is freed by core if dcs is 0xFF */
|
||||
} else {
|
||||
ofono_ussd_notify(ud->ussd, ussdtype, 0, NULL, 0);
|
||||
}
|
||||
|
||||
g_free(type);
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean ril_ussd_register(gpointer user_data)
|
||||
{
|
||||
struct ril_ussd *ud = user_data;
|
||||
|
||||
DBG("");
|
||||
GASSERT(ud->timer_id);
|
||||
ud->timer_id = 0;
|
||||
ofono_ussd_register(ud->ussd);
|
||||
|
||||
/* Register for USSD events */
|
||||
ud->event_id = grilio_channel_add_unsol_event_handler(ud->io,
|
||||
ril_ussd_notify, RIL_UNSOL_ON_USSD, ud);
|
||||
|
||||
/* Single-shot */
|
||||
return G_SOURCE_REMOVE;
|
||||
}
|
||||
|
||||
static int ril_ussd_probe(struct ofono_ussd *ussd, unsigned int vendor,
|
||||
void *data)
|
||||
{
|
||||
struct ril_modem *modem = data;
|
||||
struct ril_ussd *ud = g_try_new0(struct ril_ussd, 1);
|
||||
|
||||
DBG("");
|
||||
ud->ussd = ussd;
|
||||
ud->io = grilio_channel_ref(ril_modem_io(modem));
|
||||
ud->q = grilio_queue_new(ud->io);
|
||||
ud->timer_id = g_idle_add(ril_ussd_register, ud);
|
||||
ofono_ussd_set_data(ussd, ud);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void ril_ussd_remove(struct ofono_ussd *ussd)
|
||||
{
|
||||
struct ril_ussd *ud = ril_ussd_get_data(ussd);
|
||||
|
||||
DBG("");
|
||||
ofono_ussd_set_data(ussd, NULL);
|
||||
|
||||
if (ud->timer_id > 0) {
|
||||
g_source_remove(ud->timer_id);
|
||||
}
|
||||
|
||||
grilio_channel_remove_handler(ud->io, ud->event_id);
|
||||
grilio_channel_unref(ud->io);
|
||||
grilio_queue_cancel_all(ud->q, FALSE);
|
||||
grilio_queue_unref(ud->q);
|
||||
g_free(ud);
|
||||
}
|
||||
|
||||
const struct ofono_ussd_driver ril_ussd_driver = {
|
||||
.name = RILMODEM_DRIVER,
|
||||
.probe = ril_ussd_probe,
|
||||
.remove = ril_ussd_remove,
|
||||
.request = ril_ussd_request,
|
||||
.cancel = ril_ussd_cancel
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,420 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_util.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include <grilio_channel.h>
|
||||
|
||||
#include <gutil_misc.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "netreg.h"
|
||||
|
||||
const char *ril_error_to_string(int error)
|
||||
{
|
||||
#define RIL_E_(name) case RIL_E_##name: return #name
|
||||
#define GRILIO_E_(name) case GRILIO_STATUS_##name: return "GRILIO_" #name
|
||||
static char unknown[12];
|
||||
switch (error) {
|
||||
case RIL_E_SUCCESS: return "OK";
|
||||
GRILIO_E_(TIMEOUT);
|
||||
GRILIO_E_(CANCELLED);
|
||||
RIL_E_(RADIO_NOT_AVAILABLE);
|
||||
RIL_E_(GENERIC_FAILURE);
|
||||
RIL_E_(PASSWORD_INCORRECT);
|
||||
RIL_E_(SIM_PIN2);
|
||||
RIL_E_(SIM_PUK2);
|
||||
RIL_E_(REQUEST_NOT_SUPPORTED);
|
||||
RIL_E_(CANCELLED);
|
||||
RIL_E_(OP_NOT_ALLOWED_DURING_VOICE_CALL);
|
||||
RIL_E_(OP_NOT_ALLOWED_BEFORE_REG_TO_NW);
|
||||
RIL_E_(SMS_SEND_FAIL_RETRY);
|
||||
RIL_E_(SIM_ABSENT);
|
||||
RIL_E_(SUBSCRIPTION_NOT_AVAILABLE);
|
||||
RIL_E_(MODE_NOT_SUPPORTED);
|
||||
RIL_E_(FDN_CHECK_FAILURE);
|
||||
RIL_E_(ILLEGAL_SIM_OR_ME);
|
||||
RIL_E_(MISSING_RESOURCE);
|
||||
RIL_E_(NO_SUCH_ELEMENT);
|
||||
RIL_E_(DIAL_MODIFIED_TO_USSD);
|
||||
RIL_E_(DIAL_MODIFIED_TO_SS);
|
||||
RIL_E_(DIAL_MODIFIED_TO_DIAL);
|
||||
RIL_E_(USSD_MODIFIED_TO_DIAL);
|
||||
RIL_E_(USSD_MODIFIED_TO_SS);
|
||||
RIL_E_(USSD_MODIFIED_TO_USSD);
|
||||
RIL_E_(SS_MODIFIED_TO_DIAL);
|
||||
RIL_E_(SS_MODIFIED_TO_USSD);
|
||||
RIL_E_(SUBSCRIPTION_NOT_SUPPORTED);
|
||||
RIL_E_(SS_MODIFIED_TO_SS);
|
||||
RIL_E_(LCE_NOT_SUPPORTED);
|
||||
RIL_E_(NO_MEMORY);
|
||||
RIL_E_(INTERNAL_ERR);
|
||||
RIL_E_(SYSTEM_ERR);
|
||||
RIL_E_(MODEM_ERR);
|
||||
RIL_E_(INVALID_STATE);
|
||||
RIL_E_(NO_RESOURCES);
|
||||
RIL_E_(SIM_ERR);
|
||||
RIL_E_(INVALID_ARGUMENTS);
|
||||
RIL_E_(INVALID_SIM_STATE);
|
||||
RIL_E_(INVALID_MODEM_STATE);
|
||||
RIL_E_(INVALID_CALL_ID);
|
||||
RIL_E_(NO_SMS_TO_ACK);
|
||||
RIL_E_(NETWORK_ERR);
|
||||
RIL_E_(REQUEST_RATE_LIMITED);
|
||||
RIL_E_(SIM_BUSY);
|
||||
RIL_E_(SIM_FULL);
|
||||
RIL_E_(NETWORK_REJECT);
|
||||
RIL_E_(OPERATION_NOT_ALLOWED);
|
||||
RIL_E_(EMPTY_RECORD);
|
||||
RIL_E_(INVALID_SMS_FORMAT);
|
||||
RIL_E_(ENCODING_ERR);
|
||||
RIL_E_(INVALID_SMSC_ADDRESS);
|
||||
RIL_E_(NO_SUCH_ENTRY);
|
||||
RIL_E_(NETWORK_NOT_READY);
|
||||
RIL_E_(NOT_PROVISIONED);
|
||||
RIL_E_(NO_SUBSCRIPTION);
|
||||
RIL_E_(NO_NETWORK_FOUND);
|
||||
RIL_E_(DEVICE_IN_USE);
|
||||
RIL_E_(ABORTED);
|
||||
RIL_E_(INVALID_RESPONSE);
|
||||
default:
|
||||
snprintf(unknown, sizeof(unknown), "%d", error);
|
||||
return unknown;
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_request_to_string(guint request)
|
||||
{
|
||||
#define RIL_REQUEST_(name) case RIL_REQUEST_##name: return #name
|
||||
static char unknown[24];
|
||||
switch (request) {
|
||||
RIL_REQUEST_(GET_SIM_STATUS);
|
||||
RIL_REQUEST_(ENTER_SIM_PIN);
|
||||
RIL_REQUEST_(ENTER_SIM_PUK);
|
||||
RIL_REQUEST_(ENTER_SIM_PIN2);
|
||||
RIL_REQUEST_(ENTER_SIM_PUK2);
|
||||
RIL_REQUEST_(CHANGE_SIM_PIN);
|
||||
RIL_REQUEST_(CHANGE_SIM_PIN2);
|
||||
RIL_REQUEST_(ENTER_NETWORK_DEPERSONALIZATION);
|
||||
RIL_REQUEST_(GET_CURRENT_CALLS);
|
||||
RIL_REQUEST_(DIAL);
|
||||
RIL_REQUEST_(GET_IMSI);
|
||||
RIL_REQUEST_(HANGUP);
|
||||
RIL_REQUEST_(HANGUP_WAITING_OR_BACKGROUND);
|
||||
RIL_REQUEST_(HANGUP_FOREGROUND_RESUME_BACKGROUND);
|
||||
RIL_REQUEST_(SWITCH_HOLDING_AND_ACTIVE);
|
||||
RIL_REQUEST_(CONFERENCE);
|
||||
RIL_REQUEST_(UDUB);
|
||||
RIL_REQUEST_(LAST_CALL_FAIL_CAUSE);
|
||||
RIL_REQUEST_(SIGNAL_STRENGTH);
|
||||
RIL_REQUEST_(VOICE_REGISTRATION_STATE);
|
||||
RIL_REQUEST_(DATA_REGISTRATION_STATE);
|
||||
RIL_REQUEST_(OPERATOR);
|
||||
RIL_REQUEST_(RADIO_POWER);
|
||||
RIL_REQUEST_(DTMF);
|
||||
RIL_REQUEST_(SEND_SMS);
|
||||
RIL_REQUEST_(SEND_SMS_EXPECT_MORE);
|
||||
RIL_REQUEST_(SETUP_DATA_CALL);
|
||||
RIL_REQUEST_(SIM_IO);
|
||||
RIL_REQUEST_(SEND_USSD);
|
||||
RIL_REQUEST_(CANCEL_USSD);
|
||||
RIL_REQUEST_(GET_CLIR);
|
||||
RIL_REQUEST_(SET_CLIR);
|
||||
RIL_REQUEST_(QUERY_CALL_FORWARD_STATUS);
|
||||
RIL_REQUEST_(SET_CALL_FORWARD);
|
||||
RIL_REQUEST_(QUERY_CALL_WAITING);
|
||||
RIL_REQUEST_(SET_CALL_WAITING);
|
||||
RIL_REQUEST_(SMS_ACKNOWLEDGE);
|
||||
RIL_REQUEST_(GET_IMEI);
|
||||
RIL_REQUEST_(GET_IMEISV);
|
||||
RIL_REQUEST_(ANSWER);
|
||||
RIL_REQUEST_(DEACTIVATE_DATA_CALL);
|
||||
RIL_REQUEST_(QUERY_FACILITY_LOCK);
|
||||
RIL_REQUEST_(SET_FACILITY_LOCK);
|
||||
RIL_REQUEST_(CHANGE_BARRING_PASSWORD);
|
||||
RIL_REQUEST_(QUERY_NETWORK_SELECTION_MODE);
|
||||
RIL_REQUEST_(SET_NETWORK_SELECTION_AUTOMATIC);
|
||||
RIL_REQUEST_(SET_NETWORK_SELECTION_MANUAL);
|
||||
RIL_REQUEST_(QUERY_AVAILABLE_NETWORKS);
|
||||
RIL_REQUEST_(DTMF_START);
|
||||
RIL_REQUEST_(DTMF_STOP);
|
||||
RIL_REQUEST_(BASEBAND_VERSION);
|
||||
RIL_REQUEST_(SEPARATE_CONNECTION);
|
||||
RIL_REQUEST_(SET_MUTE);
|
||||
RIL_REQUEST_(GET_MUTE);
|
||||
RIL_REQUEST_(QUERY_CLIP);
|
||||
RIL_REQUEST_(LAST_DATA_CALL_FAIL_CAUSE);
|
||||
RIL_REQUEST_(DATA_CALL_LIST);
|
||||
RIL_REQUEST_(RESET_RADIO);
|
||||
RIL_REQUEST_(OEM_HOOK_RAW);
|
||||
RIL_REQUEST_(OEM_HOOK_STRINGS);
|
||||
RIL_REQUEST_(SCREEN_STATE);
|
||||
RIL_REQUEST_(SET_SUPP_SVC_NOTIFICATION);
|
||||
RIL_REQUEST_(WRITE_SMS_TO_SIM);
|
||||
RIL_REQUEST_(DELETE_SMS_ON_SIM);
|
||||
RIL_REQUEST_(SET_BAND_MODE);
|
||||
RIL_REQUEST_(QUERY_AVAILABLE_BAND_MODE);
|
||||
RIL_REQUEST_(STK_GET_PROFILE);
|
||||
RIL_REQUEST_(STK_SET_PROFILE);
|
||||
RIL_REQUEST_(STK_SEND_ENVELOPE_COMMAND);
|
||||
RIL_REQUEST_(STK_SEND_TERMINAL_RESPONSE);
|
||||
RIL_REQUEST_(STK_HANDLE_CALL_SETUP_REQUESTED_FROM_SIM);
|
||||
RIL_REQUEST_(EXPLICIT_CALL_TRANSFER);
|
||||
RIL_REQUEST_(SET_PREFERRED_NETWORK_TYPE);
|
||||
RIL_REQUEST_(GET_PREFERRED_NETWORK_TYPE);
|
||||
RIL_REQUEST_(GET_NEIGHBORING_CELL_IDS);
|
||||
RIL_REQUEST_(SET_LOCATION_UPDATES);
|
||||
RIL_REQUEST_(CDMA_SET_SUBSCRIPTION_SOURCE);
|
||||
RIL_REQUEST_(CDMA_SET_ROAMING_PREFERENCE);
|
||||
RIL_REQUEST_(CDMA_QUERY_ROAMING_PREFERENCE);
|
||||
RIL_REQUEST_(SET_TTY_MODE);
|
||||
RIL_REQUEST_(QUERY_TTY_MODE);
|
||||
RIL_REQUEST_(CDMA_SET_PREFERRED_VOICE_PRIVACY_MODE);
|
||||
RIL_REQUEST_(CDMA_QUERY_PREFERRED_VOICE_PRIVACY_MODE);
|
||||
RIL_REQUEST_(CDMA_FLASH);
|
||||
RIL_REQUEST_(CDMA_BURST_DTMF);
|
||||
RIL_REQUEST_(CDMA_VALIDATE_AND_WRITE_AKEY);
|
||||
RIL_REQUEST_(CDMA_SEND_SMS);
|
||||
RIL_REQUEST_(CDMA_SMS_ACKNOWLEDGE);
|
||||
RIL_REQUEST_(GSM_GET_BROADCAST_SMS_CONFIG);
|
||||
RIL_REQUEST_(GSM_SET_BROADCAST_SMS_CONFIG);
|
||||
RIL_REQUEST_(GSM_SMS_BROADCAST_ACTIVATION);
|
||||
RIL_REQUEST_(CDMA_GET_BROADCAST_SMS_CONFIG);
|
||||
RIL_REQUEST_(CDMA_SET_BROADCAST_SMS_CONFIG);
|
||||
RIL_REQUEST_(CDMA_SMS_BROADCAST_ACTIVATION);
|
||||
RIL_REQUEST_(CDMA_SUBSCRIPTION);
|
||||
RIL_REQUEST_(CDMA_WRITE_SMS_TO_RUIM);
|
||||
RIL_REQUEST_(CDMA_DELETE_SMS_ON_RUIM);
|
||||
RIL_REQUEST_(DEVICE_IDENTITY);
|
||||
RIL_REQUEST_(EXIT_EMERGENCY_CALLBACK_MODE);
|
||||
RIL_REQUEST_(GET_SMSC_ADDRESS);
|
||||
RIL_REQUEST_(SET_SMSC_ADDRESS);
|
||||
RIL_REQUEST_(REPORT_SMS_MEMORY_STATUS);
|
||||
RIL_REQUEST_(REPORT_STK_SERVICE_IS_RUNNING);
|
||||
RIL_REQUEST_(CDMA_GET_SUBSCRIPTION_SOURCE);
|
||||
RIL_REQUEST_(ISIM_AUTHENTICATION);
|
||||
RIL_REQUEST_(ACKNOWLEDGE_INCOMING_GSM_SMS_WITH_PDU);
|
||||
RIL_REQUEST_(STK_SEND_ENVELOPE_WITH_STATUS);
|
||||
RIL_REQUEST_(VOICE_RADIO_TECH);
|
||||
RIL_REQUEST_(GET_CELL_INFO_LIST);
|
||||
RIL_REQUEST_(SET_UNSOL_CELL_INFO_LIST_RATE);
|
||||
RIL_REQUEST_(SET_INITIAL_ATTACH_APN);
|
||||
RIL_REQUEST_(IMS_REGISTRATION_STATE);
|
||||
RIL_REQUEST_(IMS_SEND_SMS);
|
||||
RIL_REQUEST_(SIM_TRANSMIT_APDU_BASIC);
|
||||
RIL_REQUEST_(SIM_OPEN_CHANNEL);
|
||||
RIL_REQUEST_(SIM_CLOSE_CHANNEL);
|
||||
RIL_REQUEST_(SIM_TRANSMIT_APDU_CHANNEL);
|
||||
RIL_REQUEST_(NV_READ_ITEM);
|
||||
RIL_REQUEST_(NV_WRITE_ITEM);
|
||||
RIL_REQUEST_(NV_WRITE_CDMA_PRL);
|
||||
RIL_REQUEST_(NV_RESET_CONFIG);
|
||||
RIL_REQUEST_(SET_UICC_SUBSCRIPTION);
|
||||
RIL_REQUEST_(ALLOW_DATA);
|
||||
RIL_REQUEST_(GET_HARDWARE_CONFIG);
|
||||
RIL_REQUEST_(SIM_AUTHENTICATION);
|
||||
RIL_REQUEST_(GET_DC_RT_INFO);
|
||||
RIL_REQUEST_(SET_DC_RT_INFO_RATE);
|
||||
RIL_REQUEST_(SET_DATA_PROFILE);
|
||||
RIL_REQUEST_(SHUTDOWN);
|
||||
RIL_REQUEST_(GET_RADIO_CAPABILITY);
|
||||
RIL_REQUEST_(SET_RADIO_CAPABILITY);
|
||||
case RIL_RESPONSE_ACKNOWLEDGEMENT:
|
||||
return "RESPONSE_ACK";
|
||||
default:
|
||||
snprintf(unknown, sizeof(unknown), "RIL_REQUEST_%d", request);
|
||||
return unknown;
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_unsol_event_to_string(guint event)
|
||||
{
|
||||
#define RIL_UNSOL_(name) case RIL_UNSOL_##name: return #name
|
||||
static char unknown[24];
|
||||
switch (event) {
|
||||
RIL_UNSOL_(RESPONSE_RADIO_STATE_CHANGED);
|
||||
RIL_UNSOL_(RESPONSE_CALL_STATE_CHANGED);
|
||||
RIL_UNSOL_(RESPONSE_VOICE_NETWORK_STATE_CHANGED);
|
||||
RIL_UNSOL_(RESPONSE_NEW_SMS);
|
||||
RIL_UNSOL_(RESPONSE_NEW_SMS_STATUS_REPORT);
|
||||
RIL_UNSOL_(RESPONSE_NEW_SMS_ON_SIM);
|
||||
RIL_UNSOL_(ON_USSD);
|
||||
RIL_UNSOL_(ON_USSD_REQUEST);
|
||||
RIL_UNSOL_(NITZ_TIME_RECEIVED);
|
||||
RIL_UNSOL_(SIGNAL_STRENGTH);
|
||||
RIL_UNSOL_(DATA_CALL_LIST_CHANGED);
|
||||
RIL_UNSOL_(SUPP_SVC_NOTIFICATION);
|
||||
RIL_UNSOL_(STK_SESSION_END);
|
||||
RIL_UNSOL_(STK_PROACTIVE_COMMAND);
|
||||
RIL_UNSOL_(STK_EVENT_NOTIFY);
|
||||
RIL_UNSOL_(STK_CALL_SETUP);
|
||||
RIL_UNSOL_(SIM_SMS_STORAGE_FULL);
|
||||
RIL_UNSOL_(SIM_REFRESH);
|
||||
RIL_UNSOL_(CALL_RING);
|
||||
RIL_UNSOL_(RESPONSE_SIM_STATUS_CHANGED);
|
||||
RIL_UNSOL_(RESPONSE_CDMA_NEW_SMS);
|
||||
RIL_UNSOL_(RESPONSE_NEW_BROADCAST_SMS);
|
||||
RIL_UNSOL_(CDMA_RUIM_SMS_STORAGE_FULL);
|
||||
RIL_UNSOL_(RESTRICTED_STATE_CHANGED);
|
||||
RIL_UNSOL_(ENTER_EMERGENCY_CALLBACK_MODE);
|
||||
RIL_UNSOL_(CDMA_CALL_WAITING);
|
||||
RIL_UNSOL_(CDMA_OTA_PROVISION_STATUS);
|
||||
RIL_UNSOL_(CDMA_INFO_REC);
|
||||
RIL_UNSOL_(OEM_HOOK_RAW);
|
||||
RIL_UNSOL_(RINGBACK_TONE);
|
||||
RIL_UNSOL_(RESEND_INCALL_MUTE);
|
||||
RIL_UNSOL_(CDMA_SUBSCRIPTION_SOURCE_CHANGED);
|
||||
RIL_UNSOL_(CDMA_PRL_CHANGED);
|
||||
RIL_UNSOL_(EXIT_EMERGENCY_CALLBACK_MODE);
|
||||
RIL_UNSOL_(RIL_CONNECTED);
|
||||
RIL_UNSOL_(VOICE_RADIO_TECH_CHANGED);
|
||||
RIL_UNSOL_(CELL_INFO_LIST);
|
||||
RIL_UNSOL_(RESPONSE_IMS_NETWORK_STATE_CHANGED);
|
||||
RIL_UNSOL_(UICC_SUBSCRIPTION_STATUS_CHANGED);
|
||||
RIL_UNSOL_(SRVCC_STATE_NOTIFY);
|
||||
RIL_UNSOL_(HARDWARE_CONFIG_CHANGED);
|
||||
RIL_UNSOL_(DC_RT_INFO_CHANGED);
|
||||
RIL_UNSOL_(RADIO_CAPABILITY);
|
||||
RIL_UNSOL_(ON_SS);
|
||||
RIL_UNSOL_(STK_CC_ALPHA_NOTIFY);
|
||||
default:
|
||||
snprintf(unknown, sizeof(unknown), "RIL_UNSOL_%d", event);
|
||||
return unknown;
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_radio_state_to_string(int radio_state)
|
||||
{
|
||||
#define RADIO_STATE_(name) case RADIO_STATE_##name: return #name
|
||||
static char unknown[16];
|
||||
switch (radio_state) {
|
||||
RADIO_STATE_(OFF);
|
||||
RADIO_STATE_(UNAVAILABLE);
|
||||
RADIO_STATE_(SIM_NOT_READY);
|
||||
RADIO_STATE_(SIM_LOCKED_OR_ABSENT);
|
||||
RADIO_STATE_(SIM_READY);
|
||||
RADIO_STATE_(RUIM_NOT_READY);
|
||||
RADIO_STATE_(RUIM_READY);
|
||||
RADIO_STATE_(RUIM_LOCKED_OR_ABSENT);
|
||||
RADIO_STATE_(NV_NOT_READY);
|
||||
RADIO_STATE_(NV_READY);
|
||||
RADIO_STATE_(ON);
|
||||
default:
|
||||
snprintf(unknown, sizeof(unknown), "%d (?)", radio_state);
|
||||
return unknown;
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns enum access_technology or -1 on failure. */
|
||||
int ril_parse_tech(const char *stech, int *ril_tech)
|
||||
{
|
||||
int access_tech = -1;
|
||||
int tech = -1;
|
||||
if (gutil_parse_int(stech, 0, &tech)) {
|
||||
switch (tech) {
|
||||
case RADIO_TECH_GPRS:
|
||||
case RADIO_TECH_GSM:
|
||||
access_tech = ACCESS_TECHNOLOGY_GSM;
|
||||
break;
|
||||
case RADIO_TECH_EDGE:
|
||||
access_tech = ACCESS_TECHNOLOGY_GSM_EGPRS;
|
||||
break;
|
||||
case RADIO_TECH_UMTS:
|
||||
access_tech = ACCESS_TECHNOLOGY_UTRAN;
|
||||
break;
|
||||
case RADIO_TECH_HSDPA:
|
||||
access_tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA;
|
||||
break;
|
||||
case RADIO_TECH_HSUPA:
|
||||
access_tech = ACCESS_TECHNOLOGY_UTRAN_HSUPA;
|
||||
break;
|
||||
case RADIO_TECH_HSPA:
|
||||
case RADIO_TECH_HSPAP:
|
||||
access_tech = ACCESS_TECHNOLOGY_UTRAN_HSDPA_HSUPA;
|
||||
break;
|
||||
case RADIO_TECH_LTE:
|
||||
access_tech = ACCESS_TECHNOLOGY_EUTRAN;
|
||||
break;
|
||||
default:
|
||||
DBG("Unknown RIL tech %s", stech);
|
||||
/* no break */
|
||||
case RADIO_TECH_IWLAN:
|
||||
case RADIO_TECH_UNKNOWN:
|
||||
tech = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
if (ril_tech) {
|
||||
*ril_tech = tech;
|
||||
}
|
||||
return access_tech;
|
||||
}
|
||||
|
||||
gboolean ril_parse_mcc_mnc(const char *str, struct ofono_network_operator *op)
|
||||
{
|
||||
if (str) {
|
||||
int i;
|
||||
const char *ptr = str;
|
||||
|
||||
/* Three digit country code */
|
||||
for (i = 0;
|
||||
i < OFONO_MAX_MCC_LENGTH && *ptr && isdigit(*ptr);
|
||||
i++) {
|
||||
op->mcc[i] = *ptr++;
|
||||
}
|
||||
op->mcc[i] = 0;
|
||||
|
||||
if (i == OFONO_MAX_MCC_LENGTH) {
|
||||
/* Usually 2 but sometimes 3 digit network code */
|
||||
for (i = 0;
|
||||
i < OFONO_MAX_MNC_LENGTH && *ptr && isdigit(*ptr);
|
||||
i++) {
|
||||
op->mnc[i] = *ptr++;
|
||||
}
|
||||
op->mnc[i] = 0;
|
||||
|
||||
if (i > 0) {
|
||||
|
||||
/*
|
||||
* Sometimes MCC/MNC are followed by + and
|
||||
* what looks like the technology code. This
|
||||
* is of course completely undocumented.
|
||||
*/
|
||||
if (*ptr == '+') {
|
||||
int tech = ril_parse_tech(ptr+1, NULL);
|
||||
if (tech >= 0) {
|
||||
op->tech = tech;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2015-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_UTIL_H
|
||||
#define RIL_UTIL_H
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
struct ofono_network_operator;
|
||||
|
||||
const char *ril_error_to_string(int error);
|
||||
const char *ril_request_to_string(guint request);
|
||||
const char *ril_unsol_event_to_string(guint event);
|
||||
const char *ril_radio_state_to_string(int radio_state);
|
||||
int ril_parse_tech(const char *stech, int *ril_tech);
|
||||
gboolean ril_parse_mcc_mnc(const char *str, struct ofono_network_operator *op);
|
||||
|
||||
#define ril_error_init_ok(err) \
|
||||
((err)->error = 0, (err)->type = OFONO_ERROR_TYPE_NO_ERROR)
|
||||
#define ril_error_init_failure(err) \
|
||||
((err)->error = 0, (err)->type = OFONO_ERROR_TYPE_FAILURE)
|
||||
#define ril_error_init_sim_error(err,sw1,sw2) \
|
||||
((err)->error = ((sw1) << 8)|(sw2), (err)->type = OFONO_ERROR_TYPE_SIM)
|
||||
|
||||
#define ril_error_ok(err) (ril_error_init_ok(err), err)
|
||||
#define ril_error_failure(err) (ril_error_init_failure(err), err)
|
||||
#define ril_error_sim(err,sw1,sw2) (ril_error_init_sim_error(err,sw1,sw2), err)
|
||||
|
||||
#endif /* RIL_UTIL_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,164 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_vendor.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
struct ril_vendor_hook *ril_vendor_create_hook
|
||||
(const struct ril_vendor_driver *vendor, GRilIoChannel *io,
|
||||
const char *path, const struct ril_slot_config *config,
|
||||
struct ril_network *network)
|
||||
{
|
||||
if (vendor) {
|
||||
const void *data = vendor->driver_data;
|
||||
|
||||
/*
|
||||
* NOTE: we are looking for the callback in the base but
|
||||
* keeping the original driver data.
|
||||
*/
|
||||
while (!vendor->create_hook && vendor->base) {
|
||||
vendor = vendor->base;
|
||||
}
|
||||
if (vendor->create_hook) {
|
||||
return vendor->create_hook(data, io, path, config,
|
||||
network);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct ril_vendor_hook *ril_vendor_hook_init(struct ril_vendor_hook *self,
|
||||
const struct ril_vendor_hook_proc *proc,
|
||||
ril_vendor_hook_free_proc free)
|
||||
{
|
||||
self->proc = proc;
|
||||
self->free = free;
|
||||
g_atomic_int_set(&self->ref_count, 1);
|
||||
return self;
|
||||
}
|
||||
|
||||
struct ril_vendor_hook *ril_vendor_hook_ref(struct ril_vendor_hook *self)
|
||||
{
|
||||
if (self) {
|
||||
GASSERT(self->ref_count > 0);
|
||||
g_atomic_int_inc(&self->ref_count);
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
static void ril_vendor_hook_free(struct ril_vendor_hook *self)
|
||||
{
|
||||
if (self->free) {
|
||||
self->free(self);
|
||||
}
|
||||
}
|
||||
|
||||
void ril_vendor_hook_unref(struct ril_vendor_hook *self)
|
||||
{
|
||||
if (self) {
|
||||
GASSERT(self->ref_count > 0);
|
||||
if (g_atomic_int_dec_and_test(&self->ref_count)) {
|
||||
ril_vendor_hook_free(self);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ril_vendor_get_defaults(const struct ril_vendor_driver *vendor,
|
||||
struct ril_vendor_defaults *defaults)
|
||||
{
|
||||
if (vendor) {
|
||||
while (!vendor->get_defaults && vendor->base) {
|
||||
vendor = vendor->base;
|
||||
}
|
||||
if (vendor->get_defaults) {
|
||||
vendor->get_defaults(defaults);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char *ril_vendor_hook_request_to_string(struct ril_vendor_hook *self,
|
||||
guint request)
|
||||
{
|
||||
if (self) {
|
||||
const struct ril_vendor_hook_proc *proc = self->proc;
|
||||
|
||||
while (!proc->request_to_string && proc->base) {
|
||||
proc = proc->base;
|
||||
}
|
||||
if (proc->request_to_string) {
|
||||
return proc->request_to_string(self, request);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *ril_vendor_hook_event_to_string(struct ril_vendor_hook *self,
|
||||
guint event)
|
||||
{
|
||||
if (self) {
|
||||
const struct ril_vendor_hook_proc *proc = self->proc;
|
||||
|
||||
while (!proc->event_to_string && proc->base) {
|
||||
proc = proc->base;
|
||||
}
|
||||
if (proc->event_to_string) {
|
||||
return proc->event_to_string(self, event);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GRilIoRequest *ril_vendor_hook_data_call_req(struct ril_vendor_hook *self,
|
||||
int tech, const char *profile, const char *apn,
|
||||
const char *username, const char *password,
|
||||
enum ril_auth auth, const char *proto)
|
||||
{
|
||||
if (self) {
|
||||
const struct ril_vendor_hook_proc *proc = self->proc;
|
||||
|
||||
while (!proc->data_call_req && proc->base) {
|
||||
proc = proc->base;
|
||||
}
|
||||
if (proc->data_call_req) {
|
||||
return proc->data_call_req(self, tech, profile, apn,
|
||||
username, password, auth, proto);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
gboolean ril_vendor_hook_data_call_parse(struct ril_vendor_hook *self,
|
||||
struct ril_data_call *call, int ver, GRilIoParser *rilp)
|
||||
{
|
||||
if (self) {
|
||||
const struct ril_vendor_hook_proc *proc = self->proc;
|
||||
|
||||
while (!proc->data_call_parse && proc->base) {
|
||||
proc = proc->base;
|
||||
}
|
||||
if (proc->data_call_parse) {
|
||||
return proc->data_call_parse(self, call, ver, rilp);
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef RIL_VENDOR_H
|
||||
#define RIL_VENDOR_H
|
||||
|
||||
#include "ril_types.h"
|
||||
|
||||
struct ril_vendor_defaults {
|
||||
gboolean empty_pin_query;
|
||||
gboolean legacy_imei_query;
|
||||
gboolean enable_cbs;
|
||||
gboolean query_available_band_mode;
|
||||
};
|
||||
|
||||
struct ril_vendor_driver {
|
||||
const char *name;
|
||||
const void *driver_data;
|
||||
const struct ril_vendor_driver *base;
|
||||
void (*get_defaults)(struct ril_vendor_defaults *defaults);
|
||||
struct ril_vendor_hook *(*create_hook)(const void *driver_data,
|
||||
GRilIoChannel *io, const char *path,
|
||||
const struct ril_slot_config *cfg,
|
||||
struct ril_network *network);
|
||||
};
|
||||
|
||||
struct ril_vendor_hook_proc {
|
||||
const struct ril_vendor_hook_proc *base;
|
||||
const char *(*request_to_string)(struct ril_vendor_hook *hook,
|
||||
guint request);
|
||||
const char *(*event_to_string)(struct ril_vendor_hook *hook,
|
||||
guint event);
|
||||
GRilIoRequest *(*data_call_req)(struct ril_vendor_hook *hook,
|
||||
int tech, const char *profile, const char *apn,
|
||||
const char *username, const char *password,
|
||||
enum ril_auth auth, const char *proto);
|
||||
gboolean (*data_call_parse)(struct ril_vendor_hook *hook,
|
||||
struct ril_data_call *call, int version,
|
||||
GRilIoParser *rilp);
|
||||
};
|
||||
|
||||
typedef void (*ril_vendor_hook_free_proc)(struct ril_vendor_hook *hook);
|
||||
struct ril_vendor_hook {
|
||||
const struct ril_vendor_hook_proc *proc;
|
||||
ril_vendor_hook_free_proc free;
|
||||
gint ref_count;
|
||||
};
|
||||
|
||||
struct ril_vendor_hook *ril_vendor_create_hook
|
||||
(const struct ril_vendor_driver *vendor, GRilIoChannel *io,
|
||||
const char *path, const struct ril_slot_config *cfg,
|
||||
struct ril_network *network);
|
||||
void ril_vendor_get_defaults(const struct ril_vendor_driver *vendor,
|
||||
struct ril_vendor_defaults *defaults);
|
||||
|
||||
struct ril_vendor_hook *ril_vendor_hook_init(struct ril_vendor_hook *hook,
|
||||
const struct ril_vendor_hook_proc *proc,
|
||||
ril_vendor_hook_free_proc free);
|
||||
struct ril_vendor_hook *ril_vendor_hook_ref(struct ril_vendor_hook *hook);
|
||||
void ril_vendor_hook_unref(struct ril_vendor_hook *hook);
|
||||
|
||||
const char *ril_vendor_hook_request_to_string(struct ril_vendor_hook *hook,
|
||||
guint request);
|
||||
const char *ril_vendor_hook_event_to_string(struct ril_vendor_hook *hook,
|
||||
guint event);
|
||||
GRilIoRequest *ril_vendor_hook_data_call_req(struct ril_vendor_hook *hook,
|
||||
int tech, const char *profile, const char *apn,
|
||||
const char *username, const char *password,
|
||||
enum ril_auth auth, const char *proto);
|
||||
gboolean ril_vendor_hook_data_call_parse(struct ril_vendor_hook *hook,
|
||||
struct ril_data_call *call, int version,
|
||||
GRilIoParser *rilp);
|
||||
|
||||
/* Put vendor driver descriptors to the "__vendor" section */
|
||||
#define RIL_VENDOR_DRIVER_DEFINE(name) \
|
||||
const struct ril_vendor_driver name \
|
||||
__attribute__((used, section("__vendor"))) =
|
||||
#define RIL_VENDOR_DRIVER_FOREACH(var) \
|
||||
for ((var) = __start___vendor; (var) < __stop___vendor; (var)++)
|
||||
extern const struct ril_vendor_driver __start___vendor[];
|
||||
extern const struct ril_vendor_driver __stop___vendor[];
|
||||
|
||||
#endif /* RIL_VENDOR_H */
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
@@ -1,703 +0,0 @@
|
||||
/*
|
||||
* oFono - Open Source Telephony - RIL-based devices
|
||||
*
|
||||
* Copyright (C) 2016-2018 Jolla Ltd.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "ril_plugin.h"
|
||||
#include "ril_vendor.h"
|
||||
#include "ril_network.h"
|
||||
#include "ril_data.h"
|
||||
#include "ril_log.h"
|
||||
|
||||
#include "sailfish_watch.h"
|
||||
|
||||
#include <grilio_channel.h>
|
||||
#include <grilio_parser.h>
|
||||
#include <grilio_request.h>
|
||||
#include <grilio_queue.h>
|
||||
|
||||
#include <gutil_macros.h>
|
||||
#include <gutil_misc.h>
|
||||
|
||||
#include "ofono.h"
|
||||
|
||||
#define SET_INITIAL_ATTACH_APN_TIMEOUT (20*1000)
|
||||
|
||||
enum ril_mtk_watch_events {
|
||||
WATCH_EVENT_IMSI_CHANGED,
|
||||
WATCH_EVENT_COUNT
|
||||
};
|
||||
|
||||
enum ril_mtk_network_events {
|
||||
NETWORK_EVENT_PREF_MODE_CHANGED,
|
||||
NETWORK_EVENT_COUNT
|
||||
};
|
||||
|
||||
enum ril_mtk_events {
|
||||
MTK_EVENT_REGISTRATION_SUSPENDED,
|
||||
MTK_EVENT_SET_ATTACH_APN,
|
||||
MTK_EVENT_PS_NETWORK_STATE_CHANGED,
|
||||
MTK_EVENT_INCOMING_CALL_INDICATION,
|
||||
MTK_EVENT_COUNT
|
||||
};
|
||||
|
||||
struct ril_vendor_hook_mtk {
|
||||
struct ril_vendor_hook hook;
|
||||
const struct ril_mtk_msg *msg;
|
||||
GRilIoQueue *q;
|
||||
GRilIoChannel *io;
|
||||
struct ril_network *network;
|
||||
struct sailfish_watch *watch;
|
||||
guint set_initial_attach_apn_id;
|
||||
gboolean initial_attach_apn_ok;
|
||||
gulong network_event_id[NETWORK_EVENT_COUNT];
|
||||
gulong watch_event_id[WATCH_EVENT_COUNT];
|
||||
gulong ril_event_id[MTK_EVENT_COUNT];
|
||||
guint slot;
|
||||
};
|
||||
|
||||
/* driver_data point this this: */
|
||||
struct ril_vendor_mtk_driver_data {
|
||||
const char *name;
|
||||
const struct ril_mtk_msg *msg;
|
||||
const struct ril_vendor_hook_proc *proc;
|
||||
};
|
||||
|
||||
/* Hook with auto-detection */
|
||||
struct ril_vendor_hook_mtk_auto {
|
||||
struct ril_vendor_hook_mtk mtk;
|
||||
const struct ril_vendor_mtk_driver_data *type;
|
||||
gulong detect_id;
|
||||
};
|
||||
|
||||
/* MTK specific RIL messages (actual codes differ from model to model!) */
|
||||
struct ril_mtk_msg {
|
||||
gboolean attach_apn_has_roaming_protocol;
|
||||
guint request_resume_registration;
|
||||
guint request_set_call_indication;
|
||||
|
||||
/* See ril_vendor_mtk_auto_detect_event */
|
||||
#define unsol_msgs unsol_ps_network_state_changed
|
||||
#define MTK_UNSOL_MSGS (4)
|
||||
|
||||
guint unsol_ps_network_state_changed;
|
||||
guint unsol_registration_suspended;
|
||||
guint unsol_incoming_call_indication;
|
||||
guint unsol_set_attach_apn;
|
||||
};
|
||||
|
||||
static const struct ril_mtk_msg msg_mtk1 = {
|
||||
.attach_apn_has_roaming_protocol = TRUE,
|
||||
.request_resume_registration = 2050,
|
||||
.request_set_call_indication = 2065,
|
||||
.unsol_ps_network_state_changed = 3012,
|
||||
.unsol_registration_suspended = 3021,
|
||||
.unsol_incoming_call_indication = 3037,
|
||||
.unsol_set_attach_apn = 3065
|
||||
};
|
||||
|
||||
static const struct ril_mtk_msg msg_mtk2 = {
|
||||
.attach_apn_has_roaming_protocol = FALSE,
|
||||
.request_resume_registration = 2065,
|
||||
.request_set_call_indication = 2086,
|
||||
.unsol_ps_network_state_changed = 3015,
|
||||
.unsol_registration_suspended = 3024,
|
||||
.unsol_incoming_call_indication = 3042,
|
||||
.unsol_set_attach_apn = 3073
|
||||
};
|
||||
|
||||
static inline struct ril_vendor_hook_mtk *ril_vendor_hook_mtk_cast
|
||||
(struct ril_vendor_hook *hook)
|
||||
{
|
||||
return G_CAST(hook, struct ril_vendor_hook_mtk, hook);
|
||||
}
|
||||
|
||||
static inline struct ril_vendor_hook_mtk_auto *ril_vendor_hook_mtk_auto_cast
|
||||
(struct ril_vendor_hook *hook)
|
||||
{
|
||||
return G_CAST(hook, struct ril_vendor_hook_mtk_auto, mtk.hook);
|
||||
}
|
||||
|
||||
static const char *ril_vendor_mtk_request_to_string
|
||||
(struct ril_vendor_hook *hook, guint request)
|
||||
{
|
||||
struct ril_vendor_hook_mtk *self = ril_vendor_hook_mtk_cast(hook);
|
||||
const struct ril_mtk_msg *msg = self->msg;
|
||||
|
||||
if (request == msg->request_resume_registration) {
|
||||
return "MTK_RESUME_REGISTRATION";
|
||||
} else if (request == msg->request_set_call_indication) {
|
||||
return "MTK_SET_CALL_INDICATION";
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static const char *ril_vendor_mtk_unsol_msg_name(const struct ril_mtk_msg *msg,
|
||||
guint event)
|
||||
{
|
||||
if (event == msg->unsol_ps_network_state_changed) {
|
||||
return "MTK_PS_NETWORK_STATE_CHANGED";
|
||||
} else if (event == msg->unsol_registration_suspended) {
|
||||
return "MTK_REGISTRATION_SUSPENDED";
|
||||
} else if (event == msg->unsol_set_attach_apn) {
|
||||
return "MTK_SET_ATTACH_APN";
|
||||
} else if (event == msg->unsol_incoming_call_indication) {
|
||||
return "MTK_INCOMING_CALL_INDICATION";
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static const char *ril_vendor_mtk_event_to_string(struct ril_vendor_hook *hook,
|
||||
guint event)
|
||||
{
|
||||
struct ril_vendor_hook_mtk *self = ril_vendor_hook_mtk_cast(hook);
|
||||
|
||||
return ril_vendor_mtk_unsol_msg_name(self->msg, event);
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_registration_suspended(GRilIoChannel *io, guint id,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_vendor_hook_mtk *self = user_data;
|
||||
const struct ril_mtk_msg *msg = self->msg;
|
||||
GRilIoParser rilp;
|
||||
int session_id;
|
||||
|
||||
GASSERT(id == msg->unsol_registration_suspended);
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
if (grilio_parser_get_int32(&rilp, NULL) &&
|
||||
grilio_parser_get_int32(&rilp, &session_id)) {
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
DBG("slot=%u,session_id=%d", self->slot, session_id);
|
||||
grilio_request_append_int32(req, 1);
|
||||
grilio_request_append_int32(req, session_id);
|
||||
grilio_queue_send_request(self->q, req,
|
||||
msg->request_resume_registration);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
}
|
||||
|
||||
static GRilIoRequest *ril_vendor_mtk_build_set_attach_apn_req
|
||||
(const struct ofono_gprs_primary_context *pc,
|
||||
gboolean roamingProtocol)
|
||||
{
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
const char *proto = ril_data_ofono_protocol_to_ril(pc->proto);
|
||||
|
||||
DBG("%s %d", pc->apn, roamingProtocol);
|
||||
grilio_request_append_utf8(req, pc->apn); /* apn */
|
||||
grilio_request_append_utf8(req, proto); /* protocol */
|
||||
if (roamingProtocol) {
|
||||
grilio_request_append_utf8(req, proto); /* roamingProtocol */
|
||||
}
|
||||
|
||||
if (pc->username[0]) {
|
||||
int auth;
|
||||
|
||||
switch (pc->auth_method) {
|
||||
case OFONO_GPRS_AUTH_METHOD_ANY:
|
||||
auth = RIL_AUTH_BOTH;
|
||||
break;
|
||||
case OFONO_GPRS_AUTH_METHOD_NONE:
|
||||
auth = RIL_AUTH_NONE;
|
||||
break;
|
||||
case OFONO_GPRS_AUTH_METHOD_CHAP:
|
||||
auth = RIL_AUTH_CHAP;
|
||||
break;
|
||||
case OFONO_GPRS_AUTH_METHOD_PAP:
|
||||
auth = RIL_AUTH_PAP;
|
||||
break;
|
||||
default:
|
||||
auth = RIL_AUTH_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
grilio_request_append_int32(req, auth);
|
||||
grilio_request_append_utf8(req, pc->username);
|
||||
grilio_request_append_utf8(req, pc->password);
|
||||
} else {
|
||||
grilio_request_append_int32(req, RIL_AUTH_NONE);
|
||||
grilio_request_append_utf8(req, "");
|
||||
grilio_request_append_utf8(req, "");
|
||||
}
|
||||
|
||||
grilio_request_append_utf8(req, ""); /* operatorNumeric */
|
||||
grilio_request_append_int32(req, FALSE); /* canHandleIms */
|
||||
grilio_request_append_int32(req, -1); /* dualApnPlmnList */
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
static const struct ofono_gprs_primary_context *ril_vendor_mtk_internet_context
|
||||
(struct ril_vendor_hook_mtk *self)
|
||||
{
|
||||
struct sailfish_watch *watch = self->watch;
|
||||
|
||||
if (watch->imsi) {
|
||||
struct ofono_atom *atom = __ofono_modem_find_atom(watch->modem,
|
||||
OFONO_ATOM_TYPE_GPRS);
|
||||
|
||||
if (atom) {
|
||||
return __ofono_gprs_context_settings_by_type
|
||||
(__ofono_atom_get_data(atom),
|
||||
OFONO_GPRS_CONTEXT_TYPE_INTERNET);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_initial_attach_apn_resp(GRilIoChannel *io,
|
||||
int ril_status, const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_vendor_hook_mtk *self = user_data;
|
||||
|
||||
GASSERT(self->set_initial_attach_apn_id);
|
||||
self->set_initial_attach_apn_id = 0;
|
||||
if (ril_status == RIL_E_SUCCESS) {
|
||||
DBG("ok");
|
||||
self->initial_attach_apn_ok = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_initial_attach_apn_check
|
||||
(struct ril_vendor_hook_mtk *self)
|
||||
{
|
||||
|
||||
if (!self->set_initial_attach_apn_id && !self->initial_attach_apn_ok) {
|
||||
const struct ofono_gprs_primary_context *pc =
|
||||
ril_vendor_mtk_internet_context(self);
|
||||
|
||||
if (pc) {
|
||||
GRilIoRequest *req =
|
||||
ril_vendor_mtk_build_set_attach_apn_req(pc,
|
||||
self->msg->attach_apn_has_roaming_protocol);
|
||||
|
||||
grilio_request_set_timeout(req,
|
||||
SET_INITIAL_ATTACH_APN_TIMEOUT);
|
||||
self->set_initial_attach_apn_id =
|
||||
grilio_queue_send_request_full(self->q, req,
|
||||
RIL_REQUEST_SET_INITIAL_ATTACH_APN,
|
||||
ril_vendor_mtk_initial_attach_apn_resp,
|
||||
NULL, self);
|
||||
grilio_request_unref(req);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_initial_attach_apn_reset
|
||||
(struct ril_vendor_hook_mtk *self)
|
||||
{
|
||||
self->initial_attach_apn_ok = FALSE;
|
||||
if (self->set_initial_attach_apn_id) {
|
||||
grilio_queue_cancel_request(self->q,
|
||||
self->set_initial_attach_apn_id, FALSE);
|
||||
self->set_initial_attach_apn_id = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_watch_imsi_changed(struct sailfish_watch *watch,
|
||||
void *user_data)
|
||||
{
|
||||
struct ril_vendor_hook_mtk *self = user_data;
|
||||
|
||||
if (watch->imsi) {
|
||||
ril_vendor_mtk_initial_attach_apn_check(self);
|
||||
} else {
|
||||
ril_vendor_mtk_initial_attach_apn_reset(self);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_network_pref_mode_changed(struct ril_network *net,
|
||||
void *user_data)
|
||||
{
|
||||
struct ril_vendor_hook_mtk *self = user_data;
|
||||
|
||||
if (net->pref_mode >= OFONO_RADIO_ACCESS_MODE_LTE) {
|
||||
ril_vendor_mtk_initial_attach_apn_check(self);
|
||||
} else {
|
||||
ril_vendor_mtk_initial_attach_apn_reset(self);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_set_attach_apn(GRilIoChannel *io, guint id,
|
||||
const void *data, guint len, void *self)
|
||||
{
|
||||
ril_vendor_mtk_initial_attach_apn_check(self);
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_ps_network_state_changed(GRilIoChannel *io,
|
||||
guint id, const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_vendor_hook_mtk *self = user_data;
|
||||
|
||||
ril_network_query_registration_state(self->network);
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_incoming_call_indication(GRilIoChannel *io, guint id,
|
||||
const void *data, guint len, void *user_data)
|
||||
{
|
||||
struct ril_vendor_hook_mtk *self = user_data;
|
||||
const struct ril_mtk_msg *msg = self->msg;
|
||||
GRilIoRequest* req = NULL;
|
||||
|
||||
GASSERT(id == msg->unsol_incoming_call_indication);
|
||||
|
||||
if (msg->request_set_call_indication) {
|
||||
int nparams, cid, seq;
|
||||
gchar *call_id = NULL, *seq_no = NULL;
|
||||
GRilIoParser rilp;
|
||||
|
||||
grilio_parser_init(&rilp, data, len);
|
||||
|
||||
if (grilio_parser_get_int32(&rilp, &nparams) && nparams >= 5 &&
|
||||
(call_id = grilio_parser_get_utf8(&rilp)) != NULL &&
|
||||
grilio_parser_skip_string(&rilp) /* number */ &&
|
||||
grilio_parser_skip_string(&rilp) /* type */ &&
|
||||
grilio_parser_skip_string(&rilp) /* call_mode */ &&
|
||||
(seq_no = grilio_parser_get_utf8(&rilp)) != NULL &&
|
||||
gutil_parse_int(call_id, 10, &cid) &&
|
||||
gutil_parse_int(seq_no, 10, &seq)) {
|
||||
|
||||
DBG("slot=%u,cid=%d,seq=%d", self->slot, cid, seq);
|
||||
req = grilio_request_new();
|
||||
grilio_request_append_int32(req, 3); /* Param count */
|
||||
/* mode - IMS_ALLOW_INCOMING_CALL_INDICATION: */
|
||||
grilio_request_append_int32(req, 0);
|
||||
grilio_request_append_int32(req, cid);
|
||||
grilio_request_append_int32(req, seq);
|
||||
} else {
|
||||
DBG("failed to parse INCOMING_CALL_INDICATION");
|
||||
}
|
||||
|
||||
g_free(call_id);
|
||||
g_free(seq_no);
|
||||
}
|
||||
|
||||
if (req) {
|
||||
grilio_queue_send_request(self->q, req,
|
||||
msg->request_set_call_indication);
|
||||
grilio_request_unref(req);
|
||||
} else {
|
||||
/* Let ril_voicecall.c know that something happened */
|
||||
grilio_channel_inject_unsol_event(io,
|
||||
RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED, NULL, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static GRilIoRequest *ril_vendor_mtk_data_call_req
|
||||
(struct ril_vendor_hook *hook, int tech, const char *profile,
|
||||
const char *apn, const char *username, const char *password,
|
||||
enum ril_auth auth, const char *proto)
|
||||
{
|
||||
struct ril_vendor_hook_mtk *self = ril_vendor_hook_mtk_cast(hook);
|
||||
GRilIoRequest *req = grilio_request_new();
|
||||
|
||||
grilio_request_append_int32(req, 8); /* Number of parameters */
|
||||
grilio_request_append_format(req, "%d", tech);
|
||||
grilio_request_append_utf8(req, profile);
|
||||
grilio_request_append_utf8(req, apn);
|
||||
grilio_request_append_utf8(req, username);
|
||||
grilio_request_append_utf8(req, password);
|
||||
grilio_request_append_format(req, "%d", auth);
|
||||
grilio_request_append_utf8(req, proto);
|
||||
grilio_request_append_format(req, "%d", self->slot+1);
|
||||
return req;
|
||||
}
|
||||
|
||||
static gboolean ril_vendor_mtk_data_call_parse_v6(struct ril_vendor_hook *hook,
|
||||
struct ril_data_call *call, int version,
|
||||
GRilIoParser *rilp)
|
||||
{
|
||||
if (version < 11) {
|
||||
int prot;
|
||||
char *prot_str;
|
||||
guint32 status = PDP_FAIL_ERROR_UNSPECIFIED;
|
||||
guint32 active = RIL_DATA_CALL_INACTIVE;
|
||||
|
||||
/* RIL_Data_Call_Response_v6 with MTK specific additions */
|
||||
grilio_parser_get_uint32(rilp, &status);
|
||||
grilio_parser_get_int32(rilp, &call->retry_time);
|
||||
grilio_parser_get_int32(rilp, &call->cid);
|
||||
grilio_parser_get_uint32(rilp, &active);
|
||||
grilio_parser_get_int32(rilp, &call->mtu); /* MTK specific */
|
||||
prot_str = grilio_parser_get_utf8(rilp);
|
||||
prot = ril_data_protocol_to_ofono(prot_str);
|
||||
g_free(prot_str);
|
||||
|
||||
if (prot >= 0) {
|
||||
call->ifname = grilio_parser_get_utf8(rilp);
|
||||
call->addresses = grilio_parser_split_utf8(rilp, " ");
|
||||
call->dnses = grilio_parser_split_utf8(rilp, " ");
|
||||
call->gateways = grilio_parser_split_utf8(rilp, " ");
|
||||
if (call->ifname && call->addresses) {
|
||||
call->prot = prot;
|
||||
call->status = status;
|
||||
call->active = active;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_get_defaults(struct ril_vendor_defaults *defaults)
|
||||
{
|
||||
/*
|
||||
* With most Qualcomm RIL implementations, querying available band
|
||||
* modes causes some magic Android properties to appear. Otherwise
|
||||
* this request is pretty harmless and useless.
|
||||
*
|
||||
* Most MediaTek RIL implementations don't support this request and
|
||||
* don't even bother to reply which slows things down because we wait
|
||||
* for this request to complete at startup.
|
||||
*/
|
||||
defaults->query_available_band_mode = FALSE;
|
||||
defaults->empty_pin_query = FALSE;
|
||||
defaults->legacy_imei_query = TRUE;
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_hook_subscribe(struct ril_vendor_hook_mtk *self)
|
||||
{
|
||||
const struct ril_mtk_msg *msg = self->msg;
|
||||
|
||||
self->ril_event_id[MTK_EVENT_REGISTRATION_SUSPENDED] =
|
||||
grilio_channel_add_unsol_event_handler(self->io,
|
||||
ril_vendor_mtk_registration_suspended,
|
||||
msg->unsol_registration_suspended, self);
|
||||
if (msg->unsol_set_attach_apn) {
|
||||
self->ril_event_id[MTK_EVENT_SET_ATTACH_APN] =
|
||||
grilio_channel_add_unsol_event_handler(self->io,
|
||||
ril_vendor_mtk_set_attach_apn,
|
||||
msg->unsol_set_attach_apn, self);
|
||||
}
|
||||
if (msg->unsol_ps_network_state_changed) {
|
||||
self->ril_event_id[MTK_EVENT_PS_NETWORK_STATE_CHANGED] =
|
||||
grilio_channel_add_unsol_event_handler(self->io,
|
||||
ril_vendor_mtk_ps_network_state_changed,
|
||||
msg->unsol_ps_network_state_changed, self);
|
||||
}
|
||||
if (msg->unsol_incoming_call_indication) {
|
||||
self->ril_event_id[MTK_EVENT_INCOMING_CALL_INDICATION] =
|
||||
grilio_channel_add_unsol_event_handler(self->io,
|
||||
ril_vendor_mtk_incoming_call_indication,
|
||||
msg->unsol_incoming_call_indication, self);
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_hook_init(struct ril_vendor_hook_mtk *self,
|
||||
const struct ril_vendor_mtk_driver_data *mtk_driver_data,
|
||||
ril_vendor_hook_free_proc free, GRilIoChannel *io, const char *path,
|
||||
const struct ril_slot_config *config, struct ril_network *network)
|
||||
{
|
||||
self->msg = mtk_driver_data->msg;
|
||||
self->q = grilio_queue_new(io);
|
||||
self->io = grilio_channel_ref(io);
|
||||
self->watch = sailfish_watch_new(path);
|
||||
self->slot = config->slot;
|
||||
self->network = ril_network_ref(network);
|
||||
self->watch_event_id[WATCH_EVENT_IMSI_CHANGED] =
|
||||
sailfish_watch_add_imsi_changed_handler(self->watch,
|
||||
ril_vendor_mtk_watch_imsi_changed, self);
|
||||
self->network_event_id[NETWORK_EVENT_PREF_MODE_CHANGED] =
|
||||
ril_network_add_pref_mode_changed_handler(self->network,
|
||||
ril_vendor_mtk_network_pref_mode_changed, self);
|
||||
ril_vendor_mtk_hook_subscribe(self);
|
||||
ril_vendor_hook_init(&self->hook, mtk_driver_data->proc, free);
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_destroy(struct ril_vendor_hook_mtk *self)
|
||||
{
|
||||
grilio_queue_cancel_all(self->q, FALSE);
|
||||
grilio_channel_remove_all_handlers(self->io, self->ril_event_id);
|
||||
grilio_queue_unref(self->q);
|
||||
grilio_channel_unref(self->io);
|
||||
sailfish_watch_remove_all_handlers(self->watch, self->watch_event_id);
|
||||
sailfish_watch_unref(self->watch);
|
||||
ril_network_remove_all_handlers(self->network, self->network_event_id);
|
||||
ril_network_unref(self->network);
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_free(struct ril_vendor_hook *hook)
|
||||
{
|
||||
struct ril_vendor_hook_mtk *self = ril_vendor_hook_mtk_cast(hook);
|
||||
|
||||
DBG("slot %u", self->slot);
|
||||
ril_vendor_mtk_destroy(self);
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
static struct ril_vendor_hook *ril_vendor_mtk_create_hook_from_data
|
||||
(const void *driver_data, GRilIoChannel *io, const char *path,
|
||||
const struct ril_slot_config *config,
|
||||
struct ril_network *network)
|
||||
{
|
||||
const struct ril_vendor_mtk_driver_data *mtk_driver_data = driver_data;
|
||||
struct ril_vendor_hook_mtk *self =
|
||||
g_new0(struct ril_vendor_hook_mtk, 1);
|
||||
|
||||
ril_vendor_mtk_hook_init(self, mtk_driver_data, ril_vendor_mtk_free,
|
||||
io, path, config, network);
|
||||
DBG("%s slot %u", mtk_driver_data->name, self->slot);
|
||||
return &self->hook;
|
||||
}
|
||||
|
||||
static const struct ril_vendor_hook_proc ril_vendor_mtk_hook_base_proc = {
|
||||
.request_to_string = ril_vendor_mtk_request_to_string,
|
||||
.event_to_string = ril_vendor_mtk_event_to_string,
|
||||
.data_call_req = ril_vendor_mtk_data_call_req
|
||||
};
|
||||
|
||||
static const struct ril_vendor_driver ril_vendor_mtk_base = {
|
||||
.get_defaults = ril_vendor_mtk_get_defaults,
|
||||
.create_hook = ril_vendor_mtk_create_hook_from_data
|
||||
};
|
||||
|
||||
static const struct ril_vendor_mtk_driver_data ril_vendor_mtk1_data = {
|
||||
.name = "mtk1",
|
||||
.msg = &msg_mtk1,
|
||||
.proc = &ril_vendor_mtk_hook_base_proc
|
||||
};
|
||||
|
||||
static struct ril_vendor_hook_proc ril_vendor_mtk2_proc = {
|
||||
.base = &ril_vendor_mtk_hook_base_proc,
|
||||
.data_call_parse = ril_vendor_mtk_data_call_parse_v6
|
||||
};
|
||||
|
||||
static const struct ril_vendor_mtk_driver_data ril_vendor_mtk2_data = {
|
||||
.name = "mtk2",
|
||||
.msg = &msg_mtk2,
|
||||
.proc = &ril_vendor_mtk2_proc
|
||||
};
|
||||
|
||||
#define DEFAULT_MTK_TYPE (&ril_vendor_mtk1_data)
|
||||
|
||||
static const struct ril_vendor_mtk_driver_data *mtk_types [] = {
|
||||
&ril_vendor_mtk1_data,
|
||||
&ril_vendor_mtk2_data
|
||||
};
|
||||
|
||||
RIL_VENDOR_DRIVER_DEFINE(ril_vendor_driver_mtk1) {
|
||||
.name = "mtk1",
|
||||
.driver_data = &ril_vendor_mtk1_data,
|
||||
.base = &ril_vendor_mtk_base
|
||||
};
|
||||
|
||||
RIL_VENDOR_DRIVER_DEFINE(ril_vendor_driver_mtk2) {
|
||||
.name = "mtk2",
|
||||
.driver_data = &ril_vendor_mtk2_data,
|
||||
.base = &ril_vendor_mtk_base
|
||||
};
|
||||
|
||||
/* Auto-selection */
|
||||
|
||||
static gboolean ril_vendor_mtk_auto_set_type
|
||||
(struct ril_vendor_hook_mtk_auto *self,
|
||||
const struct ril_vendor_mtk_driver_data *type)
|
||||
{
|
||||
struct ril_vendor_hook_mtk *mtk = &self->mtk;
|
||||
gboolean changed = FALSE;
|
||||
|
||||
if (self->type != type) {
|
||||
DBG("switching type %s -> %s", self->type->name, type->name);
|
||||
self->type = type;
|
||||
mtk->msg = type->msg;
|
||||
mtk->hook.proc = type->proc;
|
||||
grilio_channel_remove_all_handlers(mtk->io, mtk->ril_event_id);
|
||||
ril_vendor_mtk_hook_subscribe(mtk);
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
grilio_channel_remove_handler(mtk->io, self->detect_id);
|
||||
self->detect_id = 0;
|
||||
return changed;
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_auto_detect_event(GRilIoChannel *io, guint id,
|
||||
const void *data, guint len, void *self)
|
||||
{
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS(mtk_types); i++) {
|
||||
const struct ril_vendor_mtk_driver_data *type = mtk_types[i];
|
||||
const struct ril_mtk_msg *msg = type->msg;
|
||||
const guint *ids = &msg->unsol_msgs;
|
||||
guint j;
|
||||
|
||||
for (j = 0; j < MTK_UNSOL_MSGS; j++) {
|
||||
if (ids[j] == id) {
|
||||
DBG("event %u is %s %s", id, type->name,
|
||||
ril_vendor_mtk_unsol_msg_name(msg,id));
|
||||
if (ril_vendor_mtk_auto_set_type(self, type)) {
|
||||
/* And repeat the event to invoke
|
||||
* the handler */
|
||||
grilio_channel_inject_unsol_event(io,
|
||||
id, data, len);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void ril_vendor_mtk_auto_free(struct ril_vendor_hook *hook)
|
||||
{
|
||||
struct ril_vendor_hook_mtk_auto *self =
|
||||
ril_vendor_hook_mtk_auto_cast(hook);
|
||||
struct ril_vendor_hook_mtk *mtk = &self->mtk;
|
||||
|
||||
DBG("slot %u", mtk->slot);
|
||||
grilio_channel_remove_handler(mtk->io, self->detect_id);
|
||||
ril_vendor_mtk_destroy(mtk);
|
||||
g_free(self);
|
||||
}
|
||||
|
||||
static struct ril_vendor_hook *ril_vendor_mtk_create_hook_auto
|
||||
(const void *driver_data, GRilIoChannel *io, const char *path,
|
||||
const struct ril_slot_config *cfg, struct ril_network *network)
|
||||
{
|
||||
struct ril_vendor_hook_mtk_auto *self =
|
||||
g_new0(struct ril_vendor_hook_mtk_auto, 1);
|
||||
struct ril_vendor_hook_mtk *mtk = &self->mtk;
|
||||
|
||||
/* Pick the default */
|
||||
self->type = DEFAULT_MTK_TYPE;
|
||||
ril_vendor_mtk_hook_init(mtk, self->type, ril_vendor_mtk_auto_free,
|
||||
io, path, cfg, network);
|
||||
DBG("%s slot %u", self->type->name, mtk->slot);
|
||||
|
||||
/*
|
||||
* Subscribe for (all) unsolicited events. Keep on listening until
|
||||
* we receive an MTK specific event that tells us which particular
|
||||
* kind of MTK adaptation we are using.
|
||||
*/
|
||||
self->detect_id = grilio_channel_add_unsol_event_handler(mtk->io,
|
||||
ril_vendor_mtk_auto_detect_event, 0, self);
|
||||
return &mtk->hook;
|
||||
}
|
||||
|
||||
RIL_VENDOR_DRIVER_DEFINE(ril_vendor_driver_mtk) {
|
||||
.name = "mtk",
|
||||
.get_defaults = ril_vendor_mtk_get_defaults,
|
||||
.create_hook = ril_vendor_mtk_create_hook_auto
|
||||
};
|
||||
|
||||
/*
|
||||
* Local Variables:
|
||||
* mode: C
|
||||
* c-basic-offset: 8
|
||||
* indent-tabs-mode: t
|
||||
* End:
|
||||
*/
|
||||
File diff suppressed because it is too large
Load Diff
@@ -38,6 +38,8 @@
|
||||
#include <ofono/call-forwarding.h>
|
||||
#include "common.h"
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wrestrict"
|
||||
|
||||
#include "gril.h"
|
||||
|
||||
#include "rilmodem.h"
|
||||
|
||||
@@ -108,7 +108,8 @@ static gboolean lte_delayed_register(gpointer user_data)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int ril_lte_probe(struct ofono_lte *lte, void *user_data)
|
||||
static int ril_lte_probe(struct ofono_lte *lte,
|
||||
unsigned int vendor, void *user_data)
|
||||
{
|
||||
GRil *ril = user_data;
|
||||
struct ril_lte_data *ld;
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
#include <ofono/modem.h>
|
||||
#include <ofono/netreg.h>
|
||||
|
||||
#pragma GCC diagnostic ignored "-Wrestrict"
|
||||
|
||||
#include <gril/gril.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user