Skip to content

Commit 263d659

Browse files
committed
Implement discovery controller
1 parent 1a04a6b commit 263d659

9 files changed

+610
-2
lines changed

app/contexts.go

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/controllers.go

Lines changed: 54 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/media_types.go

Lines changed: 122 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/test/discover_v1_testing.go

Lines changed: 90 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

design/discover.go

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
package design
2+
3+
import (
4+
. "github.com/goadesign/goa/design"
5+
. "github.com/goadesign/goa/design/apidsl"
6+
)
7+
8+
var _ = Resource("discover_v1", func() {
9+
BasePath("/v1/discover")
10+
11+
Action("list", func() {
12+
Description("Returns a list of devices connected to the PC")
13+
Routing(GET(""))
14+
Response(OK, DiscoverV1)
15+
})
16+
})
17+
18+
var DiscoverV1 = MediaType("application/vnd.arduino.agent.discover+json", func() {
19+
Attributes(func() {
20+
Attribute("serial", CollectionOf(DiscoverSerialV1), "A list of devices connected through the serial port")
21+
Attribute("network", CollectionOf(DiscoverNetworkV1), "A list of devices connected through the network")
22+
})
23+
24+
Required("serial", "network")
25+
26+
View("default", func() {
27+
Attribute("serial")
28+
Attribute("network")
29+
})
30+
})
31+
32+
var DiscoverSerialV1 = MediaType("application/vnd.arduino.agent.discover.serial+json", func() {
33+
Attributes(func() {
34+
Attribute("vid", String, "Vendor ID", func() {
35+
Example("0x2341")
36+
})
37+
Attribute("pid", String, "Vendor ID", func() {
38+
Example("0x8036")
39+
})
40+
Attribute("serial", String, "The Serial Number")
41+
Attribute("port", String, "The port through which it's connected", func() {
42+
Example("/dev/ttyACM0")
43+
})
44+
})
45+
46+
Required("vid", "pid", "port")
47+
48+
View("default", func() {
49+
Attribute("vid")
50+
Attribute("pid")
51+
Attribute("port")
52+
Attribute("serial")
53+
})
54+
55+
})
56+
57+
var DiscoverNetworkV1 = MediaType("application/vnd.arduino.agent.discover.network+json", func() {
58+
Attributes(func() {
59+
Attribute("address", String, "IP Address", func() {
60+
Example("192.168.1.107")
61+
})
62+
Attribute("port", Integer, "IP Port", func() {
63+
Example(80)
64+
})
65+
Attribute("info", String, "Informations about the device", func() {
66+
Example(`board=Arduino Y\195\186n Shield distro_version=0.1`)
67+
})
68+
Attribute("name", String, "The friendly name given to the device", func() {
69+
Example("MyShield")
70+
})
71+
})
72+
73+
Required("address", "port", "info", "name")
74+
75+
View("default", func() {
76+
Attribute("address")
77+
Attribute("port")
78+
Attribute("info")
79+
Attribute("name")
80+
})
81+
})

0 commit comments

Comments
 (0)