完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在尝试将现有的模块修改为
1) 添加更多字段而不是标准的 wifi 名称和密码字段 2) 保存给文本文件的答案 我知道如何修改 html 文件,但我不熟悉 C,所以我可以不明白如何将接收到的数据传递给 Lua 或将其直接保存到文本文件(考虑到它可能包含 utf-8 数据)。 在此感谢您的帮助。 代码:全选 ... else if (c_strncmp(data + 4, "/setwifi?", 9) == 0) { switch (enduser_setup_http_handle_credentials(data, data_len)) { case 0: enduser_setup_serve_status_as_json(http_client); break; case 1: enduser_setup_http_serve_header(http_client, http_header_400, LITLEN(http_header_400)); break; default: ENDUSER_SETUP_ERROR("http_recvcb failed. Failed to handle wifi credentials.", ENDUSER_SETUP_ERR_UNKOWN_ERROR, ENDUSER_SETUP_ERR_NONFATAL); break; } } ... static int enduser_setup_http_handle_credentials(char *data, unsigned short data_len) { ENDUSER_SETUP_DEBUG("enduser_setup_http_handle_credentials"); state->success = 0; state->lastStationStatus = 0; char *name_str = (char *) ((uint32_t)strstr(&(data[6]), "wifi_ssid=")); char *pwd_str = (char *) ((uint32_t)strstr(&(data[6]), "wifi_password=")); if (name_str == NULL || pwd_str == NULL) { ENDUSER_SETUP_DEBUG("Password or SSID string not found"); return 1; } int name_field_len = LITLEN("wifi_ssid="); int pwd_field_len = LITLEN("wifi_password="); char *name_str_start = name_str + name_field_len; char *pwd_str_start = pwd_str + pwd_field_len; int name_str_len = enduser_setup_srch_str(name_str_start, "& "); int pwd_str_len = enduser_setup_srch_str(pwd_str_start, "& "); if (name_str_len == -1 || pwd_str_len == -1) { ENDUSER_SETUP_DEBUG("Password or SSID HTTP paramter divider not found"); return 1; } struct station_config *cnf = luaM_malloc(lua_getstate(), sizeof(struct station_config)); c_memset(cnf, 0, sizeof(struct station_config)); int err; err = enduser_setup_http_urldecode(cnf->ssid, name_str_start, name_str_len, sizeof(cnf->ssid)); err |= enduser_setup_http_urldecode(cnf->password, pwd_str_start, pwd_str_len, sizeof(cnf->password)); if (err != 0 || c_strlen(cnf->ssid) == 0) { ENDUSER_SETUP_DEBUG("Unable to decode HTTP parameter to valid password or SSID"); return 1; } ENDUSER_SETUP_DEBUG(""); ENDUSER_SETUP_DEBUG("WiFi Credentials Stored"); ENDUSER_SETUP_DEBUG("-----------------------"); ENDUSER_SETUP_DEBUG("name: "); ENDUSER_SETUP_DEBUG(cnf->ssid); ENDUSER_SETUP_DEBUG("pass: "); ENDUSER_SETUP_DEBUG(cnf->password); ENDUSER_SETUP_DEBUG("-----------------------"); ENDUSER_SETUP_DEBUG(""); task_post_medium(do_station_cfg_handle, (task_param_t) cnf); return 0; } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
545浏览 6评论
457浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
438浏览 5评论
441浏览 4评论
411浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-22 10:01 , Processed in 1.072256 second(s), Total 75, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号