Skip to content

Commit

Permalink
mqtt gateway now works
Browse files Browse the repository at this point in the history
  • Loading branch information
Ubuntu committed Mar 9, 2024
1 parent 00163a9 commit 71e84b4
Show file tree
Hide file tree
Showing 6 changed files with 811 additions and 188 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ add_library(woofc-shepherd src/woofc-shepherd.cpp)
target_link_libraries(woofc-shepherd PUBLIC woof)
target_include_directories(woofc-shepherd PRIVATE src/include)

add_executable(woofc-mqtt-gateway src/woofc-mqtt-gateway.cpp)
#add_executable(woofc-mqtt-gateway src/woofc-mqtt-gateway.cpp)
add_executable(woofc-mqtt-gateway src/woofc-mqtt-gateway.c)
target_link_libraries(woofc-mqtt-gateway woof woof-mqtt)
target_include_directories(woofc-mqtt-gateway PRIVATE src/include)

Expand Down
32 changes: 32 additions & 0 deletions deps/euca-cutils/redblack.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,37 @@

#include "redblack.h"

int Strcmp(char *s1, char *s2)
{
int i;
char *c1;
char *c2;
c1 = s1;
c2 = s2;
//printf("Strcmp: s1: %s\n",s1);
//printf("Strcmp: s2: %s\n",s2);
if((s1 == NULL) && (s2 != NULL)) {
return(-1);
} else if ((s2 == NULL) && (s1 != NULL)) {
return(1);
}
else if((s1 == NULL) && (s2 == NULL)) {
return(0);
}
while((*c1 != 0) && (*c2 != 0)) {
if(*c1 != *c2) {
break;
}
c1++;
c2++;
}
if((*c1 == 0) && (*c2 == 0)) {
return(0);
} else {
return(*(unsigned char *)s1 - *(unsigned char *)s2);
}
}

int CompareKeyType(KEY_t op1, KEY_t op2)
{
int i1, i2;
Expand Down Expand Up @@ -145,6 +176,7 @@ RB *RBTreeInit(unsigned char type)
RB *node;

node = RBInit();
memset(node,0,sizeof(node));
node->color = RB_GREEN; /* need this if the root rotates */
node->key.type = type;

Expand Down
12 changes: 11 additions & 1 deletion src/net/zmq/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace cspot::zmq {
int32_t backend::remote_get(std::string_view woof_name, void* elem, uint32_t elem_size, uint32_t seq_no) {
auto endpoint_opt = endpoint_from_woof(woof_name);
std::string woof_n(woof_name);

if (!endpoint_opt) {
return -1;
Expand Down Expand Up @@ -38,6 +39,8 @@ int32_t backend::remote_get(std::string_view woof_name, void* elem, uint32_t ele

if (!r_msg) {
DEBUG_WARN("Could not receive reply for WoofMsgGet");
printf("WooFMsgGet: server request failed\n");
perror("WooFMsgGet");
return -1;
}

Expand Down Expand Up @@ -138,6 +141,8 @@ backend::remote_put(std::string_view woof_name, const char* handler_name, const

if (!r_msg) {
DEBUG_WARN("Could not receive reply for WoofMsgPut");
printf("WooFPut: server request failed");
perror("WooFMsgPut");
return -1;
}

Expand Down Expand Up @@ -177,7 +182,8 @@ int32_t backend::remote_get_elem_size(std::string_view woof_name_v) {
"server at %s\n",
woof_name.c_str(),
endpoint.c_str());
perror("WooFMsgGetElSize: no response received");
printf("WooFMsgGetElSize: server request failed\n");
perror("WooFMsgGetElSize");
return -1;
}

Expand All @@ -193,6 +199,8 @@ int32_t backend::remote_get_elem_size(std::string_view woof_name_v) {
int32_t backend::remote_get_latest_seq_no(std::string_view woof_name,
const char* cause_woof_name,
uint32_t cause_woof_latest_seq_no) {

std::string woof_n(woof_name);
auto endpoint_opt = endpoint_from_woof(woof_name);

if (!endpoint_opt) {
Expand Down Expand Up @@ -220,6 +228,8 @@ int32_t backend::remote_get_latest_seq_no(std::string_view woof_name,

if (!r_msg) {
DEBUG_WARN("Could not receive reply for WoofMsgGet");
printf("WooFMsgGetLatestSeqno: server request failed\n");
perror("WooFMsgGetLatestSeqno");
return -1;
}

Expand Down
Loading

0 comments on commit 71e84b4

Please sign in to comment.