/** Stop the transfer */ public void stop() { if (V) Log.v(TAG, "stop"); if (mSession != null) { if (V) Log.v(TAG, "Stop mSession"); mSession.disconnect(); mSession = null; } }
/** Push the message over Obex client session */ private void sendEvent(String str, int masId) { if (str != null && (str.length() > 0)) { if (V) { Log.v(TAG, "--------------"); Log.v(TAG, " CONTENT OF EVENT REPORT FILE: " + str); } final String FILENAME = "EventReport" + masId; FileOutputStream fos = null; File file = new File(mContext.getFilesDir() + "/" + FILENAME); file.delete(); try { fos = mContext.openFileOutput(FILENAME, Context.MODE_PRIVATE); fos.write(str.getBytes()); fos.flush(); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } File fileR = new File(mContext.getFilesDir() + "/" + FILENAME); if (fileR.exists() == true) { if (V) { Log.v(TAG, " Sending event report file for Mas " + masId); } try { if (mSession != null) { mSession.sendEvent(fileR, (byte) masId); } } catch (Exception e) { e.printStackTrace(); } } else { if (V) { Log.v(TAG, " ERROR IN CREATING SEND EVENT OBJ FILE"); } } } else if (V) { Log.v(TAG, "sendEvent(null, " + masId + ")"); } }
/** Connect the MNS Obex client to remote server */ private void startObexSession(ObexTransport transport) throws NullPointerException { if (V) Log.v(TAG, "Create Client session with transport " + transport.toString()); mSession = new BluetoothMnsObexSession(mContext, transport); mSession.connect(); }