How do I encode a configuration downlink for a 4-20mA Current Loop Sensor?

How do I encode a configuration downlink for a 4-20mA Current Loop Sensor?

NOTE:  All downlinks must contain a total of (8) bytes, padded with zeros at the end when necessary.


4-20mA Current Loop Sensor Threshold Configuration Example:
      11 00 0C 96 04 17 04 A8
      11            Downlink Message Type ( 0x11 = 4-20mA Current Loop Sensor )
      00            Configuration Mode (0x00 = Threshold Mode)
      0C            Periodic Reporting (0x0C = 12 Hours)
      96            Notification Restore Margin (0x96 = 150 = 1.50mA)
      0417        Lower Analog Measurement Threshold (0x0417 = 1047 = 10.47mA)
      04A8       Upper Analog Measurement Threshold (0x04A8 = 1192  = 11.92mA)

4-20mA Current Loop Sensor Report on Change Configuration Example:
      11 01 F8 00 01 B4 01 E9
      11            Downlink Message Type ( 0x11 = 4-20mA Current Loop Sensor )
      01            Configuration Mode (0x01 = Report on Change Mode)
      F8            Periodic Reporting (0xF8 120 minutes)
      00            Not Used
      01B4       Analog Measurement Increase (0x01B4 = 436 -> 4.36 mA)
      01E9       Analog Measurement Decrease (0x01E9 = 489 -> 4.89 mA)

Note: The Periodic Interval can be set between 1 minute and 127 hours.
Values below 0x80 are in hours e.g. 0x18 = 24 hours
Values above 0x80 are in minutes e.g. 0x9E = 30 minutes

If the configuration is successful the sensor will respond with a Downlink Acknowledge message:
      1 0 FF 02
      1                   Protocol Version (currently always 0x1)
      0                   Packet Counter, increments by 1 each message and wraps from 0xF to 0x0
      FF                 Message Type (Downlink ACK = 0xFF)
      02                 Downlink Message Valid (Invalid/Undefined = 0x01, Valid = 0x02)