state machine for wifi