1 #pragma once
2 
3 // 1-wire chip family definition (merge from http://owfs.sourceforge.net/family.html and http://owfs.org/index.php?page=family-code-list)
4 enum _e1WireFamilyType
5 {
6    silicon_serial_number	= 0x01,
7    multikey_1153bit_secure	= 0x02,
8    econoram_time_chip	= 0x04,
9    Addresable_Switch	= 0x05,
10    _4k_memory_ibutton	= 0x06,
11    _1k_memory_ibutton	= 0x08,
12    _1k_add_only_memory	= 0x09,
13    _16k_memory_ibutton	 = 0x0A,
14    _16k_add_only_memory	 = 0x0B,
15    _64k_memory_ibutton	 = 0x0C,
16    _64k_add_only_memory	 = 0x0F,
17    high_precision_digital_thermometer	= 0x10,
18    dual_addressable_switch_plus_1k_memory	= 0x12,
19    _256_eeprom	= 0x14,
20    crypto_ibutton	= 0x16,
21    SHA_iButton	= 0x18,
22    _4k_Monetary	 = 0x1A,
23    battery_id_monitor_chip	 = 0x1B,
24    _4k_EEPROM_with_PIO	 = 0x1C,
25    _4k_ram_with_counter	 = 0x1D,
26    Battery_monitor	= 0x1E,
27    microlan_coupler	 = 0x1F,
28    quad_ad_converter	= 0x20,
29    Thermachron	= 0x21,
30    Econo_Digital_Thermometer	= 0x22,
31    _4k_eeprom	= 0x23,
32    time_chip	= 0x24,
33    smart_battery_monitor	= 0x26,
34    time_chip_with_interrupt	= 0x27,
35    programmable_resolution_digital_thermometer	= 0x28,
36    _8_channel_addressable_switch	= 0x29,
37    digital_potentiometer	 = 0x2C,
38    _1k_eeprom	 = 0x2D,
39    battery_monitor_and_charge_controller	 = 0x2E,
40    high_precision_li_battery_monitor	= 0x30,
41    efficient_addressable_single_cell_rechargable_lithium_protection_ic	= 0x31,
42    Battery = 0x32,
43    _1k_protected_eeprom_with_SHA_1	= 0x33,
44    SHA_1_Battery = 0x34,
45    Battery_Fuel_Gauge = 0x35,
46    high_precision_coulomb_counter	= 0x36,
47    Password_protected_32k_eeprom	= 0x37,
48    dual_channel_addressable_switch	 = 0x3A,
49    Temperature_memory = 0x3B,
50    stand_alone_fuel_gauge = 0x3D,
51    Temperature_Logger_8k_mem	= 0x41,
52    Temperature_IO	= 0x42,
53    Memory = 0x43,
54    SHA_1_Authenticator = 0x44,
55    multichemistry_battery_fuel_gauge	= 0x51,
56    Environmental_Monitors = 0x7E,
57    Serial_ID_Button	= 0x81,
58    Authorization = 0x82,
59    dual_port_plus_time	= 0x84,
60    _48_bit_node_address_chip	= 0x89,
61    _16k_add_only_uniqueware	 = 0x8B,
62    _64k_add_only_uniqueware	 = 0x8F,
63    Rotation_Sensor = 0xA0,
64    Vibratio	= 0xA1,
65    AC_Voltage	= 0xA2,
66    IR_Temperature	= 0xA6,
67    _21_channels_thermocouple_Converter	= 0xB1,
68    DC_Current_or_Voltage	= 0xB2,
69    _168_channels_thermocouple_Converter	= 0xB3,
70    Ultra_Violet_Index	= 0xEE,
71    Moisture_meter_4_Channel_Hub	= 0xEF,
72    Programmable_Miroprocessor	= 0xFC,
73    LCD_Swart	 = 0xFF,
74 
75    _e1WireFamilyTypeUnknown = 0
76 };
77 
78 struct _t1WireDevice
79 {
80    _e1WireFamilyType family;
81    std::string devid;
82    std::string filename;
83 
84    bool operator<(_t1WireDevice other) const
85    {
86 	   return devid > other.devid;
87    }
88 };
89 
90 _e1WireFamilyType ToFamily(const std::string& str);
91 
92 
93 #define DEVICE_ID_SIZE  6
94 void DeviceIdToByteArray(const std::string &deviceId,/*out*/unsigned char* byteArray);
95 std::string ByteArrayToDeviceId(const unsigned char* byteArray);
96 
97 unsigned char Crc16(const unsigned char* byteArray,size_t arraySize);
98