| |
---|
| | $devResponse = $serial->readPort(); |
---|
| | $serial->deviceClose(); |
---|
| | |
---|
| | $toReturn = trim(preg_replace('/\s+/', ' ', $devResponse)); |
---|
| | if(strpos($toReturn, "Thank you for doing your part") !== false){ // have sent more than 20 signals |
---|
| | $toReturn = trim(string_between_two_string($toReturn, 'Shared the Signal: ', 'Thank you for doing your part')); |
---|
| | }else{ |
---|
| | $toReturn = trim(string_between_two_string($toReturn, 'Shared the Signal: ', 'se try again')); |
---|
| | if(strpos($toReturn, "Shared the Signal") !== false){ // are sharing the signal |
---|
| | if(strpos($toReturn, "Thank you for doing your part") !== false){ // have sent more than 20 signals |
---|
| | $toReturn = trim(string_between_two_string($toReturn, 'Shared the Signal: ', 'Thank you for doing your part')); |
---|
| | }else{ |
---|
| | $toReturn = trim(string_between_two_string($toReturn, 'Shared the Signal: ', 'se try again')); |
---|
| | } |
---|
| | //echo $toReturn; // DEBUG |
---|
| | }else{ // you havent collected all badge types |
---|
| | $toReturn = 0; |
---|
| | } |
---|
| | //echo $toReturn; // DEBUG |
---|
| | |
---|
| | return $toReturn; |
---|
| | } |
---|
| | function string_between_two_string($str, $starting_word, $ending_word){ |
---|
| | $subtring_start = strpos($str, $starting_word); |
---|
| |
---|
| | |