if (slave)
{
//speed setzen
SP1.Write("AT+BAUD8");
SP2.Write("AT+BAUD8");
Thread.Sleep(1000);
Console.WriteLine("SP1: " + SP1.ReadExisting());
Console.WriteLine("SP2: " + SP2.ReadExisting());
SP1.BaudRate = 115200;
SP2.BaudRate = 115200;
//Antwort sollte OK Sein
SP1.Write("AT");
SP2.Write("AT");
Thread.Sleep(1000);
Console.WriteLine("SP1: " + SP1.ReadExisting());
Console.WriteLine("SP2: " + SP2.ReadExisting());
//Pin setzen
SP1.Write("AT+PIN1111");
SP2.Write("AT+PIN1111");
Thread.Sleep(1000);
Console.WriteLine("SP1: " + SP1.ReadExisting());
Console.WriteLine("SP2: " + SP2.ReadExisting());
//Name setzen
SP1.Write("AT+NAMESP1");
SP2.Write("AT+NAMESP2");
Thread.Sleep(1000);
Console.WriteLine("SP1: " + SP1.ReadExisting());
Console.WriteLine("SP2: " + SP2.ReadExisting());
//Name Sets the parity of the module AT+PN >> No parity check
SP1.Write("AT+PN");
SP2.Write("AT+PN");
Thread.Sleep(1000);
Console.WriteLine("SP1: " + SP1.ReadExisting());
Console.WriteLine("SP2: " + SP2.ReadExisting());
SP1.Write("HUHU");
SP2.Write("HUHU zurück");
Thread.Sleep(1000);
Console.WriteLine("SP1: " + SP1.ReadExisting());
Console.WriteLine("SP2: " + SP2.ReadExisting());
}
if (master)
{
SP2.ReadExisting();
SP2.BaudRate = 38400;
//Antwort sollte OK Sein
SP2.Write("AT\r\n");
Thread.Sleep(1000);
Console.WriteLine("SP2: " + SP2.ReadExisting());
//passwort setzen
SP2.Write("AT+PSWD=1111\r\n");
Thread.Sleep(1000);
Console.WriteLine("SP2: " + SP2.ReadExisting());
//speed setzen
SP2.Write("AT+UART=115200,0,0\r\n");
Thread.Sleep(1000);
Console.WriteLine("SP2: " + SP2.ReadExisting());
//master rolle setzen
SP2.Write("AT+ROLE=1\r\n");
Thread.Sleep(1000);
Console.WriteLine("SP2: " + SP2.ReadExisting());
//bind keine spec adresse
SP2.Write("AT+CMODE=2\r\n");
Thread.Sleep(1000);
Console.WriteLine("SP2: " + SP2.ReadExisting());
//binden
SP2.Write("AT+BIND=1111\r\n");
Thread.Sleep(1000);
Console.WriteLine("SP2: " + SP2.ReadExisting());
}