Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

36 řádky
918 B

  1. package mqtt_client
  2. import (
  3. "fmt"
  4. "strconv"
  5. "strings"
  6. "github.com/AFASystems/presence/internal/pkg/model"
  7. )
  8. func incomingBeaconFilter(incoming model.Incoming_json) model.Incoming_json {
  9. out_json := incoming
  10. if incoming.Beacon_type == "hb_button" {
  11. raw_data := incoming.Data
  12. hb_button_prefix_str := fmt.Sprintf("02010612FF5900")
  13. if strings.HasPrefix(raw_data, hb_button_prefix_str) {
  14. out_json.Namespace = "ddddeeeeeeffff5544ff"
  15. counter_str := fmt.Sprintf("0x%s", raw_data[22:24])
  16. counter, _ := strconv.ParseInt(counter_str, 0, 64)
  17. out_json.HB_ButtonCounter = counter
  18. battery_str := fmt.Sprintf("0x%s%s", raw_data[20:22], raw_data[18:20])
  19. battery, _ := strconv.ParseInt(battery_str, 0, 64)
  20. out_json.HB_Battery = battery
  21. out_json.TX_power = fmt.Sprintf("0x%s", "4")
  22. out_json.Beacon_type = "hb_button"
  23. out_json.HB_ButtonMode = "presence_button"
  24. }
  25. }
  26. return out_json
  27. }