使用HERE Positioning V2 API遇MAC地址定位错误报E606404如何解决
HERE Positioning V2 API E606404错误解决方案
错误原因
你遇到的E606404错误是因为提交的请求中存在位置偏差极大的MAC地址,多个WLAN的已知位置分布过于分散,API无法聚合出合理的定位结果,即使开启了singleWifi fallback也会因为多源数据冲突直接返回错误。
官方返回的错误说明如下:
'title': 'Not Found', 'status': 404, 'code': 'E606404', 'action': 'The values provided in the request cannot produce any content for the response. The location of the WLANs and cells in the request is unknown or the locations of the radio measurements are so widely scattered that the location cannot be determined. Make sure that the network measurements are correct and consistent. Try allowing fallbacks
areaoranyfor cell positioning andsingleWififor WLAN positioning.', 'cause': 'Position not found'
解决步骤
- 调整fallback参数,开启全量降级策略
你当前的请求仅配置了fallback=singleWifi,修改为fallback=singleWifi,area,any,允许API在多WLAN位置冲突时,自动选择集中的有效WLAN组计算,极端情况下也可返回区域级定位结果,避免直接返回404。 - 增加请求失败的降级重试逻辑
捕获E606404错误后,按RSS信号强度从低到高依次移除WLAN条目后重试,直到拿到返回结果或剩余1个WLAN(配合singleWififallback可保证至少返回单WIFI定位结果)。 - 前置过滤弱信号/可疑MAC
优先提交RSS大于-70的前3-4个信号最强的WLAN,信号越强说明距离当前位置越近,出现跨几百公里漂移MAC的概率更低,从源头降低冲突概率。
修改后的参考代码
import json import requests API_KEY = "my_api_key" # 调整fallback参数,开启全量降级 BASE_URL = f"https://positioning.hereapi.com/v2/locate?apiKey={API_KEY}&desired=altitude&fallback=singleWifi,area,any" headers = {"Content-Type": "application/json"} # 原始WLAN列表,按RSS从高到低排序,优先保留信号强的 wlan_list = sorted([ {"mac": "xx:xx:xx:xx:xx:xx", "rss": -42}, {"mac": "yy:yy:yy:yy:yy:yy", "rss": -54}, {"mac": "zz:zz:zz:zz:zz:zz", "rss": -76}, {"mac": "vv:vv:vv:vv:vv:vv", "rss": -64} # 漂移MAC ], key=lambda x: x["rss"], reverse=True) response = None # 最多重试len(wlan_list)次,每次移除信号最弱的一个WLAN for i in range(len(wlan_list), 0, -1): data = {"wlan": wlan_list[:i]} response = requests.post(BASE_URL, headers=headers, data=json.dumps(data)) # 只要不是E606404错误就终止重试 if not (response.status_code == 404 and response.json().get("code") == "E606404"): break # 处理最终返回结果 if response.status_code == 200: print("定位结果:", response.json()) else: print("定位失败,请检查MAC地址有效性")
内容的提问来源于stack exchange,提问作者starli8ht
相关产品推荐
相关产品推荐

