| | |
| | | #include "bh_api.h" |
| | | #include <pthread.h> |
| | | #include <getopt.h> |
| | | #include "bhome_msg_api.pb.h" |
| | | #include "bhome_msg.pb.h" |
| | | #include "error_msg.pb.h" |
| | | #include "proto/bhome_msg.pb.h" |
| | | #include "proto/bhome_msg_api.pb.h" |
| | | #include "../proto/source/bhome_msg.pb.h" |
| | | #include "../proto/source/bhome_msg_api.pb.h" |
| | | |
| | | static Logger *logger = LoggerFactory::getLogger(); |
| | | |
| | |
| | | strncpy(topics_buf + count, _input.topics[i], min); |
| | | count += min; |
| | | |
| | | if (total >= strlen(_input.topics[i])) { |
| | | total -= strlen(_input.topics[i]); |
| | | } |
| | | total -= min; |
| | | |
| | | if ((_input.amount > 1) && (i < (_input.amount - 1))) { |
| | | if ((total > 1) && (_input.amount > 1) && (i < (_input.amount - 1))) { |
| | | strncpy(topics_buf + count, STR_MAGIC, strlen(STR_MAGIC)); |
| | | total -= 1; |
| | | count++; |
| | |
| | | } |
| | | } |
| | | |
| | | logger->debug("the parsed compound register topics: %s!\n", topics_buf); |
| | | //logger->debug("the parsed compound register topics: %s!\n", topics_buf); |
| | | #else |
| | | memcpy(topics_buf, topics, topics_len > (sizeof(topics_buf) - 1) ? (sizeof(topics_buf) - 1) : topics_len); |
| | | #endif |
| | |
| | | strncpy(topics_buf + count, _input.topics[i], min); |
| | | count += min; |
| | | |
| | | if (total >= strlen(_input.topics[i])) { |
| | | total -= strlen(_input.topics[i]); |
| | | } |
| | | total -= min; |
| | | |
| | | if ((_input.amount > 1) && (i < (_input.amount - 1))) { |
| | | if ((total > 1) && (_input.amount > 1) && (i < (_input.amount - 1))) { |
| | | strncpy(topics_buf + count, STR_MAGIC, strlen(STR_MAGIC)); |
| | | total -= 1; |
| | | count++; |
| | |
| | | topics_buf[strlen(topics_buf) - 1] = '\0'; |
| | | } |
| | | } |
| | | logger->debug("the parsed compound sub topics: %s!\n", topics_buf); |
| | | //logger->debug("the parsed compound sub topics: %s!\n", topics_buf); |
| | | #else |
| | | memcpy(topics_buf, topics, topics_len > (sizeof(topics_buf) - 1) ? (sizeof(topics_buf) - 1) : topics_len); |
| | | #endif |
| | |
| | | } |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | | int BHPublish(const char *msgpub, const char msgpub_len, const int timeout_ms) |
| | | int BHPublish(const char *msgpub, const int msgpub_len, const int timeout_ms) |
| | | #else |
| | | int BHPublish(const char *topic, const char *content, const int timeout_ms) |
| | | #endif |
| | |
| | | int node_arr_len = 0; |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | | struct _MsgPublish |
| | | struct MsgPublish |
| | | { |
| | | const char *topic; |
| | | const char *data; |
| | |
| | | int sec, nsec; |
| | | char topics_buf[MAX_STR_LEN] = { 0x00 }; |
| | | |
| | | struct _RequestReply |
| | | { |
| | | std::string proc_id; |
| | | std::string data; |
| | | }rr; |
| | | |
| | | #if defined(PRO_DE_SERIALIZE) |
| | | struct _BHAddress |
| | | { |
| | |
| | | const char *topic; |
| | | const char *data; |
| | | }_input1; |
| | | |
| | | |
| | | ::bhome_msg::BHAddress input0; |
| | | ::bhome_msg::MsgRequestTopic input1; |
| | | if (!input0.ParseFromArray(remote, remote_len) || !input1.ParseFromArray(request, request_len)) { |
| | |
| | | |
| | | memset(errString, 0x00, sizeof(errString)); |
| | | strncpy(errString, bus_strerror(rv), sizeof(errString)); |
| | | |
| | | struct _RequestReply |
| | | { |
| | | std::string proc_id; |
| | | std::string data; |
| | | }rr; |
| | | |
| | | if (rv == 0) { |
| | | memset(topics_buf, 0x00, sizeof(topics_buf)); |