1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
/*
* uqmi -- tiny QMI support implementation
*
* Copyright (C) 2023 Alexander Couzens <lynxis@fe80.eu>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA.
*/
/* Used by uqmid to contain the modem state */
#include <stdint.h>
#include <talloc.h>
#include "qmi-struct.h"
#include "qmi-enums.h"
#include "qmi-message.h"
#include "qmi-enums-uim.h"
#include "logging.h"
#include "utils.h"
#include "modem.h"
#include "services.h"
#include "modem_fsm.h"
#include "modem_tx.h"
int tx_dms_set_operating_mode(struct modem *modem, struct qmi_service *dms, uint8_t operating_mode, request_cb cb)
{
struct qmi_request *req = talloc_zero(dms, struct qmi_request);
struct qmi_msg *msg = talloc_zero_size(req, 1024);
struct qmi_dms_set_operating_mode_request set_op_mode_req = { QMI_INIT(mode, operating_mode) };
int ret = qmi_set_dms_set_operating_mode_request(msg, &set_op_mode_req);
if (ret) {
LOG_ERROR("Failed to encode get version info");
return 1;
}
req->msg = msg;
req->cb = cb;
req->cb_data = modem;
return uqmi_service_send_msg(dms, req);
}
int tx_nas_subscribe_nas_events(struct modem *modem, struct qmi_service *nas, bool action, request_cb cb)
{
struct qmi_request *req = talloc_zero(nas, struct qmi_request);
struct qmi_msg *msg = talloc_zero_size(req, 1024);
struct qmi_nas_register_indications_request register_req = {};
qmi_set(®ister_req, serving_system_events, action);
qmi_set(®ister_req, subscription_info, action);
qmi_set(®ister_req, system_info, action);
qmi_set(®ister_req, signal_info, action);
register_req.set.network_reject_information = 1;
register_req.data.network_reject_information.enable_network_reject_indications = action;
int ret = qmi_set_nas_register_indications_request(msg, ®ister_req);
if (ret) {
LOG_ERROR("Failed to encode get version info");
return 1;
}
req->msg = msg;
req->cb = cb;
req->cb_data = modem;
return uqmi_service_send_msg(nas, req);
}
int tx_wds_get_profile_list(struct modem *modem, struct qmi_service *wds, request_cb cb)
{
struct qmi_request *req = talloc_zero(wds, struct qmi_request);
struct qmi_msg *msg = talloc_zero_size(req, 1024);
struct qmi_wds_get_profile_list_request profile_req = { QMI_INIT(profile_type, QMI_WDS_PROFILE_TYPE_3GPP) };
int ret = qmi_set_wds_get_profile_list_request(msg, &profile_req);
if (ret) {
LOG_ERROR("Failed to encode get profile list");
return 1;
}
req->msg = msg;
req->cb = cb;
req->cb_data = modem;
return uqmi_service_send_msg(wds, req);
}
int tx_wds_modify_profile(struct modem *modem, struct qmi_service *wds, request_cb cb, uint8_t profile, const char *apn,
uint8_t pdp_type)
{
struct qmi_request *req = talloc_zero(wds, struct qmi_request);
struct qmi_msg *msg = talloc_zero_size(req, 1024);
struct qmi_wds_modify_profile_request profile_req = {};
profile_req.set.profile_identifier = 1;
profile_req.data.profile_identifier.profile_type = QMI_WDS_PROFILE_TYPE_3GPP;
profile_req.data.profile_identifier.profile_index = profile;
qmi_set(&profile_req, pdp_type, pdp_type);
if (apn)
profile_req.data.apn_name = (char *) apn;
int ret = qmi_set_wds_modify_profile_request(msg, &profile_req);
if (ret) {
LOG_ERROR("Failed to encode get profile list");
return 1;
}
req->msg = msg;
req->cb = cb;
req->cb_data = modem;
return uqmi_service_send_msg(wds, req);
}
int tx_wds_start_network(struct modem *modem, struct qmi_service *wds, request_cb cb, uint8_t profile_idx,
uint8_t ip_family)
{
struct qmi_request *req = talloc_zero(wds, struct qmi_request);
struct qmi_msg *msg = talloc_zero_size(req, 1024);
struct qmi_wds_start_network_request start_req = {};
qmi_set(&start_req, profile_index_3gpp, profile_idx);
qmi_set(&start_req, ip_family_preference, ip_family);
int ret = qmi_set_wds_start_network_request(msg, &start_req);
if (ret) {
LOG_ERROR("Failed to encode start network request");
return 1;
}
req->msg = msg;
req->cb = cb;
req->cb_data = modem;
return uqmi_service_send_msg(wds, req);
}
int tx_wds_get_current_settings(struct modem *modem, struct qmi_service *wds, request_cb cb)
{
struct qmi_request *req = talloc_zero(wds, struct qmi_request);
struct qmi_msg *msg = talloc_zero_size(req, 1024);
struct qmi_wds_get_current_settings_request get_settings_req = {};
qmi_set(&get_settings_req, requested_settings,
QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_PDP_TYPE |
QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_DNS_ADDRESS |
QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_GRANTED_QOS |
QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_IP_ADDRESS |
QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_GATEWAY_INFO |
QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_MTU |
QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_DOMAIN_NAME_LIST |
QMI_WDS_GET_CURRENT_SETTINGS_REQUESTED_SETTINGS_IP_FAMILY);
int ret = qmi_set_wds_get_current_settings_request(msg, &get_settings_req);
if (ret) {
LOG_ERROR("Failed to encode start network request");
return 1;
}
req->msg = msg;
req->cb = cb;
req->cb_data = modem;
return uqmi_service_send_msg(wds, req);
}
|