Skip to content

Commit

Permalink
extmod/network_cyw43: Add hostname config option.
Browse files Browse the repository at this point in the history
  • Loading branch information
iabdalkader committed Jul 17, 2022
1 parent d9840af commit dc35a50
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions extmod/network_cyw43.c
Expand Up @@ -381,6 +381,9 @@ STATIC mp_obj_t network_cyw43_config(size_t n_args, const mp_obj_t *args, mp_map
cyw43_ioctl(self->cyw, CYW43_IOCTL_GET_VAR, 13, buf, self->itf);
return MP_OBJ_NEW_SMALL_INT(nw_get_le32(buf) / 4);
}
case MP_QSTR_hostname: {
return mp_obj_new_str(self->cyw->hostname, strlen(self->cyw->hostname));
}
default:
mp_raise_ValueError(MP_ERROR_TEXT("unknown config param"));
}
Expand Down Expand Up @@ -453,6 +456,12 @@ STATIC mp_obj_t network_cyw43_config(size_t n_args, const mp_obj_t *args, mp_map
cyw43_ioctl(self->cyw, CYW43_IOCTL_SET_VAR, 9 + 4, buf, self->itf);
break;
}
case MP_QSTR_hostname: {
const char *hostname = mp_obj_str_get_str(e->value);
strncpy(self->cyw->hostname, hostname, DNS_MAX_NAME_LENGTH);
self->cyw->hostname[DNS_MAX_NAME_LENGTH - 1] = 0;
break;
}
default:
mp_raise_ValueError(MP_ERROR_TEXT("unknown config param"));
}
Expand Down

0 comments on commit dc35a50

Please sign in to comment.