62 lines
1.3 KiB
Arduino
62 lines
1.3 KiB
Arduino
|
char* ip_remote = "IpHoSt";
|
||
|
uint8_t ipCount =0;
|
||
|
boolean ok_ip = false;
|
||
|
uint8_t pos_ip=0;
|
||
|
|
||
|
void test_ip(byte inByte)
|
||
|
{
|
||
|
if ((inByte == ip_remote[ipCount])&&(!ok_ip))
|
||
|
{
|
||
|
ipCount++;
|
||
|
if (ipCount==strlen(ip_remote))
|
||
|
{
|
||
|
ipCount=0;
|
||
|
ok_ip=true;
|
||
|
}
|
||
|
}
|
||
|
else if (ok_ip) save_ip(inByte);
|
||
|
else ipCount=0;
|
||
|
}
|
||
|
|
||
|
void save_ip(byte inByte)
|
||
|
{
|
||
|
if (inByte=='/')
|
||
|
{
|
||
|
if(pos_ip>0)
|
||
|
{
|
||
|
EEPROM.write(pos_ip - 1, 0x00);
|
||
|
ip_host[pos_ip - 1] = 0x00;
|
||
|
ok_ip=false;
|
||
|
pos_ip = 0;
|
||
|
software_Reset();
|
||
|
}
|
||
|
else pos_ip=1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
if (pos_ip<17)
|
||
|
{
|
||
|
EEPROM.write(pos_ip - 1 , inByte);
|
||
|
ip_host[pos_ip - 1] = inByte;
|
||
|
pos_ip++;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void test_incoming(byte inByte)
|
||
|
{
|
||
|
if (inByte == test_message[0])
|
||
|
{
|
||
|
incomming_count = 0;
|
||
|
incomming_message[incomming_count] = inByte;
|
||
|
incomming_count++;
|
||
|
}
|
||
|
else if((inByte == test_message[incomming_count])&&(incomming_count<=11))
|
||
|
{
|
||
|
incomming_count++;
|
||
|
}
|
||
|
else if ((incomming_count>11)&&(incomming_count<16)) { incomming_message[incomming_count] = inByte; incomming_count++; if (incomming_count>15) incoming_ok=true;}
|
||
|
//else { incomming_count=0; wifly.print("E");}
|
||
|
}
|
||
|
|