diff --git a/bc.lua b/bc.lua index 05b313c7d8c1..8d914621f1bd 100644 --- a/bc.lua +++ b/bc.lua @@ -138,6 +138,8 @@ function bc:init(my_address, local_nouns, local_verbs) end -- Change this for deployment VVV o.modem = modem:init(my_address, modem_listener) + -- Save listener function for deinit + o.modem_cb = modem_listener -- Init local stuff o.local_verbs = local_verbs or {} o.local_nouns = local_nouns or {} @@ -268,4 +270,9 @@ function bc:listen_cancel(n, id) end end +-- Deinit +function bc:cleanup() + event.ignore("modem_message", self.modem_cb) +end + return bc