events.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. // Package protocol defines shared event types for ZMQ messages
  2. package protocol
  3. // EventType identifies the type of beacon event
  4. type EventType string
  5. const (
  6. EventIBeacon EventType = "ibeacon"
  7. EventAccel EventType = "my-beacon_acc"
  8. EventAccelFF EventType = "my-beacon_acc_ff"
  9. EventRelay EventType = "rt_mybeacon"
  10. EventWiFiProbe EventType = "wifi_probe"
  11. )
  12. // BLEEvent is the base structure for all BLE events
  13. type BLEEvent struct {
  14. Type EventType `json:"type"`
  15. MAC string `json:"mac"`
  16. RSSI int8 `json:"rssi"`
  17. TsMs int64 `json:"ts"`
  18. }
  19. // IBeaconEvent represents an iBeacon advertisement
  20. type IBeaconEvent struct {
  21. BLEEvent
  22. UUID string `json:"uuid"`
  23. Major uint16 `json:"major"`
  24. Minor uint16 `json:"minor"`
  25. }
  26. // AccelEvent represents my-beacon accelerometer data
  27. type AccelEvent struct {
  28. BLEEvent
  29. X int8 `json:"x"`
  30. Y int8 `json:"y"`
  31. Z int8 `json:"z"`
  32. Bat uint8 `json:"bat"`
  33. Temp int8 `json:"temp"`
  34. FF bool `json:"ff"`
  35. }
  36. // RelayEvent represents rt_mybeacon relay data
  37. type RelayEvent struct {
  38. BLEEvent
  39. RelayMAC string `json:"relay_mac"`
  40. RelayMaj uint16 `json:"relay_major"`
  41. RelayMin uint16 `json:"relay_minor"`
  42. RelayRSSI int8 `json:"relay_rssi"`
  43. RelayBat uint8 `json:"relay_bat"`
  44. IBMajor uint16 `json:"ib_major"`
  45. IBMinor uint16 `json:"ib_minor"`
  46. }
  47. // WiFiProbeEvent represents a WiFi probe request
  48. type WiFiProbeEvent struct {
  49. Type EventType `json:"type"`
  50. MAC string `json:"mac"`
  51. RSSI int8 `json:"rssi"`
  52. TsMs int64 `json:"ts"`
  53. SSID string `json:"ssid,omitempty"`
  54. }