Skip to content

Commit 656ce43

Browse files
authored
Merge pull request #250 from particle-iot/feature/mesh/pubsub_compat
Feature/mesh/pubsub compat
2 parents 9925970 + 589bba0 commit 656ce43

File tree

6 files changed

+221
-171
lines changed

6 files changed

+221
-171
lines changed

hal/network/lwip/openthread/lwip_openthreadif.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,15 @@ err_t OpenThreadNetif::mldMacFilterCb(netif* netif, const ip6_addr_t *group,
303303

304304
int ret = OT_ERROR_FAILED;
305305

306+
// A very hacky solution: keep the list of subscriptions on loopback
306307
if (action == NETIF_ADD_MAC_FILTER) {
308+
mld6_joingroup_netif(netif_get_by_index(1), group);
307309
ret = otIp6SubscribeMulticastAddress(self->ot_, &addr);
308310
} else if (action == NETIF_DEL_MAC_FILTER) {
311+
mld6_leavegroup_netif(netif_get_by_index(1), group);
309312
ret = otIp6UnsubscribeMulticastAddress(self->ot_, &addr);
310313
}
314+
311315
return ret == OT_ERROR_NONE ? ERR_OK : ERR_VAL;
312316
}
313317

@@ -464,6 +468,12 @@ void OpenThreadNetif::stateChanged(uint32_t flags) {
464468
LOG_DEBUG(TRACE, "Subscribed to %s", tmp);
465469
#endif // DEBUG_BUILD
466470
}
471+
// Go through the list of subscriptions on LwIP side and add them if needed
472+
for (struct mld_group* g = netif_mld6_data(netif_get_by_index(1)); g != nullptr; g = g->next) {
473+
otIp6Address addr = {};
474+
ip6AddrToOtIp6Address(g->group_address, &addr);
475+
otIp6SubscribeMulticastAddress(ot_, &addr);
476+
}
467477
interface()->mld_mac_filter = mldMacFilterCb;
468478
}
469479

system/inc/system_dynalib.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ DYNALIB_FN(BASE_IDX + 13, system, system_pool_alloc, void*(size_t, void*))
9898
DYNALIB_FN(BASE_IDX + 14, system, system_pool_free, void(void*, void*))
9999
DYNALIB_FN(BASE_IDX + 15, system, system_sleep_pins, int32_t(const uint16_t*, size_t, const InterruptMode*, size_t, long, uint32_t, void*))
100100
DYNALIB_FN(BASE_IDX + 16, system, system_invoke_event_handler, int(uint16_t handlerInfoSize, FilteringEventHandler* handlerInfo, const char* event_name, const char* event_data, void* reserved))
101-
DYNALIB_FN(BASE_IDX + 17, system, system_task_loop, int(system_task_fn fn, void*))
102101

103102

104103
DYNALIB_END(system)

system/inc/system_task.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ int system_invoke_event_handler(uint16_t handlerInfoSize, FilteringEventHandler*
109109
const char* event_name, const char* event_data, void* reserved);
110110

111111
typedef int (*system_task_fn)();
112-
int system_task_loop(system_task_fn fn, void*);
113112

114113
#ifdef __cplusplus
115114
}

system/src/system_task.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,6 @@ static void process_isr_task_queue()
427427
SystemISRTaskQueue.process();
428428
}
429429

430-
system_task_fn background_task;
431-
432430
#if Wiring_SetupButtonUX
433431
extern void system_handle_button_clicks(bool isIsr);
434432
#endif
@@ -457,9 +455,6 @@ void Spark_Idle_Events(bool force_events/*=false*/)
457455

458456
CLOUD_FN(manage_cloud_connection(force_events), (void)0);
459457

460-
if (background_task) {
461-
background_task();
462-
}
463458
particle::system::fetchAndExecuteCommand(millis());
464459
}
465460
else
@@ -662,8 +657,3 @@ int system_invoke_event_handler(uint16_t handlerInfoSize, FilteringEventHandler*
662657
invokeEventHandler(handlerInfoSize, handlerInfo, event_name, event_data, reserved);
663658
return SYSTEM_ERROR_NONE;
664659
}
665-
666-
int system_task_loop(system_task_fn fn, void*) {
667-
background_task = fn;
668-
return SYSTEM_ERROR_NONE;
669-
}

wiring/inc/spark_wiring_mesh.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,9 @@ class MeshPublish {
124124
// RX packet buffer pool may easily get exhausted, because nobody is reading the data
125125
// out of the socket. Create a separate thread here with a higher priority than application
126126
// and system.
127-
// system_task_loop(mesh_loop, nullptr);
128127
}
129128

130-
int publish(const char* topic, const char* data);
129+
int publish(const char* topic, const char* data = nullptr);
131130

132131
int subscribe(const char* prefix, EventHandler handler);
133132

0 commit comments

Comments
 (0)