Advertisement
Guest User

Busch Welcome ABB Welcome Doorbell Message Format

a guest
Mar 23rd, 2023
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.43 KB | None | 0 0
  1. struct MessageHeader {
  2.     unsigned preamble:16; // 0x55ff
  3.     unsigned retransmissionFlag:1;
  4.     unsigned payloadLength:7;
  5.     unsigned replyFlag:1;
  6.     unsigned messageType:7;
  7.     unsigned destinationDeviceType:4;
  8.     unsigned destinationAddress:12;
  9.     unsigned sourceDeviceType:4;
  10.     unsigned sourceAddress:12;
  11.     unsigned messageID:8; // must be randomly generated
  12. };
  13.  
  14. // Message: Header + Payload + Checksum
  15.  
  16. enum MessageType {
  17.     DoorbellOutdoor = 0x01,
  18.     EndCall = 0x02,
  19.     AcceptCall = 0x03,
  20.     ManualVideo = 0x04,
  21.     Light = 0x09,
  22.     Call = 0x0a,
  23.     Door = 0x0d,
  24.     DoorbellIndoor = 0x11,
  25.     Actor = 0x16,
  26.     Video = 0x52,
  27. };
  28.  
  29. enum DeviceType {
  30.     IndoorStation = 0x1,
  31.     OutdoorStation = 0x2,
  32.     Gateway = 0x3,
  33.     Relay = 0x4,
  34.     Actor = 0x8,
  35.     Video = 0x9,
  36. };
  37.  
  38. uint8_t calculateChecksum(uint8_t *data, uint8_t length) {
  39.     uint8_t checksum = 0;
  40.     for (uint8_t i = 0; i < length; i++)
  41.         checksum = nextChecksum(*data++, checksum);
  42.     return ~checksum & 0xff;
  43. }
  44.  
  45. uint8_t nextChecksum(uint8_t data, uint8_t lastChecksum) {
  46.     uint16_t temp = lastChecksum ^ data;
  47.     temp = temp ^
  48.         (uint16_t)(((uint32_t)temp << 0x11) >> 0x10) ^
  49.         (uint16_t)(((uint32_t)temp << 0x12) >> 0x10) ^
  50.         (uint16_t)(((uint32_t)temp << 0x13) >> 0x10) ^
  51.         (uint16_t)(((uint32_t)temp << 0x14) >> 0x10) ^
  52.         (uint16_t)(((uint32_t)temp << 0x15) >> 0x10) ^
  53.         (uint16_t)(((uint32_t)temp << 0x16) >> 0x10) ^
  54.         (uint16_t)(((uint32_t)temp << 0x17) >> 0x10);
  55.     return (temp & 0xfe) ^ ((temp >> 8) & 1);
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement