}
}
-static AdvertiseParameters parseParams(JNIEnv* env, jobject i, bool isScannable,
- int* timeout) {
+static AdvertiseParameters parseParams(JNIEnv* env, jobject i,
+ bool isScannable) {
AdvertiseParameters p;
jclass clazz = env->GetObjectClass(i);
uint32_t interval = env->CallIntMethod(i, methodId);
methodId = env->GetMethodID(clazz, "getTxPowerLevel", "()I");
int8_t txPowerLevel = env->CallIntMethod(i, methodId);
- methodId = env->GetMethodID(clazz, "getTimeout", "()I");
- *timeout = env->CallIntMethod(i, methodId);
uint16_t props = 0;
if (isConnectable) props |= 0x01;
jobject parameters, jbyteArray adv_data,
jbyteArray scan_resp,
jobject periodic_parameters,
- jbyteArray periodic_data, jint reg_id) {
+ jbyteArray periodic_data, jint timeout,
+ jint reg_id) {
if (!sGattIf) return;
jbyte* scan_resp_data = env->GetByteArrayElements(scan_resp, NULL);
scan_resp_data + scan_resp_len);
env->ReleaseByteArrayElements(scan_resp, scan_resp_data, JNI_ABORT);
- int timeout;
AdvertiseParameters params =
- parseParams(env, parameters, (scan_resp_len != 0), &timeout);
+ parseParams(env, parameters, (scan_resp_len != 0));
PeriodicAdvertisingParameters periodicParams =
parsePeriodicParams(env, periodic_parameters);
+ int timeout_s = (int)timeout / 1000;
+
jbyte* adv_data_data = env->GetByteArrayElements(adv_data, NULL);
uint16_t adv_data_len = (uint16_t)env->GetArrayLength(adv_data);
std::vector<uint8_t> data_vec(adv_data_data, adv_data_data + adv_data_len);
sGattIf->advertiser->StartAdvertisingSet(
base::Bind(&ble_advertising_set_started_cb, reg_id), params, data_vec,
- scan_resp_vec, periodicParams, periodic_data_vec, timeout,
+ scan_resp_vec, periodicParams, periodic_data_vec, timeout_s,
base::Bind(ble_advertising_set_timeout_cb));
}
{"cleanupNative", "()V", (void*)advertiseCleanupNative},
{"startAdvertisingSetNative",
"(Landroid/bluetooth/le/AdvertisingSetParameters;[B[BLandroid/bluetooth/"
- "le/PeriodicAdvertisingParameters;[BI)V",
+ "le/PeriodicAdvertisingParameters;[BII)V",
(void*)startAdvertisingSetNative},
{"stopAdvertisingSetNative", "(I)V", (void*)stopAdvertisingSetNative},
};
void startAdvertisingSet(AdvertisingSetParameters parameters, AdvertiseData advertiseData,
AdvertiseData scanResponse, PeriodicAdvertisingParameters periodicParameters,
- AdvertiseData periodicData, IAdvertisingSetCallback callback) {
+ AdvertiseData periodicData, int timeout, IAdvertisingSetCallback callback) {
AdvertisingSetDeathRecipient deathRecipient = new AdvertisingSetDeathRecipient(callback);
IBinder binder = toBinder(callback);
try {
mAdvertisers.put(binder, new AdvertiserInfo(cb_id, deathRecipient, callback));
logd("startAdvertisingSet() - reg_id=" + cb_id + ", callback: " + binder);
- startAdvertisingSetNative(
- parameters, adv_data, scan_response, periodicParameters, periodic_data, cb_id);
+ startAdvertisingSetNative(parameters, adv_data, scan_response, periodicParameters,
+ periodic_data, timeout, cb_id);
}
void stopAdvertisingSet(IAdvertisingSetCallback callback) {
private native void cleanupNative();
private native void startAdvertisingSetNative(AdvertisingSetParameters parameters,
byte[] advertiseData, byte[] scanResponse,
- PeriodicAdvertisingParameters periodicParameters, byte[] periodicData, int reg_id);
+ PeriodicAdvertisingParameters periodicParameters, byte[] periodicData, int timeout,
+ int reg_id);
private native void stopAdvertisingSetNative(int advertiser_id);
}
public void startAdvertisingSet(AdvertisingSetParameters parameters,
AdvertiseData advertiseData, AdvertiseData scanResponse,
PeriodicAdvertisingParameters periodicParameters, AdvertiseData periodicData,
- IAdvertisingSetCallback callback) {
+ int timeout, IAdvertisingSetCallback callback) {
GattService service = getService();
if (service == null) return;
service.startAdvertisingSet(parameters, advertiseData, scanResponse, periodicParameters,
- periodicData, callback);
+ periodicData, timeout, callback);
}
public void stopAdvertisingSet(IAdvertisingSetCallback callback) {
service.stopAdvertisingSet(callback);
}
- public void enableAdverisingSet(int advertiserId, boolean enable) {
+ public void enableAdverisingSet(int advertiserId, boolean enable, int timeout) {
GattService service = getService();
if (service == null) return;
// TODO: implement
*************************************************************************/
void startAdvertisingSet(AdvertisingSetParameters parameters, AdvertiseData advertiseData,
AdvertiseData scanResponse, PeriodicAdvertisingParameters periodicParameters,
- AdvertiseData periodicData, IAdvertisingSetCallback callback) {
+ AdvertiseData periodicData, int timeout, IAdvertisingSetCallback callback) {
enforceAdminPermission();
mAdvertiseManager.startAdvertisingSet(parameters, advertiseData, scanResponse,
- periodicParameters, periodicData, callback);
+ periodicParameters, periodicData, timeout, callback);
}
void stopAdvertisingSet(IAdvertisingSetCallback callback) {