Beispiel #1
0
func TestGetFreeNwkAddr(t *testing.T) {
	c := os.Getenv("MYBROKER_DB")
	s, err := sql.Open("postgres", c)
	d := dalpsql.New(s)
	a, err := d.GetFreeNwkAddr()
	if err != nil {
		t.Error(err)
	}
	if a == nil {
		t.Error("There must be a free nwkaddr")
	}
}
Beispiel #2
0
func main() {
	log.Print("MYBroker is ALIVE")
	c := os.Getenv("MYBROKER_DB")
	//s, err := sql.Open("postgres", "postgres://*****:*****@server/my?sslmode=require")
	s, err := sql.Open("postgres", c)
	checkerror(err)
	d := dalpsql.New(s)
	b = bllimpl.New(&d)
	router := mux.NewRouter().StrictSlash(true)
	router.HandleFunc("/", Index)
	router.HandleFunc("/RegisterApplication/{name}", RegisterApplication).Methods("POST")
	router.HandleFunc("/RegisterDevice/{appeui}/{deveui}", RegisterDevice).Methods("POST")
	router.HandleFunc("/HasApplication/{appeui}", HasApplication).Methods("GET")
	router.HandleFunc("/Message", MessageHandler).Methods("POST")
	//log.Fatal(http.ListenAndServeTLS(":4443", "server.pem", "server.key", router))
	log.Fatal(http.ListenAndServe(":4443", router))
}