📄 irlapstatendm.java
字号:
/*
**************************************************************************
** $Header: /cvsroot/jred/jred/src/com/synchrona/jred/irlap/IrLAPStateNDM.java,v 1.2 2000/07/30 20:18:12 mpatters Exp $
**
** Copyright (C) 2000 Synchrona, Inc. All rights reserved.
**
** This file is part of JRed, a 100% Java implementation of the IrDA
** infrared communications protocols.
**
** This file may be distributed under the terms of the Synchrona Public
** License as defined by Synchrona, Inc. and appearing in the file
** LICENSE included in the packaging of this file. The Synchrona Public
** License is based on the Q Public License as defined by Troll Tech AS
** of Norway; it differs only in its use of the courts of Florida, USA
** rather than those of Oslo, Norway.
**************************************************************************
*/
package com.synchrona.jred.irlap;
import com.synchrona.util.Utilities;
/**
* Implement IrLAP's Normal Disconnected Mode.
*/
class IrLAPStateNDM extends IrLAPState {
//--------------------------------------------------------------------
// Implement Singleton pattern
//--------------------------------------------------------------------
private static IrLAPState s_instance = new IrLAPStateNDM();
public static IrLAPState getInstance() {
return s_instance;
}
private IrLAPStateNDM() {
super();
}
//--------------------------------------------------------------------
// (Re)Implementation of IrLAPState
//--------------------------------------------------------------------
public void connectionRequest(IrLAPContext context, int nDestination) throws Exception {
if ( !context.isMediaBusy() ) {
context.setMediaBusy(true);
context.nextState(IrLAPStateSetup.getInstance());
byte yConnection = context.generateConnectionAddress();
context.sendSNRM(nDestination, yConnection);
context.startFTimer();
context.zeroRetryCount();
}
}
/**
* Begin active discovery of other IrDA devices. Active discovery is
* not implemented in this version of J<font color="#ff0000">Red</font>.
*/
public void discoveryRequest(IrLAPContext context) throws Exception {
logIfEnabled("discoveryRequest is not implemented yet.");
}
public void handleSNRM(IrLAPContext context, int nSource, int nDestination, byte yConnection, byte [] ayParameters) throws Exception {
logIfEnabled("handleSNRM: " + Utilities.bytesToString(ayParameters, 0, ayParameters.length));
context.setMediaBusy(true);
context.nextState(IrLAPStateConnect.getInstance());
context.waitMinimumTurnaroundTime();
context.connectIndication(nSource, yConnection, ayParameters);
}
public void handleXID(IrLAPContext context, int nSource, int nDestination, byte ySlot, boolean bCommand, byte [] ayHints) throws Exception {
if ( bCommand ) {
context.generateResponseSlot((byte) 6, ySlot);
if ( context.getResponseSlot() == ySlot ) {
context.sendDiscoveryResponse(nSource);
context.setFrameSent(true);
context.startQueryTimer();
}
context.setMediaBusy(true);
context.nextState(IrLAPStateReply.getInstance());
}
}
//--------------------------------------------------------------------
// End of implementation of IrLAPState
//--------------------------------------------------------------------
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -