OSDN Git Service

[NAN] Add retry count for transmitting L2 NAN messages
authorEtan Cohen <etancohen@google.com>
Tue, 10 May 2016 18:56:06 +0000 (11:56 -0700)
committerEtan Cohen <etancohen@google.com>
Mon, 23 May 2016 22:07:47 +0000 (15:07 -0700)
Bug: 28690414
Change-Id: I0a253f6d7e0d15f4bb50cae685c5e2496682cd67

wifi/java/android/net/wifi/nan/IWifiNanManager.aidl
wifi/java/android/net/wifi/nan/WifiNanManager.java
wifi/java/android/net/wifi/nan/WifiNanSession.java

index aaf43e5..efa6211 100644 (file)
@@ -50,7 +50,7 @@ interface IWifiNanManager
     void updatePublish(int clientId, int sessionId, in PublishConfig publishConfig);
     void updateSubscribe(int clientId, int sessionId, in SubscribeConfig subscribeConfig);
     void sendMessage(int clientId, int sessionId, int peerId, in byte[] message, int messageLength,
-            int messageId);
+            int messageId, int retryCount);
     void terminateSession(int clientId, int sessionId);
     int startRanging(int clientId, int sessionId, in RttManager.ParcelableRttParams parms);
 }
index 4f7545d..b08932b 100644 (file)
@@ -399,10 +399,11 @@ public class WifiNanManager {
      * {@hide}
      */
     public void sendMessage(int sessionId, int peerId, byte[] message, int messageLength,
-            int messageId) {
+            int messageId, int retryCount) {
         if (VDBG) {
             Log.v(TAG, "sendMessage(): sessionId=" + sessionId + ", peerId=" + peerId
-                    + ", messageLength=" + messageLength + ", messageId=" + messageId);
+                    + ", messageLength=" + messageLength + ", messageId=" + messageId
+                    + ", retryCount=" + retryCount);
         }
 
         int clientId;
@@ -416,7 +417,8 @@ public class WifiNanManager {
         }
 
         try {
-            mService.sendMessage(clientId, sessionId, peerId, message, messageLength, messageId);
+            mService.sendMessage(clientId, sessionId, peerId, message, messageLength, messageId,
+                    retryCount);
         } catch (RemoteException e) {
             e.rethrowAsRuntimeException();
         }
index 32872ba..3533c02 100644 (file)
@@ -33,6 +33,8 @@ public class WifiNanSession {
     private static final boolean DBG = false;
     private static final boolean VDBG = false; // STOPSHIP if true
 
+    public static final int MAX_SEND_RETRY_COUNT = 5;
+
     /**
      * @hide
      */
@@ -102,23 +104,24 @@ public class WifiNanSession {
     }
 
     /**
-     * Sends a message to the specified destination. Message transmission is
-     * part of the current discovery session - i.e. executed subsequent to a
-     * publish/subscribe
-     * {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)}
-     * event.
+     * Sends a message to the specified destination. Message transmission is part of the current
+     * discovery session - i.e. executed subsequent to a publish/subscribe
+     * {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} event.
      *
      * @param peerId The peer's ID for the message. Must be a result of an
-     *            {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)}
-     *            event.
+     *            {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} event.
      * @param message The message to be transmitted.
-     * @param messageLength The number of bytes from the {@code message} to be
-     *            transmitted.
-     * @param messageId An arbitrary integer used by the caller to identify the
-     *            message. The same integer ID will be returned in the callbacks
-     *            indicated message send success or failure.
+     * @param messageLength The number of bytes from the {@code message} to be transmitted.
+     * @param messageId An arbitrary integer used by the caller to identify the message. The same
+     *            integer ID will be returned in the callbacks indicated message send success or
+     *            failure.
+     * @param retryCount An integer specifying how many additional service-level (as opposed to PHY
+     *            or MAC level) retries should be attempted if there is no ACK from the receiver
+     *            (note: no retransmissions are attempted in other failure cases). A value of 0
+     *            indicates no retries. Max possible value is {@link #MAX_SEND_RETRY_COUNT}.
      */
-    public void sendMessage(int peerId, byte[] message, int messageLength, int messageId) {
+    public void sendMessage(int peerId, byte[] message, int messageLength, int messageId,
+            int retryCount) {
         if (mTerminated) {
             Log.w(TAG, "sendMessage: called on terminated session");
             return;
@@ -129,11 +132,30 @@ public class WifiNanSession {
                 return;
             }
 
-            mgr.sendMessage(mSessionId, peerId, message, messageLength, messageId);
+            mgr.sendMessage(mSessionId, peerId, message, messageLength, messageId, retryCount);
         }
     }
 
     /**
+     * Sends a message to the specified destination. Message transmission is part of the current
+     * discovery session - i.e. executed subsequent to a publish/subscribe
+     * {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} event. This is
+     * equivalent to {@link #sendMessage(int, byte[], int, int, int)} with a {@code retryCount} of
+     * 0.
+     *
+     * @param peerId The peer's ID for the message. Must be a result of an
+     *            {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} event.
+     * @param message The message to be transmitted.
+     * @param messageLength The number of bytes from the {@code message} to be transmitted.
+     * @param messageId An arbitrary integer used by the caller to identify the message. The same
+     *            integer ID will be returned in the callbacks indicated message send success or
+     *            failure.
+     */
+    public void sendMessage(int peerId, byte[] message, int messageLength, int messageId) {
+        sendMessage(peerId, message, messageLength, messageId, 0);
+    }
+
+    /**
      * Start a ranging operation with the specified peers. The peer IDs are obtained from an
      * {@link WifiNanSessionCallback#onMatch(int, byte[], int, byte[], int)} or
      * {@link WifiNanSessionCallback#onMessageReceived(int, byte[], int)} operation - i.e. can only