Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Fix node discovery with dps middleware in ROS2 #124

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ static DPS_Status DecodeDiscoveryPayload(DPS_DiscoveryService* service, uint8_t

DPS_DiscoveryService* DPS_CreateDiscoveryService(DPS_Node* node, const char* serviceId)
{
static const int noWildcard = DPS_TRUE;
DPS_DiscoveryService* service;
DPS_Status ret;

Expand Down Expand Up @@ -325,7 +324,7 @@ DPS_DiscoveryService* DPS_CreateDiscoveryService(DPS_Node* node, const char* ser
if (ret != DPS_OK) {
goto Exit;
}
ret = DPS_InitPublication(service->pub, (const char**)&service->topic, 1, noWildcard, OnAck);
ret = DPS_InitPublication(service->pub, (const char**)&service->topic, 1, DPS_FALSE, OnAck);
if (ret != DPS_OK) {
goto Exit;
}
Expand Down
21 changes: 10 additions & 11 deletions src/topics.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,21 @@ DPS_Status DPS_AddTopic(DPS_BitVector* bf, const char* topic, const char* separa
tp = topic + strcspn(topic, separators);
if (!wc) {
DPS_BitVectorBloomInsert(bf, (const uint8_t*)topic, tlen);
if (topicType != DPS_PubTopic) {
return DPS_OK;
}
} else if (wc != topic) {
DPS_BitVectorBloomInsert(bf, (const uint8_t*)topic, wc - topic);
}
if (topicType == DPS_PubNoWild) {
return DPS_OK;
}

segment = malloc(tlen + 1);
if (!segment) {
return DPS_ERR_RESOURCES;
}
while (*tp) {
size_t len;
segment[prefix++] = *tp++;
if (topicType == DPS_PubTopic) {
if (wc != topic) {
DPS_BitVectorBloomInsert(bf, (const uint8_t*)topic, tp - topic);
}
len = strcspn(tp, separators);
Expand All @@ -176,14 +177,12 @@ DPS_Status DPS_AddTopic(DPS_BitVector* bf, const char* topic, const char* separa
tp += len;
}
if (ret == DPS_OK) {
if (topicType == DPS_PubTopic) {
segment[prefix] = INFIX_WILDC;
segment[prefix] = INFIX_WILDC;
DPS_BitVectorBloomInsert(bf, (uint8_t*)segment, prefix + 1);
while (prefix >= 0) {
segment[prefix] = FINAL_WILDC;
DPS_BitVectorBloomInsert(bf, (uint8_t*)segment, prefix + 1);
while (prefix >= 0) {
segment[prefix] = FINAL_WILDC;
DPS_BitVectorBloomInsert(bf, (uint8_t*)segment, prefix + 1);
--prefix;
}
--prefix;
}
}
free(segment);
Expand Down