commit once in a while...

This commit is contained in:
Joerg Lehmann 2021-06-02 20:44:35 +02:00
parent 4add965162
commit 73d4613c0e
9 changed files with 277 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
setup-node/setup-node

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

99
artwork/preisschild.svg Normal file
View File

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="210mm"
height="297mm"
viewBox="0 0 210 297"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="preisschild.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.99330107"
inkscape:cx="374.70202"
inkscape:cy="561.25984"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
inkscape:window-width="2560"
inkscape:window-height="1369"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10.8566px;line-height:0;font-family:Lato;-inkscape-font-specification:Lato;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.271416"
x="31.211096"
y="114.73696"
id="text835"
transform="rotate(-10)"
inkscape:export-filename="/home/joerg/gps-tracker-price-tag.png"
inkscape:export-xdpi="31.477173"
inkscape:export-ydpi="31.477173"><tspan
sodipodi:role="line"
x="31.211096"
y="114.73696"
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:26.056px;line-height:1.35;font-family:Carlito;-inkscape-font-specification:'Carlito Bold';fill:#000080;stroke-width:0.271416"
id="tspan837"
rotate="0 0 0 0 0 0 0 0 0 0 0">CHF 150.00</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:6.35069px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.579232"
x="31.503569"
y="127.03384"
id="text859"
transform="matrix(0.98126176,-0.17302292,0.17427569,0.98836656,0,0)"
inkscape:export-filename="/home/joerg/gps-tracker-price-tag.png"
inkscape:export-xdpi="31.477173"
inkscape:export-ydpi="31.477173"><tspan
sodipodi:role="line"
id="tspan857"
x="31.503569"
y="127.03384"
style="font-size:6.35069px;fill:#000080;stroke-width:0.579232">CHF 5.00 pro Monat (ab zweitem Jahr)</tspan></text>
<rect
style="fill:none;fill-rule:evenodd;stroke:#ff0000;stroke-width:2.75034;stroke-linecap:round;paint-order:stroke markers fill;stop-color:#000000"
id="rect879"
width="157.24968"
height="68.249664"
x="13.120611"
y="79.025589"
rx="1.3733099"
ry="1.3770248"
transform="rotate(-10)"
inkscape:export-filename="/home/joerg/gps-tracker-price-tag.png"
inkscape:export-xdpi="31.477173"
inkscape:export-ydpi="31.477173" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -2,6 +2,12 @@
`
LED nach oben (mit eigenem Kabel, siehe ODT File)
Reset Knopf kurz drücken, dann folgender Befehl:
Reset Knopf (z.B. mit Bueroklammer) drücken, dann folgender Befehl:
[joerg@cinnamon firmware]$ openocd -f /usr/share/openocd/scripts/interface/stlink.cfg -c "transport select hla_swd" -f /usr/share/openocd/scripts/target/stm32l0.cfg -c init -c 'program EU868.hex verify reset exit'
Gerade nach Befehl Reset-Knopf wieder loslassen - Timing ist entscheidend!
Nach Firmware Update immer:
AT+FDR
`

BIN
schablone/schablone.FCStd Normal file

Binary file not shown.

BIN
schablone/schablone.FCStd1 Normal file

Binary file not shown.

BIN
schablone/schablone.stl Normal file

Binary file not shown.

162
setup-node/main.go Normal file
View File

@ -0,0 +1,162 @@
package main
import (
"fmt"
"github.com/tarm/serial"
"log"
"os"
"path/filepath"
"strings"
"time"
)
// returns last line of output
func sendCommand(p *serial.Port, command string) string {
fmt.Printf("%s\n", command)
var first_line string = ""
p.Flush()
time.Sleep(300 * time.Millisecond)
ignorebuf := make([]byte, 1024)
p.Read(ignorebuf)
_, err := p.Write([]byte(command + "\n"))
if err != nil {
log.Fatal(err)
}
buf := make([]byte, 1024)
time.Sleep(300 * time.Millisecond)
n, _ := p.Read(buf)
if n > 0 {
lines := strings.Split(string(buf[:n]), "\n")
//fmt.Printf("%+q\n", lines)
first_line = lines[0]
}
return first_line
}
func getDevEui(p *serial.Port) string {
var reply = sendCommand(p, "AT+DADDR=?")
//fmt.Printf("XXX%sYYY\n",reply)
if len(reply) >= 10 {
return "a8 40 41 00 " + reply[0:11]
} else {
return ""
}
}
func getFWVersion(p *serial.Port) string {
var reply = sendCommand(p, "AT+VER=?")
//fmt.Printf("XXX%sYYY\n",reply)
if len(reply) >= 10 {
return reply
} else {
return ""
}
}
func getAppKey(deveui string) string {
if len(deveui) == 23 {
mdeveui := strings.ReplaceAll(deveui, " ", "")
appkey := fmt.Sprintf("%c%c %c%c %c%c %c%c %c%c %c%c %c%c %c%c %c%c %c%c %c%c %c%c %c%c %c%c %c%c %c%c",
mdeveui[10],
mdeveui[3],
mdeveui[4],
mdeveui[7],
mdeveui[15],
mdeveui[9],
mdeveui[11],
mdeveui[2],
mdeveui[0],
mdeveui[8],
mdeveui[1],
mdeveui[6],
mdeveui[5],
mdeveui[12],
mdeveui[14],
mdeveui[13],
mdeveui[3],
mdeveui[6],
mdeveui[12],
mdeveui[7],
mdeveui[15],
mdeveui[1],
mdeveui[9],
mdeveui[11],
mdeveui[2],
mdeveui[10],
mdeveui[0],
mdeveui[8],
mdeveui[5],
mdeveui[14],
mdeveui[4],
mdeveui[13])
fmt.Printf("calculated AppKey: %s\n", appkey)
return appkey
} else {
fmt.Printf("devEui has wrong length: %s\n", deveui)
return ""
}
}
func readSerial(p *serial.Port) {
p.Flush()
buf := make([]byte, 32)
time.Sleep(200 * time.Millisecond)
n, _ := p.Read(buf)
for n > 0 {
// ignoring error as EOF raises error on Linux
reply := string(buf[:n])
fmt.Printf("%s", reply)
n, _ = p.Read(buf)
}
}
func main() {
if len(os.Args) != 2 {
fmt.Println("usage: " + filepath.Base(os.Args[0]) + " <SerialDevice>")
os.Exit(1)
}
serialdev := os.Args[1]
appEui := "a8 40 41 35 10 35 10 35"
c := &serial.Config{Name: serialdev, Baud: 9600, ReadTimeout: time.Second * 1}
s, err := serial.OpenPort(c)
if err != nil {
log.Fatal("Problem mit Serial Interface")
}
location, err := time.LoadLocation("Europe/Zurich")
f, err := os.OpenFile("setup-node.log",
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
log.Println(err)
}
defer f.Close()
sendCommand(s, "AT")
devEui := getDevEui(s)
FWVersion := getFWVersion(s)
if devEui != "" {
fmt.Printf("devEui: %s\n", devEui)
sendCommand(s, "AT+APPEUI="+appEui)
appkey := getAppKey(devEui)
sendCommand(s, "AT+APPKEY="+appkey)
sendCommand(s, "AT+FDR")
sendCommand(s, "AT+LON=0")
sendCommand(s, "ATZ")
logline := strings.ToUpper(fmt.Sprintf("%s: %s %s %s %s\n", time.Now().In(location).Format("02.01.2006 15:04"), strings.ReplaceAll(devEui, " ", ""), strings.ReplaceAll(appEui, " ", ""), strings.ReplaceAll(appkey, " ", ""), FWVersion))
if _, err := f.WriteString(logline); err != nil {
log.Println(err)
}
readSerial(s)
} else {
log.Fatal("Could not get devEui")
}
}

View File

@ -0,0 +1,8 @@
17.04.2021 17:13: A8404100018193D7 A840413510351035 80407114A08019D30090781148A01D43 V1.6.5 EU868
17.04.2021 17:14: A8404100018193F3 A840413510351035 80403114A08019F30090381148A01F43 V1.6.5 EU868
14.05.2021 16:28: A8404100018193F3 A840413510351035 80403114A08019F30090381148A01F43 V1.6.5 EU868
14.05.2021 16:52: A8404100018193D7 A840413510351035 80407114A08019D30090781148A01D43 V1.6.5 EU868
14.05.2021 20:26: A8404100018193D7 A840413510351035 80407114A08019D30090781148A01D43 V1.6.5 EU868
14.05.2021 20:32: A8404100018193F3 A840413510351035 80403114A08019F30090381148A01F43 V1.6.5 EU868
02.06.2021 19:44: A8404100018193DE A840413510351035 8040E114A08019D30090E81148A01D43
02.06.2021 19:49: A8404100018193DE A840413510351035 8040E114A08019D30090E81148A01D43 V1.6.5 EU868