/** * Checks whether the routing table is enabled * * @return true if the routing table is enabled * @throws RoutingTableException if the information can't be retrieved */ public boolean isEnabled() throws RoutingTableException { try { return rtInterface.isEnabled(); } catch (RemoteException ex) { Log.e(TAG, "isEnabled() fails: " + ex); throw new RoutingTableException(OpenNfcException.SERVICE_COMMUNICATION_FAILED); } }
void closeTable(int handle) throws RoutingTableException { try { rtInterface.close(handle); } catch (RemoteException ex) { Log.e(TAG, "closeTable() fails: " + ex); throw new RoutingTableException(OpenNfcException.SERVICE_COMMUNICATION_FAILED); } }
/** * Disables or enables the routing table * * @return true if the routing table is enabled * @param isEnabled true - to enable, false - to disable the routing table * @throws RoutingTableException if the operation can't be accomplished */ public void enableTable(boolean isEnabled) throws RoutingTableException { try { int status = rtInterface.enable(isEnabled); if (status != 0) { throw new RoutingTableException(status); } } catch (RemoteException ex) { Log.e(TAG, "isEnabled() fails: " + ex); throw new RoutingTableException(OpenNfcException.SERVICE_COMMUNICATION_FAILED); } }
void applyTable(int handle) throws RoutingTableException { try { int status = rtInterface.apply(handle); if (DEBUG) { Log.d(TAG, "applyTable(): status=" + Integer.toHexString(status)); } if (status != 0) { throw new RoutingTableException(status); } } catch (RemoteException ex) { Log.e(TAG, "applyTable() fails: " + ex); throw new RoutingTableException(OpenNfcException.SERVICE_COMMUNICATION_FAILED); } }
void modifyTable(int handle, int operation, int index, RoutingTableEntry entry) throws RoutingTableException { try { int status = rtInterface.modify(handle, operation, index, entry); if (DEBUG) { Log.d(TAG, "modifyTable(): status=" + Integer.toHexString(status)); } if (status != 0) { throw new RoutingTableException(status); } } catch (RemoteException ex) { Log.e(TAG, "modifyTable() fails: " + ex); throw new RoutingTableException(OpenNfcException.SERVICE_COMMUNICATION_FAILED); } }
/** * Reads the routing table from the NFC controller * * @return the routing table read from the NFC controller * @throws RoutingTableException if the routing table can't be read */ public RoutingTable readTable() throws RoutingTableException { RoutingTable routingTable = null; try { int handle = rtInterface.read(); if (handle != 0) { routingTable = new RoutingTable(handle, this); } else { throw new RoutingTableException(ConstantAutogen.W_ERROR_FEATURE_NOT_SUPPORTED); } } catch (RemoteException ex) { Log.e(TAG, "readTable() fails: " + ex); throw new RoutingTableException(OpenNfcException.SERVICE_COMMUNICATION_FAILED); } return routingTable; }
/** * Returns the entries of a routing table * * @param handle Open NFC's handle for the routing table * @return the array of the entries of the routing table */ RoutingTableEntry[] getTableEntries(int handle) throws RoutingTableException { RoutingTableEntry[] entries = null; if (targets == null) { fillTargetsList(); } try { entries = rtInterface.getEntries(handle); for (RoutingTableEntry entry : entries) { int targetId = entry.getTargetId(); int length = targets.length; if (targetId < length) { entry.setTarget(targets[entry.getTargetId()]); } else { Log.e(TAG, "Can't detect target for id=" + targetId + ")"); throw new RoutingTableException(ConstantAutogen.W_ERROR_BAD_PARAMETER); } } return entries; } catch (RemoteException ex) { Log.e(TAG, "getTableEntries() fails: " + ex); throw new RoutingTableException(OpenNfcException.SERVICE_COMMUNICATION_FAILED); } }