SHARE
TWEET

Untitled

a guest Mar 24th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Generating *raw data* string for BadgeMessage.
  2.  
  3. #### Example of BadgeMessage:
  4. ``` json
  5. <Elpas><DeviceId>00:25:55:00:44:B8</DeviceId>
  6. <Type>BadgeMessage</Type><RawData>BFF874D565612E</RawData>
  7. <Id>03F874</Id><Motion>1</Motion><Battery>1</Battery>
  8. <RSSI>213</RSSI><Noise>101</Noise><Buttons>2</Buttons>
  9. <PacketId>2997</PacketId><Group>61</Group><Data>2E</Data></Elpas>
  10. ```
  11.  
  12. #### Explanation of the first 2 byte forming added as a comment below.
  13.  
  14. >**badge** - badge hex Neuron ID as string
  15. >
  16. >**motion** - *1* if in motion. *0* if motionless.
  17. >
  18. >**battery** - *1* if battery is OK. *0* if battery is low.
  19. >
  20. >**rssi** - integer value in 0-255 range
  21. >
  22. >**noise** - integer value in 0-255 range
  23. >
  24. >**data** - hex value as string
  25. >
  26. >**group** - hex value as string
  27. >
  28. >**button1** - *1* if button is pressed. *0* if button is released.
  29. >
  30. >**button2** - *1* if button is pressed. *0* if button is released.
  31. >
  32. >**message_type** - *11* if event message, *00* if supervision message
  33. >
  34.  
  35. ##### According to our example:
  36. >**badge** - 03F874
  37. >
  38. >**motion** - *1*
  39. >
  40. >**battery** - *1*
  41. >
  42. >**rssi** - *213*
  43. >
  44. >**noise** - *101*
  45. >
  46. >**data** - *2E*
  47. >
  48. >**button1** - *0*
  49. >
  50. >**button2** - *1*
  51. >
  52. >**message_type** - *11*
  53. >
  54. >**group** - *61*
  55. >
  56.  
  57. #### Description of the `first` byte:
  58.  
  59. >Bit 7 (MSB) - Motion bit (0 - motionless, 1 - motion)
  60. >
  61. >Bit6 - B1 bit( 1- Button 1 press, 0- Button 1 release)
  62. >
  63. >Bit5 - Low Battery bit (1 - Battery OK, 0 - Low Battery)
  64. >
  65. >Bit 4 - B2 bit( 1- Button 2 press, 0- Button 2 release)
  66. >
  67. >Bit 3-2 - Message Status bits ( 00 - Supervision message, 11 - Event message)
  68. >
  69. >Bit 1-0(LSB) - The MSB bits of the ID.
  70. >
  71.  
  72. ``` json    
  73. lsb = bin(int(badge, 16))[2:4]
  74. ```
  75.  
  76. ##### According to our example:
  77. >Bit 7 (MSB) - Motion bit - *1*
  78. >
  79. >Bit6 - B1 bit *0*
  80. >
  81. >Bit5 - Low Battery bit *1*
  82. >
  83. >Bit 4 - B2 bit *1*
  84. >
  85. >Bit 3-2 - Message Status bits *11*
  86. >
  87. >Bit 1-0(LSB) - The MSB bits of the ID -*11*
  88. >
  89. ``` json    
  90. lsb = bin(int(badge, 16))[2:4]
  91. IDbadge=03F029  
  92. lsb = bin(int("03F874", 16))[2:4] =  11
  93. ```
  94.  
  95.  
  96. `first`= hex((**motion**(1/0)|**button1**(1/0)|**battery**(0/1)|**button2**(0/1)|**message_type**(00/11)|**lsb**(__)), 2))[2:]
  97.  
  98. ##### According to our example:
  99.  
  100. >`first`= hex((1|0|1|1|11|11), 2))[2:] = BF
  101. >
  102.  
  103.  
  104. **_raw_** = **first**|**badge**[2:]|hex(**rssi**)[2:]|hex(**noise**)[2:]|**group**|**data**
  105.  
  106. ##### According to our example:
  107. raw = BFF874D565612E
  108. >**_raw_** = BF|F874|D5|65|61|2E
  109. >
  110.    
  111. ### Convert Temperature (*data* in BadgeMessage; *group* = _12_)
  112.  
  113.     temp_dict = {0: 806, 1: 798, 2: 790, 3: 781, 4: 772, 5: 764, 6: 755, 7: 745, 8: 736, 9: 727, 10: 717, 11: 707,
  114.                      12: 697, 13: 687, 14: 677, 15: 667, 16: 656, 17: 646, 18: 635, 19: 625, 20: 614, 21: 604, 22: 593,
  115.                      23: 582, 24: 572, 25: 561, 26: 550, 27: 539, 28: 529, 29: 518, 30: 507, 31: 497, 32: 486, 33: 476,
  116.                      34: 466, 35: 456, 36: 445, 37: 435, 38: 426, 39: 416, 40: 406, 41: 396, 42: 387, 43: 378, 44: 368,
  117.                      45: 359, 46: 350, 47: 342, 48: 333, 49: 324, 50: 316, 51: 308, 52: 300, 53: 292, 54: 284, 55: 277,
  118.                      56: 270, 57: 262, 58: 255, 59: 249, 60: 242, 61: 236, 62: 229, 63: 223, 64: 217, 65: 211, 66: 205,
  119.                      67: 200, 68: 194, 69: 189, 70: 184, 71: 179, 72: 174, 73: 169, 74: 165, 75: 160, 76: 156, 77: 151,
  120.                      78: 147, 79: 143, 80: 139, -11: 882, -43: 989, -40: 984, -35: 974, -34: 972, -33: 970, -32: 967,
  121.                      -31: 965, -30: 962, -29: 959, -28: 956, -27: 953, -26: 950, -25: 947, -24: 943, -23: 940, -22: 936,
  122.                      -21: 932, -20: 928, -19: 924, -18: 919, -17: 914, -16: 909, -15: 904, -14: 899, -13: 893, -12: 888,
  123.                      -1: 814, -10: 876, -9: 870, -8: 863, -7: 857, -6: 850, -5: 843, -4: 836, -3: 829, -2: 821}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top