Esempio n. 1
0
 /// <summary>
 /// Returns the Hash code of this object.
 /// </summary>
 /// <returns>The Hash code of this object.</returns>
 public override int GetHashCode()
 {
     return(HardwareVersion.GetHashCode() + FirmwareVersion.GetHashCode());
 }
Esempio n. 2
0
        /// <summary>
        /// Determines the XBee protocol based on the given Hardware and firmware versions.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="hardwareVersion">The hardware version of the protocol to determine.</param>
        /// <param name="firmwareVersion">The firmware version of the protocol to determine.</param>
        /// <returns>The XBee protocol corresponding to the given hardware and firmware versions.</returns>
        public static XBeeProtocol DetermineProtocol(this XBeeProtocol source, HardwareVersion hardwareVersion, string firmwareVersion)
        {
            if (hardwareVersion == null || firmwareVersion == null || hardwareVersion.Value < 0x09)
            {
                return(XBeeProtocol.UNKNOWN);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XC09_009.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.XC09_038.GetValue())
            {
                return(XBeeProtocol.XCITE);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XT09_XXX.GetValue())
            {
                if ((firmwareVersion.Length == 4 && firmwareVersion.StartsWith("8")) ||
                    (firmwareVersion.Length == 5 && firmwareVersion[1] == '8'))
                {
                    return(XBeeProtocol.XTEND_DM);
                }
                return(XBeeProtocol.XTEND);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XB24_AXX_XX.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.XBP24_AXX_XX.GetValue())
            {
                if ((firmwareVersion.Length == 4 && firmwareVersion.StartsWith("8")))
                {
                    return(XBeeProtocol.DIGI_MESH);
                }
                return(XBeeProtocol.RAW_802_15_4);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XB24_BXIX_XXX.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.XBP24_BXIX_XXX.GetValue())
            {
                if ((firmwareVersion.Length == 4 && firmwareVersion.StartsWith("1") && firmwareVersion.EndsWith("20")) ||
                    (firmwareVersion.Length == 4 && firmwareVersion.StartsWith("2")))
                {
                    return(XBeeProtocol.ZIGBEE);
                }
                else if (firmwareVersion.Length == 4 && firmwareVersion.StartsWith("3"))
                {
                    return(XBeeProtocol.SMART_ENERGY);
                }
                return(XBeeProtocol.ZNET);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XBP09_DXIX_XXX.GetValue())
            {
                if ((firmwareVersion.Length == 4 && firmwareVersion.StartsWith("8") ||
                     (firmwareVersion.Length == 4 && firmwareVersion[1] == '8')) ||
                    (firmwareVersion.Length == 5 && firmwareVersion[1] == '8'))
                {
                    return(XBeeProtocol.DIGI_MESH);
                }
                return(XBeeProtocol.DIGI_POINT);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XBP09_XCXX_XXX.GetValue())
            {
                return(XBeeProtocol.XC);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XBP08_DXXX_XXX.GetValue())
            {
                return(XBeeProtocol.DIGI_POINT);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XBP24B.GetValue())
            {
                if (firmwareVersion.Length == 4 && firmwareVersion.StartsWith("3"))
                {
                    return(XBeeProtocol.SMART_ENERGY);
                }
                return(XBeeProtocol.ZIGBEE);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XB24_WF.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.WIFI_ATHEROS.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.SMT_WIFI_ATHEROS.GetValue())
            {
                return(XBeeProtocol.XBEE_WIFI);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XBP24C.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.XB24C.GetValue())
            {
                if (firmwareVersion.Length == 4 && firmwareVersion.StartsWith("5"))
                {
                    return(XBeeProtocol.SMART_ENERGY);
                }
                return(XBeeProtocol.ZIGBEE);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XSC_GEN3.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.SRD_868_GEN3.GetValue())
            {
                if (firmwareVersion.Length == 4 && firmwareVersion.StartsWith("8"))
                {
                    return(XBeeProtocol.DIGI_MESH);
                }
                else if (firmwareVersion.Length == 4 && firmwareVersion.StartsWith("1"))
                {
                    return(XBeeProtocol.DIGI_POINT);
                }
                return(XBeeProtocol.XC);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XBEE_CELL_TH.GetValue())
            {
                return(XBeeProtocol.UNKNOWN);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XLR_MODULE.GetValue())
            {
                // This is for the old version of the XLR we have (K60), and it is
                // reporting the firmware of the module (8001), this will change in
                // future (after K64 integration) reporting the hardware and firmware
                // version of the baseboard (see the case HardwareVersionEnum.XLR_BASEBOARD).
                // TODO maybe this should be removed in future, since this case will never be released.
                return(XBeeProtocol.XLR);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XLR_BASEBOARD.GetValue())
            {
                // XLR devices with K64 will report the baseboard hardware version,
                // and also firmware version (the one we have here is 1002, but this value
                // is not being reported since is an old K60 version, the module fw version
                // is reported instead).

                // TODO [XLR_DM] The next version of the XLR will add DigiMesh support should be added.
                // Probably this XLR_DM and XLR will depend on the firmware version.

                return(XBeeProtocol.XLR);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XB900HP_NZ.GetValue())
            {
                return(XBeeProtocol.DIGI_POINT);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XBP24C_TH_DIP.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.XB24C_TH_DIP.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.XBP24C_S2C_SMT.GetValue())
            {
                if (firmwareVersion.Length == 4 && (firmwareVersion.StartsWith("5") || firmwareVersion.StartsWith("6")))
                {
                    return(XBeeProtocol.SMART_ENERGY);
                }
                else if (firmwareVersion.StartsWith("2"))
                {
                    return(XBeeProtocol.RAW_802_15_4);
                }
                else if (firmwareVersion.StartsWith("9"))
                {
                    return(XBeeProtocol.DIGI_MESH);
                }
                return(XBeeProtocol.ZIGBEE);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.SX_PRO.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.SX.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.XTR.GetValue())
            {
                if (firmwareVersion.StartsWith("2"))
                {
                    return(XBeeProtocol.XTEND);
                }
                else if (firmwareVersion.StartsWith("8"))
                {
                    return(XBeeProtocol.XTEND_DM);
                }
                return(XBeeProtocol.SX);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.S2D_SMT_PRO.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.S2D_SMT_REG.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.S2D_TH_PRO.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.S2D_TH_REG.GetValue())
            {
                if (firmwareVersion.StartsWith("8"))
                {
                    return(XBeeProtocol.THREAD);
                }
                return(XBeeProtocol.ZIGBEE);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.CELLULAR_CAT1_LTE_VERIZON.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.CELLULAR_3G.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.CELLULAR_LTE_VERIZON.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.CELLULAR_LTE_ATT.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.CELLULAR_NBIOT_EUROPE.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.CELLULAR_3_CAT1_LTE_ATT.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.CELLULAR_3_LTE_M_VERIZON.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.CELLULAR_3_LTE_M_ATT.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.CELLULAR_3_LTE_M_ATT_TELIT.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.CELLULAR_3_CAT1_LTE_VERIZON.GetValue())
            {
                return(XBeeProtocol.CELLULAR);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XBEE3_MICRO.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.XBEE3_TH.GetValue() ||
                     hardwareVersion.Value == HardwareVersionEnum.XBEE3_RESERVED.GetValue())
            {
                if (firmwareVersion.StartsWith("2"))
                {
                    return(XBeeProtocol.RAW_802_15_4);
                }
                else if (firmwareVersion.StartsWith("3"))
                {
                    return(XBeeProtocol.DIGI_MESH);
                }
                return(XBeeProtocol.ZIGBEE);
            }
            else if (hardwareVersion.Value == HardwareVersionEnum.XB8X.GetValue())
            {
                return(XBeeProtocol.DIGI_MESH);
            }

            return(XBeeProtocol.ZIGBEE);
        }