Bluetooth tutorial

Hello Group -
I am an old user of NSBasic, put it down for a while but back, because I really need to figure out how to build apps to connect with things that I design with Bluetooth.
I am a hardware designer, but I can code. I say that because I have no idea how to use the plugins, nor how to include the bluetooth functionality inside an NSBasic app, but I am not new to programming.
I have been unable to find any sort of starter guide for getting all of that going.
Can someone point me to a real, step-by-step procedure for this?
Even some example projects with BT support may help.
I have a new (hardware) project that uses a Microchip BT module. I need to get an app written for it or else it’s just a waste of time.
Thanks in advance -
Dan

This plugin may help cordova-plugin-bluetoothle - npm

In your NSBasic Project “Properties” sidebar window > VoltBuilder > config.xml = Add this line to add the plugin:

<plugin name="cordova-plugin-bluetoothle" source="npm" />

As someone who has spend a lot of time on Bluetooth over the years, I can attest that a “Bluetooth made simple” tutorial will never happen.

I can give a few tips that may help…

  1. BT (Bluetooth) and BLE (Bluetooth Low Energy) are not the same thing. BLE is newer and meant to address some of the complications of BT. It is itself perhaps more complicated.
  2. You’ll need to make it a native app, to run on Android and/or iOS. Native code libraries are needed.
  3. Here an example what needs to go into your config.xml. The plugins for BT and BLE are both here:
<plugin name="cordova-plugin-bluetooth-serial" source="npm" />
<plugin name="cordova-plugin-ble-central@slim">
  <variable name="ACCESS_BACKGROUND_LOCATION" value="true" />
  <variable name="IOS_INIT_ON_LOAD" value="false" />
</plugin>
<platform name="android">
    <config-file target="AndroidManifest.xml" parent="/manifest">
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />
        <uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
        <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    </config-file>
</platform>

<edit-config target="NSBluetoothAlwaysUsageDescription" file="*-Info.plist" mode="overwrite">
  <string>Allow the app to access Bluetooth EID reader/Weight scale</string>
</edit-config>
<edit-config target="NSBluetoothPeripheralUsageDescription" file="*-Info.plist" mode="overwrite">
  <string>Allow the app to access Bluetooth EID reader/Weight scale</string>
</edit-config>
  1. There are other plugins which may work better in your case depending on the device.
  2. If you need to do this from the desktop, it could probably be done using Electron. I have no ideas what libraries might be needed - I have not done this.
  3. BT (and BLE) by their nature are not reliable protocols. Devices keep dropping in and out of range. Reconnecting reliably depends on the device, the device OS, when in the protocol is disconnected, etc. Your code needs to allow for this.

This really isn’t an issue with AppStudio itself - it’s the nature of Bluetooth. Be prepared to do lots of research and experimentation.