Documentation
¶
Overview ¶
Package bcevent interprets the cloud event reports a battery camera emits (bcudp cf31 packets) as motion, recording and status. A sniffer sitting on the camera's path to its cloud server can decode these in real time, which gives a near-instant local motion signal — the camera sends event 3 the moment it wakes on motion, long before an FTP upload or an SD recording is finished — without the camera's cloud account or any change to the camera.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Battery ¶
type Battery struct {
Current int `json:"bc"`
Millivolts int `json:"bv"`
TempC int `json:"tm"`
ChargeState int `json:"cs"`
Low int `json:"low"`
Pct int `json:"pct"`
}
Battery is the battery sub-object of a status report. Current is milliamps, negative while discharging; Millivolts is the pack voltage; TempC is the pack temperature in Celsius; Pct is the state of charge.
type Kind ¶
type Kind string
Kind is the sort of report an event number names.
const ( Motion Kind = "motion" // event 3: the camera woke on motion RecordingEnd Kind = "recording_end" // event 4: a clip finished (carries duration) Status Kind = "status" // event 12: battery, power, wifi, time Codec Kind = "codec" // event 8: stream parameters Firmware Kind = "firmware" // event 0: firmware/summary Unknown Kind = "unknown" )
type Packet ¶
Packet is one captured, decoded cloud event with the UDP endpoints it was sent between.
type Report ¶
type Report struct {
Event int `json:"event"`
Kind Kind `json:"-"`
Raw json.RawMessage `json:"-"`
// RecordingEnd (event 4).
DurationMS int `json:"duration"`
TotalDuration int `json:"totalduration"`
Reason int `json:"reason"`
// Status (event 12).
HostPwr int `json:"hostpwr"`
Battery *Battery `json:"bat"`
WifiRSSI int `json:"wifi_rssi"`
Time int64 `json:"time"`
}
Report is a decoded event. Fields outside the one that matched Kind are left at their zero value; Raw holds the original JSON for anything not modelled here.
type Sniffer ¶
type Sniffer struct {
// Iface is the interface to capture on, e.g. "enp1s0" or "br-lan".
Iface string
// Promisc puts the interface in promiscuous mode. Needed when the
// camera's frames are bridged past (not addressed to) this host, which
// is the usual case on a router or bridge. Default when zero value is
// used via NewSniffer.
Promisc bool
// NoFilter skips the kernel BPF and filters in userspace instead. For
// diagnostics only; the kernel filter is far cheaper on a busy link.
NoFilter bool
// Debug logs a count of raw frames seen, to tell "no packets arrive"
// from "packets arrive but do not decode".
Debug bool
}
Sniffer passively reads a battery camera's cloud event reports off a network interface. It must run where the camera's traffic to its cloud server is visible — the gateway or bridge the camera sits behind, or a mirror of that port — and needs CAP_NET_RAW (typically root). It never transmits and never touches the camera.