def add_Wifi(): params = request.get_json() #print params if not params: response = "Ssid or password empty" resp = jsonify({'detail': response}) resp.status_code = 400 return resp ssid = params.get('ssid', None) password = params.get('password', None) name = params.get('name', '') #print ssid, password, name if ssid is None or password is None: response = "Ssid or password empty" resp = jsonify({'detail': response}) resp.status_code = 400 return resp if niryo_one_wifi.connect_to_wifi(ssid, password): write_robot_name(str(name)) else: niryo_one_wifi.hard_enable_hotspot_with_ssid(HOTSPOT_SSID, HOTSPOT_PASSWORD) response = "Successfully Changed Wi-Fi" resp = jsonify({'detail': response}) resp.status_code = 200 return resp
def switch_to_hotspot_mode(): if niryo_one_wifi.get_current_ssid() == HOTSPOT_SSID: return standard_response(200, "Hotspot mode already activated") success = niryo_one_wifi.hard_enable_hotspot_with_ssid(HOTSPOT_SSID, HOTSPOT_PASSWORD) if success: return standard_response(200, "Hotspot mode activated") return standard_response(400, "Failed to activate hotspot mode")