| | |
| | | #include "cbhomeclient.h"
|
| | | #include "fixed_q.h"
|
| | |
|
| | | #include "3dparty/bus_nng/interface_bus_api.h"
|
| | | #include "3rdparty/bus_nng/interface_bus_api.h"
|
| | |
|
| | | #include "bhome_msg.pb.h"
|
| | |
|
| | |
| | | }
|
| | | template <class T> Msg msg(T&& t){
|
| | | Msg m;
|
| | | msg_helper(make_index_sequence<tuple_size<T>::value>{}, std::forward<T>(t), m);
|
| | | msg_helper(make_index_sequence<tuple_size<typename decay<T>::type>::value>{}, std::forward<T>(t), m);
|
| | | return m;
|
| | | }
|
| | |
|
| | |
| | | return bus_send_reply(cli->bus, src, pbstr.data(), pbstr.size());
|
| | | }
|
| | |
|
| | | struct cqueryprocs* bus_client_query_procs(void* handle, size_t* count){
|
| | | BHAddress addr;
|
| | | const auto& pbaddr = addr.SerializeAsString();
|
| | | MsgQueryProc topic;
|
| | | const auto& pbtopic = topic.SerializeAsString();
|
| | |
|
| | | void* rep = NULL;
|
| | | int repl = 0;
|
| | | auto msg = to_bus<4,5>(ptr(handle), bus_query_procs, pbaddr.data(), pbaddr.size(),
|
| | | pbtopic.data(), pbtopic.size(), &rep, &repl, sndto);
|
| | |
|
| | | MsgQueryProcReply msgR;
|
| | | msgR.ParseFromArray(rep, repl);
|
| | | bus_free(rep, repl);
|
| | |
|
| | | *count = msgR.proc_list_size();
|
| | | auto procs = (struct cqueryprocs*)calloc(*count, sizeof(struct cqueryprocs));
|
| | | for(size_t i = 0; i < *count; i++){
|
| | | const auto& p = msgR.proc_list(i);
|
| | | size_t idl = p.proc().proc_id().size();
|
| | | char* id = (char*)calloc(idl+1, 1);
|
| | | memcpy(id, p.proc().proc_id().data(), idl);
|
| | | procs[i] = cqueryprocs{ .id = id, .idl = idl, .online = p.online() };
|
| | | }
|
| | | return procs;
|
| | | }
|
| | |
|
| | | ////////////////////////////////////////////////////
|
| | | int bus_client_publish(void* handle, const char* topic, const size_t topicl, const char* data, const size_t size){
|
| | | MsgPublish pbmsg;
|