Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sayToClient #5

Open
robin-debug opened this issue Nov 26, 2019 · 2 comments
Open

sayToClient #5

robin-debug opened this issue Nov 26, 2019 · 2 comments

Comments

@robin-debug
Copy link

能不能添加sayToClient函数,即向指定客户端发送文字的功能?
在设备收到服务器下发指令后,能够恢复简单结果可以提升用户体验。
尤其是在公众号或网站对话时。

@robin-debug
Copy link
Author

robin-debug commented Nov 27, 2019

bool BIGIOT::sayToClient(const char *client_id, const char *content)
{
if (!_isLogin || !client_id || !content)return false;
#if ARDUINOJSON_V6113
root.clear();
#elif ARDUINOJSON_V5132
jsonBuffer.clear();
JsonObject &root = jsonBuffer.createObject();
#endif

root["M"] = "say";
root["ID"] = client_id;
root["C"] = content;

String json;

#if ARDUINOJSON_V6113
serializeJson(root, json);
#elif ARDUINOJSON_V5132
root.printTo(json);
#endif
json += "\n";
print(json);
DEBUG_BIGIOTCIENT("Send:%s", json);
return true;
}

@robin-debug
Copy link
Author

另外,由于packetParse()并没有解析client_id,
建议将const char *salve = (const char *)root["S"];
改成const char *salve = (const char *)root["ID"];
即用slave传递ui到_eventCallback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant