String[] tokens = string.split(" ");
if (tokens.length < 2) {
throw new IllegalArgumentException("Malformed event " + string);
}
if (tokens[0].endsWith("PBC-REQ")) event = PBC_REQ;
else if (tokens[0].endsWith("PBC-RESP")) event = PBC_RSP;
else if (tokens[0].endsWith("ENTER-PIN")) event = ENTER_PIN;
else if (tokens[0].endsWith("SHOW-PIN")) event = SHOW_PIN;
else throw new IllegalArgumentException("Malformed event " + string);
device = new WifiP2pDevice();
device.deviceAddress = tokens[1];
if (event == SHOW_PIN) {
pin = tokens[2];
}