1package main
2
3import (
4 "fmt"
5 "log"
6 "os"
7 "path/filepath"
8)
9
10const (
11 bufSize = 1024
12 baudRate = 115200
13)
14
15var (
16 out = os.Stdout
17 err = os.Stderr
18)
19
20var logger = log.New(err, "", log.Lshortfile)
21
22func main() {
23 if len(os.Args) < 3 {
24 fmt.Fprintf(os.Stderr, "USAGE: %s ADDR PATH\n", filepath.Base(os.Args[0]))
25 os.Exit(1)
26 }
27
28 addr := os.Args[1]
29 path := os.Args[2]
30
31 cep, err := NewCoapEP(addr)
32 if err != nil {
33 logger.Fatal(err)
34 }
35 defer cep.Close()
36
37 sep, err := NewSerialEP(path)
38 if err != nil {
39 logger.Fatal(err)
40 }
41 defer sep.Close()
42
43 dispatcher := &Dispatcher{cep, sep}
44 dispatcher.Run()
45}