Add method to set custom hostname
This commit is contained in:
parent
9de96786ad
commit
ceb531086e
@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2020-10-10 23:49-0700\n"
|
||||
"POT-Creation-Date: 2020-10-12 14:16+0530\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@ -947,6 +947,10 @@ msgstr ""
|
||||
msgid "Hardware in use, try alternative pins"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/wifi/Radio.c
|
||||
msgid "Hostname must be between 1 and 63 characters"
|
||||
msgstr ""
|
||||
|
||||
#: extmod/vfs_posix_file.c py/objstringio.c
|
||||
msgid "I/O operation on closed file"
|
||||
msgstr ""
|
||||
@ -1026,6 +1030,7 @@ msgstr ""
|
||||
msgid "Invalid BSSID"
|
||||
msgstr ""
|
||||
|
||||
#: ports/esp32s2/common-hal/analogio/AnalogOut.c
|
||||
#: ports/stm/common-hal/analogio/AnalogOut.c
|
||||
msgid "Invalid DAC pin supplied"
|
||||
msgstr ""
|
||||
@ -1237,7 +1242,6 @@ msgid "No CCCD for this Characteristic"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/analogio/AnalogOut.c
|
||||
#: ports/esp32s2/common-hal/analogio/AnalogOut.c
|
||||
#: ports/stm/common-hal/analogio/AnalogOut.c
|
||||
msgid "No DAC on chip"
|
||||
msgstr ""
|
||||
|
@ -32,3 +32,8 @@ CONFIG_SPIRAM_MEMTEST=y
|
||||
# CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY is not set
|
||||
# end of SPI RAM config
|
||||
|
||||
#
|
||||
# LWIP
|
||||
#
|
||||
CONFIG_LWIP_LOCAL_HOSTNAME="microS2"
|
||||
# end of LWIP
|
||||
|
@ -104,6 +104,10 @@ void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self) {
|
||||
self->current_scan = NULL;
|
||||
}
|
||||
|
||||
void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *hostname) {
|
||||
esp_netif_set_hostname(self->netif, hostname);
|
||||
}
|
||||
|
||||
wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t* ssid, size_t ssid_len, uint8_t* password, size_t password_len, uint8_t channel, mp_float_t timeout, uint8_t* bssid, size_t bssid_len) {
|
||||
// check enabled
|
||||
start_station(self);
|
||||
|
@ -102,6 +102,26 @@ STATIC mp_obj_t wifi_radio_stop_scanning_networks(mp_obj_t self_in) {
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_stop_scanning_networks_obj, wifi_radio_stop_scanning_networks);
|
||||
|
||||
//| def set_hostname(self, hostname: ReadableBuffer) -> None:
|
||||
//| """Sets hostname for wifi interface. When the hostname is altered after interface started/connected
|
||||
//| the changes would only be reflected once the interface restarts/reconnects."""
|
||||
//| ...
|
||||
//|
|
||||
STATIC mp_obj_t wifi_radio_set_hostname(mp_obj_t self_in, mp_obj_t hostname_in) {
|
||||
mp_buffer_info_t hostname;
|
||||
mp_get_buffer_raise(hostname_in, &hostname, MP_BUFFER_READ);
|
||||
|
||||
if (hostname.len < 1 || hostname.len > 63) {
|
||||
mp_raise_ValueError(translate("Hostname must be between 1 and 63 characters"));
|
||||
}
|
||||
|
||||
wifi_radio_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
common_hal_wifi_radio_set_hostname(self, hostname.buf);
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(wifi_radio_set_hostname_obj, wifi_radio_set_hostname);
|
||||
|
||||
//| def connect(self, ssid: ReadableBuffer, password: ReadableBuffer = b"", *, channel: Optional[int] = 0, timeout: Optional[float] = None) -> bool:
|
||||
//| """Connects to the given ssid and waits for an ip address. Reconnections are handled
|
||||
//| automatically once one connection succeeds."""
|
||||
@ -216,6 +236,8 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_start_scanning_networks), MP_ROM_PTR(&wifi_radio_start_scanning_networks_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_stop_scanning_networks), MP_ROM_PTR(&wifi_radio_stop_scanning_networks_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_set_hostname), MP_ROM_PTR(&wifi_radio_set_hostname_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_connect), MP_ROM_PTR(&wifi_radio_connect_obj) },
|
||||
// { MP_ROM_QSTR(MP_QSTR_connect_to_enterprise), MP_ROM_PTR(&wifi_radio_connect_to_enterprise_obj) },
|
||||
|
||||
|
@ -35,7 +35,6 @@
|
||||
|
||||
const mp_obj_type_t wifi_radio_type;
|
||||
|
||||
|
||||
typedef enum {
|
||||
WIFI_RADIO_ERROR_NONE,
|
||||
WIFI_RADIO_ERROR_UNKNOWN,
|
||||
@ -46,6 +45,8 @@ typedef enum {
|
||||
extern bool common_hal_wifi_radio_get_enabled(wifi_radio_obj_t *self);
|
||||
extern void common_hal_wifi_radio_set_enabled(wifi_radio_obj_t *self, bool enabled);
|
||||
|
||||
extern void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *hostname);
|
||||
|
||||
extern mp_obj_t common_hal_wifi_radio_get_mac_address(wifi_radio_obj_t *self);
|
||||
|
||||
extern mp_obj_t common_hal_wifi_radio_start_scanning_networks(wifi_radio_obj_t *self);
|
||||
|
Loading…
x
Reference in New Issue
Block a user