Skip to content

Commit 161e2bd

Browse files
DvdGiessendpgeorge
authored andcommitted
extmod/network_ppp: Add stream config parameter.
This makes the stream that the PPP object wraps, which is normally only set once via the constructor, accessible and configurable via the `ppp.config()` method. Signed-off-by: Daniël van de Giessen <[email protected]>
1 parent 4fd5b72 commit 161e2bd

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

docs/library/network.PPP.rst

+5-2
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,11 @@ Methods
7070

7171
.. method:: PPP.config(config_parameters)
7272

73-
Sets or gets parameters of the PPP interface. There are currently no parameter that
74-
can be set or retrieved.
73+
Sets or gets parameters of the PPP interface. The only parameter that can be
74+
retrieved and set is the underlying stream, using::
75+
76+
stream = PPP.config("stream")
77+
PPP.config(stream=stream)
7578

7679
.. method:: PPP.ipconfig('param')
7780
PPP.ipconfig(param=value, ...)

extmod/network_ppp_lwip.c

+10-1
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,17 @@ static mp_obj_t network_ppp_config(size_t n_args, const mp_obj_t *args, mp_map_t
153153
if (n_args != 1 && kwargs->used != 0) {
154154
mp_raise_TypeError(MP_ERROR_TEXT("either pos or kw args are allowed"));
155155
}
156-
// network_ppp_obj_t *self = MP_OBJ_TO_PTR(args[0]);
156+
network_ppp_obj_t *self = MP_OBJ_TO_PTR(args[0]);
157157

158158
if (kwargs->used != 0) {
159159
for (size_t i = 0; i < kwargs->alloc; i++) {
160160
if (mp_map_slot_is_filled(kwargs, i)) {
161161
switch (mp_obj_str_get_qstr(kwargs->table[i].key)) {
162+
case MP_QSTR_stream: {
163+
mp_get_stream_raise(kwargs->table[i].value, MP_STREAM_OP_READ | MP_STREAM_OP_WRITE);
164+
self->stream = kwargs->table[i].value;
165+
break;
166+
}
162167
default:
163168
break;
164169
}
@@ -174,6 +179,10 @@ static mp_obj_t network_ppp_config(size_t n_args, const mp_obj_t *args, mp_map_t
174179
mp_obj_t val = mp_const_none;
175180

176181
switch (mp_obj_str_get_qstr(args[1])) {
182+
case MP_QSTR_stream: {
183+
val = self->stream;
184+
break;
185+
}
177186
default:
178187
mp_raise_ValueError(MP_ERROR_TEXT("unknown config param"));
179188
}

ports/esp32/network_ppp.c

+9
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,11 @@ static mp_obj_t ppp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
323323
for (size_t i = 0; i < kwargs->alloc; i++) {
324324
if (mp_map_slot_is_filled(kwargs, i)) {
325325
switch (mp_obj_str_get_qstr(kwargs->table[i].key)) {
326+
case MP_QSTR_stream: {
327+
mp_get_stream_raise(kwargs->table[i].value, MP_STREAM_OP_READ | MP_STREAM_OP_WRITE);
328+
self->stream = kwargs->table[i].value;
329+
break;
330+
}
326331
default:
327332
break;
328333
}
@@ -338,6 +343,10 @@ static mp_obj_t ppp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
338343
mp_obj_t val = mp_const_none;
339344

340345
switch (mp_obj_str_get_qstr(args[1])) {
346+
case MP_QSTR_stream: {
347+
val = self->stream;
348+
break;
349+
}
341350
case MP_QSTR_ifname: {
342351
if (self->pcb != NULL) {
343352
struct netif *pppif = ppp_netif(self->pcb);

0 commit comments

Comments
 (0)