Package org.nfctools.llcp.pdu

Examples of org.nfctools.llcp.pdu.Symmetry


  @Test
  public void testWellKnownServiceConnectWithSendAndDisconnect() throws Exception {
    DummyServiceAccessPoint serviceAccessPoint = new DummyServiceAccessPoint("Hello", COM_ANDROID_NPP);
    connectionManager.registerWellKnownServiceAccessPoint(COM_ANDROID_NPP, serviceAccessPoint);
    AbstractProtocolDataUnit processPdu = new Symmetry().processPdu(connectionManager);
    assertTrue(processPdu.toString(), processPdu instanceof Connect);
    assertEquals(0, connectionManager.getOpenConnectionsSize());

    Connect connect = (Connect)processPdu;
    assertEquals(1, connect.getDestinationServiceAccessPoint());
View Full Code Here


    assertSymmetryState();
  }

  private void assertSymmetryState() {
    for (int x = 0; x < 10; x++) {
      AbstractProtocolDataUnit processPdu = new Symmetry().processPdu(connectionManager);
      assertTrue(processPdu.toString(), processPdu instanceof Symmetry);
    }
  }
View Full Code Here

    serviceAccessPoint.onSendSucceeded(this);
  }

  protected AbstractProtocolDataUnit getMessageToSend() {
    if (messageToSend == null)
      return new Symmetry();
    AbstractProtocolDataUnit pdu = messageToSend;
    messageToSend = null;
    return pdu;
  }
View Full Code Here

  @Override
  public void onConnection(NFCIPConnection connection) throws IOException {
    LlcpConnectionManager connectionManager = connectionManagerFactory.createInstance();
    connectionManager.init(extractParameters(connection.getGeneralBytes()));
    try {
      byte[] data = connection.isInitiator() ? pduDecoder.encode(new Symmetry()) : connection.receive();
      while (!Thread.interrupted()) {
        AbstractProtocolDataUnit requestPdu = pduDecoder.decode(data);
        AbstractProtocolDataUnit responsePdu = requestPdu.processPdu(connectionManager);
        byte[] pdu = pduDecoder.encode(responsePdu);
        connection.send(pdu);
View Full Code Here

    return Collections.emptyList();
  }

  public AbstractProtocolDataUnit onLlcpActive() {
    // TODO make messageToSend method local variable, implement Llcp interface similar to SnepAgent
    messageToSend = new Symmetry();
    handlePendingConnectionTimeout();
    if (pendingConnections.isEmpty()) {
      serviceDiscovery.onLlcpActive(this);
      for (Entry<Integer, ServiceAccessPoint> entry : services.entrySet()) {
        ServiceAccessPoint serviceAccessPoint = entry.getValue();
View Full Code Here

        llcpSocket = getOpenLlcpSocket(new AddressPair(remoteAddress, localAddress));
        if (llcpSocket != null) {
          log.info("Closing open connection");
          closeSocket(llcpSocket);
          llcpSocket.onDisconnect();
          return new Symmetry();
        }
      case 0x02: // no service bound
      case 0x03: // rejected by service layer
      case 0x10: // perm not accept connection at same target point
      case 0x11: // perm not accept connection at any target point
        if (pendingConnections.containsKey(localAddress)) {
          Integer pendingLocalAddress = Integer.valueOf(localAddress);
          log.info("Closing pending connection");
          PendingConnection pendingConnection = pendingConnections.remove(pendingLocalAddress);
          pendingConnection.getServiceAccessPoint().onConnectFailed();
        }
        return new Symmetry();
      case 0x21: // temp not accept connection at same target point
      case 0x20: // temp not accept connection at any target point
        // TODO add additional timeout for this messages
        return new Symmetry();
      default:
        return new Symmetry();
    }
  }
View Full Code Here

TOP

Related Classes of org.nfctools.llcp.pdu.Symmetry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.