Пример #1
0
        private void button5_Click(object sender, EventArgs e)
        {
            //Enroll
            string end = "\n";

            byte[] endBYTE       = Encoding.ASCII.GetBytes(end);
            char   startCode     = '#';
            byte   startCodeByte = Convert.ToByte(startCode);

            byte[] StoreFingerprint = { startCodeByte, 0x05 };

            byte[] FinalBytes = Combine(StoreFingerprint, endBYTE);
            port.Write(FinalBytes, 0, 4);

            System.Threading.Thread.Sleep(5000);

            int intBuffer;

            intBuffer = port.BytesToRead;
            byte[] byteBuffer = new byte[intBuffer];
            port.Read(byteBuffer, 0, intBuffer);

            string str = System.Text.Encoding.Default.GetString(byteBuffer);

            if (str == "1\n")
            {
                MessageBox.Show("Fingerprint Enrollment Success");
            }
            else
            {
                MessageBox.Show("Fingerprint Enrollment Failed");
            }
        }
Пример #2
0
        private void button6_Click(object sender, EventArgs e)
        {
            //Request entries  { startCodeByte, 0x02, 0x0000, endCodeByte};
            string MSG     = (textBox1.Text).Trim();
            string end     = "\n";
            int    MSGsize = MSG.Length;

            byte[] MSGByte     = Encoding.ASCII.GetBytes(MSG);
            byte[] endBYTE     = Encoding.ASCII.GetBytes(end);
            byte   MSGsizeByte = Convert.ToByte(MSGsize);

            char startCode     = '#';
            byte startCodeByte = Convert.ToByte(startCode);
            char endCode       = '\n';
            byte endCodeByte   = Convert.ToByte(endCode);

            byte[] RequestEntry = { startCodeByte, 0x02, endCodeByte };

            port.Write(RequestEntry, 0, 3);
            System.Threading.Thread.Sleep(2000);

            //The ESP32 sends back the request.
            int intBuffer;

            intBuffer = port.BytesToRead;
            byte[] byteBuffer = new byte[intBuffer];
            port.Read(byteBuffer, 0, intBuffer);

            string str = System.Text.Encoding.Default.GetString(byteBuffer);

            if (String.IsNullOrWhiteSpace(str))
            {
                MessageBox.Show("There are no Current Entries");
            }
            textBox1.Text = str;
        }