@@ -12,9 +12,16 @@ import (
12
12
"time"
13
13
)
14
14
15
+ // READ_TIMEOUT is the timeout for reading from the TCP connection.
16
+ // Low power devices may take longer than usual before receiving initial data.
17
+ var READ_TIMEOUT = 10 * time .Second
18
+
19
+ // FRAMES_KEEPALIVE is the keep-alive ping frame sent to the Blink stream server.
15
20
var FRAMES_KEEPALIVE = []byte {
16
- 0x12 , 0x00 , 0x00 , 0x03 , 0xe8 , 0x00 , 0x00 , 0x00 , 0x18 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
17
- 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 ,
21
+ 0x12 , 0x00 , 0x00 , 0x03 , 0xe8 , 0x00 , 0x00 , 0x00 ,
22
+ 0x18 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
23
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 ,
24
+ 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x01 , 0x00 ,
18
25
0x00 ,
19
26
}
20
27
@@ -74,7 +81,7 @@ stream:
74
81
log .Println ("Closing stream" )
75
82
break stream
76
83
default :
77
- if err := client .SetReadDeadline (time .Now ().Add (2 * time . Second )); err != nil {
84
+ if err := client .SetReadDeadline (time .Now ().Add (READ_TIMEOUT )); err != nil {
78
85
streamErr = fmt .Errorf ("error setting read deadline: %w" , err )
79
86
break stream
80
87
}
0 commit comments