Skip to content

Commit 87b6c00

Browse files
committed
🎉 sendimage complete
1 parent ba05f69 commit 87b6c00

5 files changed

Lines changed: 438 additions & 21 deletions

File tree

api.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ func RunApi(chapi chan bool, MyID uint32) {
1818
// python3 main.py を実行する
1919
cmd = exec.Command("python3", "main.py")
2020
//コマンドを実行
21-
err := cmd.Start()
22-
if err != nil {
23-
log.Println(err)
24-
}
21+
cmd.Start()
2522
//ポートを開く
2623
listener, err := net.Listen("tcp", PORT)
2724
if err != nil {
@@ -147,7 +144,7 @@ func HandleRequest(conn net.Conn) {
147144

148145
}
149146

150-
if strings.Split(requests[1], "/")[1] == "changeAdjustment" {
147+
if strings.Split(requests[1], "/")[1] == "changeadjustment" {
151148
// /changeadjustment/1,120,100/15,255,255/150/0.2これを受け取る
152149
// /120,100,15をとる
153150
minThreshold := strings.Split(requests[1], "/")[2]
@@ -170,11 +167,11 @@ func HandleRequest(conn net.Conn) {
170167
fmt.Fprintf(conn, "CHANGE ADJUSTMENT OK\r\n")
171168
// /changeadjustment/1,120,100/15,255,255/150/0.2を受け取ったら、jsonファイルを変更する
172169
// jsonファイルを変更する
173-
file, err := os.OpenFile("threshold.json", os.O_RDWR|os.O_CREATE, 0755)
170+
171+
os.Remove("threshold.json")
172+
file, err := os.Create("threshold.json")
174173
if err != nil {
175-
fmt.Fprintf(conn, "HTTP/1.1 500 Internal Server Error\r\n")
176-
fmt.Fprintf(conn, "Content-Type: text/plain; charset=utf-8\r\n\r\n")
177-
fmt.Fprintf(conn, "500 Internal Server Error\r\n")
174+
log.Println(err)
178175
}
179176
defer file.Close()
180177
// jsonファイルに書き込む

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ func main() {
8080
netInterfaceAddresses, _ := net.InterfaceAddrs()
8181

8282
ip := "0.0.0.0"
83+
ipCamera := "127.0.0.1"
8384
for _, netInterfaceAddress := range netInterfaceAddresses {
8485
networkIp, ok := netInterfaceAddress.(*net.IPNet)
8586
if ok && !networkIp.IP.IsLoopback() && networkIp.IP.To4() != nil {
@@ -165,7 +166,7 @@ func main() {
165166
go kickCheck(chkick)
166167
go RunGPIO(chgpio)
167168
go RunApi(chapi, MyID)
168-
go ReceiveData(chreceive, MyID, ip)
169+
go ReceiveData(chreceive, MyID, ipCamera)
169170

170171
<-chclient
171172
<-chserver

0 commit comments

Comments
 (0)