RPC Protocol use,The code is as follows
wlan = network.WINC(mode=network.WINC.MODE_AP)
wlan.start_ap(SSID, key=KEY, security=wlan.WEP, channel=2)
print(“AP mode started. SSID: {} IP: {}”.format(SSID, wlan.ifconfig()[0]))
interface = rpc.rpc_network_slave(wlan)
Method 1: when code_ Interface stuck when STR field content is large
def upload_code_str(data):
“”"upload_code_str
Args:
data (_type_): _description_
Returns:
_type_: _description_
"""
try:
input_args = json.loads(bytes(data).decode())
file_name = input_args["file_name"]
code_str = input_args["code_str"]
with open("/codes/"+file_name, "w") as f:
f.write(code_str)
f.close()
except Exception as e:
print(repr(e))
return memoryview('success')
Method 2: after returning the picture data, call other interfaces to get stuck
def start_snapshoot(data):
“”"start snapshoot
Args:
data (_type_): _description_
Returns:
_type_: _description_
"""
try:
album_name = bytes(data).decode()
file_path = "/images/%s/%s.jpg" % (album_name, str(time.time_ns())[0:13])
print(album_name, file_path)
sensor.snapshot().save(file_path)
with open(file_path, 'rb') as f:
return bytearray(f.read())
except Exception as e:
print(repr(e))
return bytes()