2017-10-23 23:33:53 +00:00
|
|
|
_G.requireInjector()
|
2017-09-05 06:09:31 +00:00
|
|
|
|
2018-01-10 21:46:37 +00:00
|
|
|
local Event = require('event')
|
|
|
|
local Util = require('util')
|
2016-12-11 19:24:52 +00:00
|
|
|
|
2017-10-23 23:33:53 +00:00
|
|
|
local device = _G.device
|
|
|
|
local fs = _G.fs
|
2018-01-10 21:46:37 +00:00
|
|
|
local network = _G.network
|
2017-10-23 23:33:53 +00:00
|
|
|
local os = _G.os
|
|
|
|
local printError = _G.printError
|
|
|
|
|
2018-01-10 21:46:37 +00:00
|
|
|
if not device.wireless_modem then
|
2018-01-14 04:40:53 +00:00
|
|
|
return
|
2018-01-13 20:17:26 +00:00
|
|
|
end
|
2016-12-11 19:24:52 +00:00
|
|
|
|
|
|
|
print('Net daemon started')
|
|
|
|
|
2018-01-10 21:46:37 +00:00
|
|
|
for _,file in pairs(fs.list('sys/network')) do
|
2018-01-14 04:40:53 +00:00
|
|
|
local fn, msg = Util.run(_ENV, 'sys/network/' .. file)
|
|
|
|
if not fn then
|
|
|
|
printError(msg)
|
|
|
|
end
|
2016-12-11 19:24:52 +00:00
|
|
|
end
|
|
|
|
|
2018-01-10 21:46:37 +00:00
|
|
|
Event.on('device_detach', function()
|
2018-01-14 04:40:53 +00:00
|
|
|
if not device.wireless_modem then
|
|
|
|
Event.exitPullEvents()
|
|
|
|
end
|
2018-01-10 21:46:37 +00:00
|
|
|
end)
|
|
|
|
|
|
|
|
Event.pullEvents()
|
|
|
|
|
|
|
|
for _,c in pairs(network) do
|
2018-01-14 04:40:53 +00:00
|
|
|
c.active = false
|
|
|
|
os.queueEvent('network_detach', c)
|
2016-12-11 19:24:52 +00:00
|
|
|
end
|
2018-01-10 21:46:37 +00:00
|
|
|
os.queueEvent('network_down')
|
|
|
|
Event.pullEvent('network_down')
|
|
|
|
|
2018-01-14 04:40:53 +00:00
|
|
|
Util.clear(network)
|
2018-01-14 23:28:23 +00:00
|
|
|
|
|
|
|
print('Net daemon stopped')
|