Example #1
0
//===============================================
        // Initialize 
		public BtSerial(string address,string type_name)

		{
                // check that it doesn't affect the other connections            
                TurnON_BT_Radio();

                Thread.Sleep(50);

                bt_type_name = type_name;

                if (type_name.CompareTo("wocket") == 0)
                {
                    BT_TYPE = WOCKET;
                    MAX_BYTES = 4096;
                    
                    wocket_dc = new WocketsDecoder();
                    Wockets.Utils.WocketsTimer.InitializeTime();
                    cbuffer = new CircularBuffer(MAX_BYTES);
                }
                else if (type_name.CompareTo("lilypad") == 0)
                {
                    BT_TYPE = SERIAL_LILYPAD;
                    MAX_BYTES = 4096;
                }

                //Initialize buffer
                buffer = new byte[MAX_BYTES];
               

                address_set = SetAddress(address);
                   
		}
Example #2
0
        public void FromXML(string xml)
        {
            XmlDocument dom = new XmlDocument();

            dom.LoadXml(xml);
            XmlNode xNode = dom.DocumentElement;

            if ((xNode.Name == DECODERS_ELEMENT) && (xNode.HasChildNodes))
            {
                foreach (XmlNode jNode in xNode.ChildNodes)
                {
                    if (jNode.Name == Decoder.DECODER_ELEMENT)
                    {
                        DecoderTypes decoderType = DecoderTypes.Unknown;
                        foreach (XmlAttribute jAttribute in jNode.Attributes)
                        {
                            if (jAttribute.Name == TYPE_ATTRIBUTE)
                            {
                                decoderType = (DecoderTypes)Enum.Parse(typeof(DecoderTypes), jAttribute.Value, true);
                            }
                        }
                        Decoder decoder = null;
#if (PocketPC)
                        if (decoderType == DecoderTypes.HTCDiamondTouch)
                        {
                            decoder = new HTCDiamondTouchDecoder();
                        }
                        else
#endif
                        if (decoderType == DecoderTypes.MITes)
                        {
                            decoder = new MITesDecoder();
                        }
                        else if (decoderType == DecoderTypes.Wockets)
                        {
                            decoder = new WocketsDecoder();
                        }
                        else if (decoderType == DecoderTypes.Sparkfun)
                        {
                            decoder = new SparkfunDecoder();
                        }
                        else if (decoderType == DecoderTypes.HTCDiamondTouch)
                        {
                            decoder = new HTCDiamondTouchDecoder();
                        }

                        decoder.FromXML(jNode.OuterXml);
                        this.Insert(decoder._ID, decoder);
                    }
                }
            }
        }