mit-cml / appinventor-extensions

Source code of extensions published for MIT App Inventor
Apache License 2.0
86 stars 95 forks source link

Include an abstract base class for BLE-enabled extensions #29

Closed ewpatton closed 4 years ago

ewpatton commented 4 years ago

A while back I created an example extension (also in this repo) for how to use a BluetoothLE extension as a communication channel for higher-level extensions, such as our Arduino101 and Microbit extensions. However, this results in a lot of replicated code as each extension has to duplicate the same functionality of receiving a BluetoothLE instance, setting up listeners, handling onPause, onResume, etc. What we should do instead is create in the BluetoothLE extension an abstract base class that these other extensions can extend. This base class would have all the now currently duplicated functionality and allow us to reconcile to a single code path. Further, as we make improvements to the BLE extension or its base class these other extensions would immediately benefit.

ewpatton commented 4 years ago

Added the BLEExtension class in the latest version of the extension that other extensions can use to start building BLE-enabled extensions: https://github.com/mit-cml/appinventor-extensions/blob/extension/bluetoothle/appinventor/components/src/edu/mit/appinventor/ble/BLEExtension.java