Documentation
¶
Overview ¶
Package watch is the text protocol of 3G / SeTracker-style children's watches and many low-cost trackers ("[SG*id*len*content]"): frame reading, decoding into track.Message, and command framing. Our own implementation from the watch "Communication Protocol" V1.7_C (3G Electronics, published on traccar.org); facts cross-checked against Traccar's decoder tests.
A frame is "[" vendor (two characters: SG, 3G, CS, ZJ, …) "*" device ID "*" [index "*"] length (four hexadecimal digits) "*" content "]". Binary content (voice) escapes "}" "[" "]" "," "*" as 0x7D followed by 0x01 to 0x05; frames are found by matching brackets, so a WiFi name holding brackets stays inside its frame. Read:
LK[,steps,rolls,battery] link keep-alive, answered LK (the first frame is the Login) UD, UD2 (history), UD3, UD_LTE, UD_WCDMA, WT, WG, WAD positions, not answered AL, AL_LTE, ALCUSTOMER… alarm positions, answered AL INIT, TKQ, TKQ2 answered with themselves (INIT,1) PULSE, heart, BLOOD, bphrt, TEMP, btemp2, oxygen health readings anything else the device's answer to a command, named by its keyword
A position is date (ddMMyy), time, A/V, latitude, N/S, longitude, E/W, speed, course, altitude, satellites, GSM signal (0-100), battery (%), steps, rolls, a hexadecimal status word (alarms in its high half: 16 SOS, 17 low battery, 18 out of fence, 19 into fence, 20 watch taken off; low half: 0 low battery, 1 out of fence, 2 in fence), the cells (count, timing advance, MCC, MNC, then LAC, cell ID and signal each; decimal or hexadecimal) and the WiFi access points (count, then name, MAC and RSSI each). Voice, pictures and audio parts (TK, img, JXTK) are passed over with a warning (JXTK is acknowledged).
Commands are frames with the device's vendor, ID and index form; devices that send "3G" are sent "SG", as Traccar does. Every command's answer repeats its keyword, so the codec is a strict track.Correlator. Forms: {"text": "CR"}, a named command, or {"sos": ["number", …]} (one to three SOS numbers, "SOS,a,b,c"). Useful texts: CR (locate now), UPLOAD,<seconds>, RESET, POWEROFF, SOS1,<number>, VERNO, TS.
The profile (NewCodec; Profile):
speedUnit: kmh # kmh (default, as devices send it), mph (as the document says), knots
commandVendor: "" # vendor written on commands; default the device's (3G → SG)
namedCommands: {interval: "UPLOAD,{seconds}"} # replaces a named command's text
Named commands (track.Named): locate "CR", reboot "RESET", interval "UPLOAD,<seconds>" (10 to 86400 s). Watches have no engine relay.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Interval bounds the interval command, in seconds. Interval = track.IntervalRange{Min: 10, Max: 86400} // NamedActions are the named commands watches have: no engine relay. NamedActions = []string{track.ActionLocate, track.ActionReboot, track.ActionInterval} )
Named commands as watch protocol commands (Communication Protocol V1.7_C: CR, RESET, UPLOAD).