均鈺科技 (Hypro) 合作案

2019 年有機會與同學的公司均鈺科技 (Hypro Enterprises) 做一個簡單的藍芽物聯網的專案,成果簡單以以下方式呈現:

透過 ElasticSearch 與 Kibana 的幫助,我們建立一個後台可以將藍芽收到的溫濕度歷史紀錄呈現出來

雲端的資料庫與可視化模組由開源的 ElasticSearch 與 Kibana 負責資料的蒐集,硬體的部分則是利用 Raspberry Pi 3 和有人物聯網的藍芽開發模組負責將溫濕度的資訊由藍芽晶片上傳至閘道再傳至雲端。

藍芽晶片將訊號收集之後傳送到由 Android 控制的 Raspberry Pi 再將訊號發送至雲端

Android 的 Block Diagram 簡化之後可以以下的圖片簡單描述,程式可以由此處下載安裝檔 apk

由於 Gateway 主要是由 Android 進行撰寫的,以下列出幾個遇到的錯誤訊息。

E/AndroidRuntime: FATAL EXCEPTION: 
  main Process: hypro.btLogger, PID: 1846
  java.lang.RuntimeException: Error receiving broadcast Intent { act=hypro.bluetooth.le.ACTION_DATA_AVAILABLE flg=0x10 (has extras) } in hypro.btLogger.bluetooth.BleBroadcastReceiver@8bdb385
  at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52497(LoadedApk.java:1323)
  at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.$m$7(Unknown Source:4)
  at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.run(Unknown Source:39)
  at android.os.Handler.handleCallback(Handler.java:790)
  at android.os.Handler.dispatchMessage(Handler.java:99)
  at android.os.Looper.loop(Looper.java:164)
  at android.app.ActivityThread.main(ActivityThread.java:6494)
  at java.lang.reflect.Method.invoke(Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
  at hypro.btLogger.bluetooth.BleBroadcastReceiver.sendData2ElasticSearch(BleBroadcastReceiver.java:117)
  at hypro.btLogger.bluetooth.BleBroadcastReceiver.onReceive(BleBroadcastReceiver.java:101)
  at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52497(LoadedApk.java:1313)

 

D/BluetoothAdapter: startLeScan(): null startLeScan(): callback = com.btLogger.MainActivity$3@3ad7171 
D/BluetoothLeScanner: startScan(): callback = android.bluetooth.BluetoothAdapter$2@d2924f 
D/BluetoothAdapter: STATE_ON D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=6 W/Binder: Caught a RuntimeException from the binder stub implementation. 
java.lang.SecurityException: Need ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION permission to get scan results 
  at android.os.Parcel.readException(Parcel.java:1629) 
  at android.os.Parcel.readException(Parcel.java:1582) 
  at android.bluetooth.IBluetoothGatt$Stub$Proxy.startScan(IBluetoothGatt.java:772) 
  at android.bluetooth.le.BluetoothLeScanner$BleScanCallbackWrapper.onClientRegistered(BluetoothLeScanner.java:378) 
  at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:56) 
  at android.os.Binder.execTransact(Binder.java:461) Disconnected from the target VM, address: 'localhost:8603', transport: 'socket'

 

W/BluetoothGatt: Unhandled exception in callback java.lang.NullPointerException: Attempt to invoke virtual method 'void hypro.btLogger.bluetooth.BluetoothTerminal.setState(int)' on a null object reference at hypro.btLogger.bluetooth.BluetoothLeService$1.onConnectionStateChange(BluetoothLeService.java:57) 
  at android.bluetooth.BluetoothGatt$1$4.run(BluetoothGatt.java:249) 
  at android.bluetooth.BluetoothGatt.runOrQueueCallback(BluetoothGatt.java:725) 
  at android.bluetooth.BluetoothGatt.-wrap0(Unknown Source:0) 
  at android.bluetooth.BluetoothGatt$1.onClientConnectionState(BluetoothGatt.java:244) 
  at android.bluetooth.IBluetoothGattCallback$Stub.onTransact(IBluetoothGattCallback.java:70) 
  at android.os.Binder.execTransact(Binder.java:697)