Advance

Some advance functions will be described here, with this functions, you can control your halocode flexibly, it also means you need to be more careful.

network2

Micropython has implemented a network module, see more in network. the module network2 is based on network, and we add some other functions.

Default config:

DEFAULT_AP_IP    = "192.168.4.1"
DEFAULT_STA_IP   = "192.168.4.2"
DEFAULT_NETMARK  = "255.255.255.0"
DEFAULT_GATEWAY  = "192.168.1.1"
DEFAULT_DNS      = "172.16.50.20"
DEFAULT_AUTHMODE = AUTH_WPA2_PSK
DEFAULT_PORT     = 5050

API REFERENCE

network2.config_ap(ssid, password, authmode = DEFAULT_AUTHMODE, hidden = False)

start as ap mode, ap+sta is not supported now.

config_sta(ssid, password):

start as sta mode, ap+sta is not supported now.

is_connected():
set_ip(ip, if_mode = None):

# set ip address

set_subnet_mark(mark, if_mode = None):
set_gateway(gw, if_mode = None):
get_ip(if_mode = None):
get_sunnet_mark(if_mode = None):
get_gateway(if_mode = None):
create_client():
client_connect_to(ip_to, port = DEFAULT_PORT):
create_server(port = DEFAULT_PORT):
server_wait_connection(port = DEFAULT_PORT):
server_get_connections(port = DEFAULT_PORT):
server_get_latest_connection(port = DEFAULT_PORT):
write(data, mode, ip_to, port = DEFAULT_PORT):
write_line(data, mode, ip_to, port = DEFAULT_PORT):
read(mode, ip_from, port = DEFAULT_PORT):
read_line(mode, ip_from, port = DEFAULT_PORT):

example:

import halo
halo.network2.config_sta("esp32_test", "12345678")

communication

Halocode has implement a powerful communication mudle,

enable_channel_default(channel):
disable_channel_default(channel):
communication_o.disable_phy(channel_table[channel])
enable_repl():
disable_repl():
read(channel):
send(channel):
bind_passthrough_channels(channel1, channel2):
unbind_passthrough_channels(channel1, channel2):

game

System functions

::
halo.print_user_script()