1
1
local constants = require " ecnet2.constants"
2
2
local Identity = require " ecnet2.Identity"
3
3
local modems = require " ecnet2.modems"
4
- local Protocol = require " ecnet2.Protocol"
5
4
local ecnetd = require " ecnet2.ecnetd"
5
+ local expect = require " cc.expect"
6
6
7
7
local module = {}
8
8
@@ -14,7 +14,15 @@ local function fetchIdentity()
14
14
return identity
15
15
end
16
16
17
+ --- Loads or creates an identity file in the given path.
18
+ --- @param path string The path to load or create the identity at.
19
+ --- @return ecnet2.Identity
20
+ function module .Identity (path )
21
+ return Identity (expect (1 , path , " string" ))
22
+ end
23
+
17
24
--- Returns the address for this device.
25
+ --- @deprecated Use `ecnet2.Identity("/.ecnet2").address` instead.
18
26
--- @return string address The address.
19
27
function module .address ()
20
28
return fetchIdentity ().address
@@ -27,10 +35,11 @@ module.isOpen = modems.isOpen
27
35
module .daemon = ecnetd .daemon
28
36
29
37
--- Creates a protocol from a given interface.
38
+ --- @deprecated Use `ecnet2.Identity("/.ecnet2"):Protocol(...)` instead.
30
39
--- @param interface ecnet2.IProtocol A table describing the protocol.
31
40
--- @return ecnet2.Protocol protocol The resulting protocol.
32
41
function module .Protocol (interface )
33
- return Protocol ( interface , fetchIdentity ())
42
+ return fetchIdentity (): Protocol ( interface )
34
43
end
35
44
36
45
return module
0 commit comments