Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2f972e92 authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Fix primary adv interval range

INTERVAL_MAX of primary advertising interval needs to be reduced to
account for the range calculation.

Bug: 64181062
Change-Id: I154e09d95e222c95047c2319f1371d822724345e
parent b143b491
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -1699,6 +1699,10 @@ static void advertiseCleanupNative(JNIEnv* env, jobject object) {
  }
}

static uint32_t INTERVAL_MAX = 0xFFFFFF;
// Always give controller 31.25ms difference between min and max
static uint32_t INTERVAL_DELTA = 50;

static AdvertiseParameters parseParams(JNIEnv* env, jobject i) {
  AdvertiseParameters p;

@@ -1731,9 +1735,13 @@ static AdvertiseParameters parseParams(JNIEnv* env, jobject i) {
  if (isAnonymous) props |= 0x20;
  if (includeTxPower) props |= 0x40;

  if (interval > INTERVAL_MAX - INTERVAL_DELTA) {
    interval = INTERVAL_MAX - INTERVAL_DELTA;
  }

  p.advertising_event_properties = props;
  p.min_interval = interval;
  p.max_interval = interval + 50;
  p.max_interval = interval + INTERVAL_DELTA;
  p.channel_map = 0x07; /* all channels */
  p.tx_power = txPowerLevel;
  p.primary_advertising_phy = primaryPhy;