bluetoothSerial is not defined ReferenceError: bluetoothSerial is not defined (cordova phonegap bluetooth plugin)

1
Hi,  I am trying to create hybrid application to scan nearby bluetooth devices. For that i have generated apk using phonegap build. I have already added bluetoothSerial plugins in the config file of phonegap build. But the problem is when i try to execute javascript action i am getting this following error ERROR :  bluetoothSerial is not defined ReferenceError: bluetoothSerial is not defined Please leave some comments/ideas about this issue. <?xml version="1.0" encoding="UTF-8" ?> <widget xmlns = "http://www.w3.org/ns/widgets" xmlns:gap = "http://phonegap.com/ns/1.0" id = "io.mxapps.bluetoothsample-sandbox" version = "0.0.32" xmlns:android="http://schemas.android.com/apk/res/android"> <name>Bluetooth-Sample</name> <description>Testing for scanning the bluetooth devices</description> <!-- Current latest and default version Platform versions don't follow a common version number anymore (see: http://phonegap.com/blog/2015/06/16/phonegap-updated-on-build/). Instead, Phonegap Build derives the platform versions from the CLI defaults. --> <preference name="phonegap-version" value="cli-9.0.0" /> <engine name="android" spec="8.1.0" /> <engine name="ios" spec="5.1.1" /> <!-- allow assets to be loaded and open links in the app itself, see: http://phonegap.com/blog/2012/03/20/access-tags/ --> <!-- Issue 204079: Allow retrieval of any resource. Custom widgets can point to anything. --> <access origin="*" /> <allow-navigation href="*://*.mendix.com/*" /> <allow-navigation href="*://*.mendixcloud.com/*" /> <allow-navigation href="*://*.mxapp.io/*" /> <allow-navigation href="about:*" /> <plugin name="com.darktalker.cordova.screenshot" source="npm" spec="0.1.6" /> <plugin name="com.telerik.plugins.nativepagetransitions" spec="https://github.com/mendix/NativePageTransitions.git" /> <plugin name="cordova-plugin-actionsheet" source="npm" spec="2.3.3" /> <plugin name="cordova-plugin-app-version" source="npm" spec="0.1.9" /> <plugin name="cordova-plugin-battery-status" source="npm" spec="2.0.2" /> <plugin name="cordova-plugin-cookieemperor" spec="https://github.com/rtk/cordova-cookie-emperor.git" /> <plugin name="cordova-plugin-device" source="npm" spec="2.0.2" /> <plugin name="cordova-plugin-device-motion" source="npm" spec="2.0.1" /> <plugin name="cordova-plugin-device-orientation" source="npm" spec="2.0.1" /> <plugin name="cordova-plugin-dialogs" source="npm" spec="2.0.1" /> <plugin name="cordova-plugin-file" source="npm" spec="6.0.1" /> <plugin name="cordova-plugin-file-opener2" source="npm" spec="2.0.19" /> <plugin name="cordova-plugin-file-transfer" source="npm" spec="1.7.1" /> <plugin name="cordova-plugin-globalization" source="npm" spec="1.11.0" /> <plugin name="cordova-plugin-inappbrowser" source="npm" spec="3.2.0" /> <plugin name="cordova-plugin-network-information" source="npm" spec="2.0.1" /> <plugin name="cordova-plugin-secure-storage" spec="https://github.com/mendix/cordova-plugin-secure-storage.git" /> <plugin name="cordova-plugin-spinner" source="npm" spec="1.1.0" /> <plugin name="cordova-plugin-splashscreen" source="npm" spec="5.0.2" /> <plugin name="cordova-plugin-statusbar" source="npm" spec="2.4.2" /> <plugin name="cordova-plugin-vibration" source="npm" spec="3.1.0" /> <plugin name="cordova-plugin-x-socialsharing" source="npm" version="5.6.4"/> <plugin name="cordova-plugin-zip" source="npm" spec="3.1.0" /> <plugin name="@mendix/cordova-sqlite-storage" source="npm" spec="2.0.4-mx.1.1.0" /> <plugin name="@mendix/uk.co.workingedge.phonegap.plugin.launchnavigator" source="npm" spec="4.2.2-mx.1.0.0" /> <plugin name="cordova-plugin-calendar" source="npm" spec="5.1.2"> <param name="CALENDAR_USAGE_DESCRIPTION" value="This app needs to access your calendar" /> </plugin> <plugin name="cordova-plugin-camera" source="npm" spec="4.0.3" /> <plugin name="cordova-plugin-contacts" source="npm" spec="3.0.1" /> <plugin name="cordova-plugin-media-capture" source="npm" spec="3.0.2" /> <plugin name="phonegap-plugin-barcodescanner" source="npm" spec="8.0.0" /> <plugin name="cordova-plugin-geolocation" source="npm" spec="4.0.1" /> <plugin name="cordova-plugin-media" source="npm" spec="5.0.2" /> <!-- The gradle build tool is required for the phonegap-plugin-push --> <preference name="android-build-tool" value="gradle" /> <plugin name="cordova-plugin-whitelist" source="npm" spec="1.3.3" /> <plugin name="cordova-plugin-android-permissions" source="npm" version="0.11.0" /> <preference name="android-minSdkVersion" value="19" /> <preference name="android-targetSdkVersion" value="28" /> <platform name="android"> <preference name="ANDROID_SUPPORT_V13_VERSION" value="28.0.0" /> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-hdpi-landscape.png" density="land-hdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-xxxhdpi-landscape.png" density="land-xxxhdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-ldpi-portrait.png" density="port-ldpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-xhdpi-portrait.png" density="port-xhdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-ldpi-landscape.png" density="land-ldpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-mdpi-landscape.png" density="land-mdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-hdpi-portrait.png" density="port-hdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-xhdpi-landscape.png" density="land-xhdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <icon src="res/android/icon-192-xxxhdpi.png" density="xxxhdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <icon src="res/android/icon-48-mdpi.png" density="mdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-xxhdpi-portrait.png" density="port-xxhdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <icon src="res/android/icon-72-hdpi.png" density="hdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <icon src="res/android/icon-36-ldpi.png" density="ldpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <icon src="res/android/icon-96-xhdpi.png" density="xhdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-xxhdpi-landscape.png" density="land-xxhdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-xxxhdpi-portrait.png" density="port-xxxhdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <icon src="res/android/icon-144-xxhdpi.png" density="xxhdpi"/> <!-- Icon definitions - for more details: http://developer.android.com/guide/topics/resources/providing-resources.html --> <splash src="res/android/screen-mdpi-portrait.png" density="port-mdpi"/> </platform> <splash src="res/android/screen-xxxhdpi-portrait.png" /> <plugin name="cordova-plugin-bluetooth-serial" source="npm" spec="0.4.7" /> </widget>   import { Big } from "big.js"; // BEGIN EXTRA CODE // END EXTRA CODE /** * @returns {Promise.<MxObject[]>} */ export async function ListUnPairedBluetoothDevices() { // BEGIN USER CODE console.log("checking...."); return new Promise(function(resolve){ console.log("checking....2"); bluetoothSerial.discoverUnpaired(function(list){ var objects = []; var listCount = list.length; list.map(function(object){ mx.data.create({ entity: "MyFirstModule.BluetoothDevice", callback: function(obj){ obj.set("name", object.name !== "" ? object.name : ""); obj.set("address", object.address); obj.set("_id", object.id); obj.set("_class", object.class); objects.push(obj); if(objects.length === list.length){ resolve(objects); }; }, error: function(error){ console.log(error); reject(error); } }) }) }, function(error){ }); }); // END USER CODE }  
asked
1 answers
0

Hi Robinson,Cause of error may be  bluetoothserial is reference variable but not instantiated with BluetoothSerial class.

answered