Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import com.google.appinventor.components.runtime.Deleteable;
import com.google.appinventor.components.runtime.EventDispatcher;
import com.google.appinventor.components.runtime.Form;
import com.google.appinventor.components.runtime.OnClearListener;
import com.google.appinventor.components.runtime.util.BulkPermissionRequest;
import com.google.appinventor.components.runtime.util.SdkLevel;
import com.google.appinventor.components.runtime.util.YailList;
Expand Down Expand Up @@ -71,13 +72,13 @@
"The BluetoothLE extension requires Android 5.0 or higher to avoid known " +
"issues with Google's Bluetooth LE support prior to Android 5.0.",
category = ComponentCategory.EXTENSION,
versionName = "20240822",
versionName = "20241218",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will bump the version number when we do a release so you don't need to update it as part of the PR.

nonVisible = true,
helpUrl = "https://iot.appinventor.mit.edu/#/bluetoothle/bluetoothleintro",
iconName = "images/bluetooth.png")
@SimpleObject(external = true)
@UsesPermissions({ BLUETOOTH, BLUETOOTH_ADMIN })
public class BluetoothLE extends AndroidNonvisibleComponent implements Component, Deleteable {
public class BluetoothLE extends AndroidNonvisibleComponent implements Component, Deleteable, OnClearListener {
public static final int ERROR_DEVICE_INDEX_OOB = 9101;
public static final int ERROR_SERVICE_INDEX_OOB = 9102;
public static final int ERROR_SERVICE_INVALID_UUID = 9103;
Expand All @@ -101,6 +102,14 @@ public void onDelete() {
}
}

@Override
public void onClear() {
if (inner != null) {
inner.Disconnect();
inner = null;
}
}

public static abstract class BLEResponseHandler<T> {
@SuppressWarnings("unused")
public void onReceive(String serviceUuid, String characteristicUuid, List<T> values) {
Expand Down Expand Up @@ -136,6 +145,8 @@ public BluetoothLE(ComponentContainer container) {
Log.d(LOG_TAG, "Appear to have Bluetooth LE support, continuing...");
}

form.registerForOnClear(this);

inner = new BluetoothLEint(this, form, container);
permissions = new PermissionHelper(getForm(), this);
}
Expand Down