~rsalveti/phablet-extras/ofono-imei-revision

« back to all changes in this revision

Viewing changes to drivers/rilmodem/sms.c

  • Committer: Tarmac
  • Author(s): Tony Espy
  • Date: 2013-06-15 00:02:41 UTC
  • mfrom: (38.2.13 ofono-debug-refactor)
  • Revision ID: tarmac-20130615000241-n6lmwvw9gpw80gsx
[gril/rilmodem] Add conditional build-time logic to RIL command tracing, and low-level gril logging.

Approved by Ricardo Salveti, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
119
119
        struct cb_data *cbd = user_data;
120
120
        struct ofono_error error;
121
121
        ofono_sms_submit_cb_t cb = cbd->cb;
 
122
        struct sms_data *sd = cbd->user;
122
123
        int mr;
123
124
 
124
125
        if (message->error == RIL_E_SUCCESS) {
127
128
                decode_ril_error(&error, "FAIL");
128
129
        }
129
130
 
130
 
        mr = ril_util_parse_sms_response(message);
 
131
        mr = ril_util_parse_sms_response(sd->ril, message);
131
132
 
132
133
        cb(&error, mr, cbd->data);
133
134
}
136
137
                        int pdu_len, int tpdu_len, int mms,
137
138
                        ofono_sms_submit_cb_t cb, void *user_data)
138
139
{
139
 
        struct sms_data *data = ofono_sms_get_data(sms);
 
140
        struct sms_data *sd = ofono_sms_get_data(sms);
140
141
        struct cb_data *cbd = cb_data_new(cb, user_data);
141
142
        struct parcel rilp;
142
143
        char *tpdu;
 
144
        int request = RIL_REQUEST_SEND_SMS;
143
145
        int ret, smsc_len;
144
146
 
 
147
        cbd->user = sd;
 
148
 
145
149
        DBG("pdu_len: %d, tpdu_len: %d mms: %d", pdu_len, tpdu_len, mms);
146
 
        g_ril_util_debug_hexdump(FALSE, pdu, pdu_len, sms_debug, "sms-pdu: ");
147
150
 
148
151
        /* TODO: if (mms) { ... } */
149
152
 
171
174
         *  parcel_w_string() encodes utf8 -> utf16
172
175
         */
173
176
        tpdu = encode_hex(pdu + smsc_len, tpdu_len, 0);
174
 
        g_ril_util_debug_hexdump(FALSE, (guchar *) tpdu, (tpdu_len * 2),
175
 
                                        sms_debug, "tpdu: ");
176
 
 
177
177
        parcel_w_string(&rilp, tpdu);
178
178
 
179
 
        /* Dump the entire parcel */
180
 
        g_ril_util_debug_hexdump(FALSE, (guchar *) rilp.data, rilp.size,
181
 
                                        sms_debug, "sms-encoded-buf: ");
182
 
        ret = g_ril_send(data->ril,
183
 
                        RIL_REQUEST_SEND_SMS,
184
 
                        rilp.data,
185
 
                        rilp.size,
186
 
                        submit_sms_cb, cbd, g_free);
 
179
        ret = g_ril_send(sd->ril,
 
180
                                request,
 
181
                                rilp.data,
 
182
                                rilp.size,
 
183
                                submit_sms_cb, cbd, g_free);
 
184
 
 
185
        g_ril_append_print_buf(sd->ril, "(%s)", tpdu);
 
186
        g_ril_print_request(sd->ril, ret, request);
187
187
 
188
188
        parcel_free(&rilp);
189
189
 
190
190
        if (ret <= 0) {
191
191
                g_free(cbd);
192
 
                CALLBACK_WITH_FAILURE(cb, -1, data);
 
192
                CALLBACK_WITH_FAILURE(cb, -1, user_data);
193
193
        }
194
194
}
195
195
 
214
214
static void ril_sms_notify(struct ril_msg *message, gpointer user_data)
215
215
{
216
216
        struct ofono_sms *sms = user_data;
217
 
        struct sms_data *data = ofono_sms_get_data(sms);
 
217
        struct sms_data *sd = ofono_sms_get_data(sms);
218
218
        struct parcel rilp;
219
219
        char *ril_pdu;
220
220
        int ril_pdu_len;
221
221
        unsigned int smsc_len;
222
222
        long ril_buf_len;
223
223
        guchar *ril_data;
 
224
        int request = RIL_REQUEST_SMS_ACKNOWLEDGE;
 
225
        int ret;
224
226
 
225
227
        DBG("req: %d; data_len: %d", message->req, message->buf_len);
226
228
 
227
229
        if (message->req != RIL_UNSOL_RESPONSE_NEW_SMS)
228
230
                goto error;
229
231
 
230
 
        /* Set up Parcel struct for proper parsing */
231
 
        rilp.data = message->buf;
232
 
        rilp.size = message->buf_len;
233
 
        rilp.capacity = message->buf_len;
234
 
        rilp.offset = 0;
235
232
 
236
 
        g_ril_util_debug_hexdump(FALSE, (guchar *) message->buf,
237
 
                message->buf_len, sms_debug, "sms-notify: ");
 
233
        ril_util_init_parcel(message, &rilp);
238
234
 
239
235
        ril_pdu = parcel_r_string(&rilp);
240
236
        if (ril_pdu == NULL)
247
243
        if (ril_data == NULL)
248
244
                goto error;
249
245
 
250
 
        g_ril_util_debug_hexdump(FALSE, ril_data,
251
 
                                        ril_buf_len,
252
 
                                        sms_debug,
253
 
                                        "sms-notify-decoded: ");
254
 
 
255
 
    /* The first octect in the pdu contains the SMSC address length
256
 
     * which is the X following octects it reads. We add 1 octet to
257
 
     * the read length to take into account this read octet in order
258
 
     * to calculate the proper tpdu length.
259
 
     */
 
246
        /* The first octect in the pdu contains the SMSC address length
 
247
         * which is the X following octects it reads. We add 1 octet to
 
248
         * the read length to take into account this read octet in order
 
249
         * to calculate the proper tpdu length.
 
250
         */
260
251
        smsc_len = ril_data[0] + 1;
261
252
        DBG("smsc_len is %d", smsc_len);
262
253
 
 
254
        g_ril_append_print_buf(sd->ril, "(%s)", ril_pdu);
 
255
        g_ril_print_unsol(sd->ril, message);
 
256
 
263
257
        /* Last parameter is 'tpdu_len' ( substract SMSC length ) */
264
 
        ofono_sms_deliver_notify(sms, ril_data, 
265
 
                        ril_buf_len, 
 
258
        ofono_sms_deliver_notify(sms, ril_data,
 
259
                        ril_buf_len,
266
260
                        ril_buf_len - smsc_len);
267
261
 
268
262
        /* Re-use rilp, so initilize */
274
268
        /* TODO: should ACK be sent for either of the error cases? */
275
269
 
276
270
        /* ACK the incoming NEW_SMS; ignore response so no cb needed */
277
 
        g_ril_send(data->ril, RIL_REQUEST_SMS_ACKNOWLEDGE,
 
271
        ret = g_ril_send(sd->ril, request,
278
272
                        rilp.data,
279
273
                        rilp.size,
280
274
                        NULL, NULL, NULL);
281
275
 
 
276
        g_ril_append_print_buf(sd->ril, "(1,0)");
 
277
        g_ril_print_request(sd->ril, ret, request);
 
278
 
282
279
        parcel_free(&rilp);
283
280
        return;
284
281
 
298
295
        g_ril_register(data->ril, RIL_UNSOL_RESPONSE_NEW_SMS,
299
296
                        ril_sms_notify, sms);
300
297
 
301
 
        DBG("registered NEW_SMS callback");
302
 
 
303
298
        /* This makes the timeout a single-shot */
304
299
        return FALSE;
305
300
}
310
305
        GRil *ril = user;
311
306
        struct sms_data *data;
312
307
 
313
 
        DBG("");
314
 
 
315
308
        data = g_new0(struct sms_data, 1);
316
309
        data->ril = g_ril_clone(ril);
317
310
        data->vendor = vendor;