@@ -239,6 +239,16 @@ const char *AT_CellularContext::get_ip_address()
239
239
#endif
240
240
}
241
241
242
+ char *AT_CellularContext::get_interface_name (char *interface_name)
243
+ {
244
+ if (_cid < 0 ) {
245
+ return NULL ;
246
+ }
247
+ MBED_ASSERT (interface_name);
248
+ sprintf (interface_name, " ce%02d" , _cid);
249
+ return interface_name;
250
+ }
251
+
242
252
void AT_CellularContext::attach (Callback<void (nsapi_event_t , intptr_t )> status_cb)
243
253
{
244
254
_status_cb = status_cb;
@@ -458,7 +468,30 @@ nsapi_error_t AT_CellularContext::do_activate_context()
458
468
459
469
nsapi_error_t AT_CellularContext::activate_ip_context ()
460
470
{
461
- return find_and_activate_context ();
471
+ nsapi_error_t ret = find_and_activate_context ();
472
+ #if !NSAPI_PPP_AVAILABLE
473
+ if (ret == NSAPI_ERROR_OK) {
474
+ pdpContextList_t params_list;
475
+ if (get_pdpcontext_params (params_list) == NSAPI_ERROR_OK) {
476
+ pdpcontext_params_t *pdp = params_list.get_head ();
477
+ while (pdp) {
478
+ SocketAddress addr;
479
+ if (addr.set_ip_address (pdp->dns_secondary_addr )) {
480
+ tr_info (" DNS secondary %s" , pdp->dns_secondary_addr );
481
+ char ifn[5 ]; // "ce" + two digit _cid + zero
482
+ add_dns_server (addr, get_interface_name (ifn));
483
+ }
484
+ if (addr.set_ip_address (pdp->dns_primary_addr )) {
485
+ tr_info (" DNS primary %s" , pdp->dns_primary_addr );
486
+ char ifn[5 ]; // "ce" + two digit _cid + zero
487
+ add_dns_server (addr, get_interface_name (ifn));
488
+ }
489
+ pdp = pdp->next ;
490
+ }
491
+ }
492
+ }
493
+ #endif
494
+ return ret;
462
495
}
463
496
464
497
nsapi_error_t AT_CellularContext::activate_non_ip_context ()
0 commit comments