Sign in to follow this  
Followers 0
redpicker

Receive Data over Bluetooth

6 posts in this topic

I a not sure this is even possible.  I want to write a script that will connect to my BBQ thermometer, which is bluetooth enabled, and log the temperatures in an Excel file.

I have done some scripts with AutoIt, and I am comfortable creating and writing the data to the excel file, but I am not sure how to connect to the bluetooth device and receive the data.  There are Android Apps that receive the data on my cell phone, but I want to do it to my laptop.

Is this even possible?  If so, could someone point me in the right direction,  I couldn't find a BlueTooth UDF.  Is there one?

Share this post


Link to post
Share on other sites



It would be a question for the manufacturer. Do they have an API for windows, or was it written specifically for Android? Even the Android app, is it open source? In other words, do they want you messing around with their code.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

It may be possible. If you could pair the thermometer with your pc and you can make sense of the data you receive. If you know android/java, you could just download the android APK file and look at the code.

 

16 hours ago, redpicker said:

I couldn't find a BlueTooth UDF.  Is there one?

Googled Bluetooth UDF and 1st and 4th result was: Bluetooth Detector/Switching Script and Bluetooth UDF!!!

Edited by genius257

Share this post


Link to post
Share on other sites
On 10/14/2016 at 11:21 AM, genius257 said:

It may be possible. If you could pair the thermometer with your pc and you can make sense of the data you receive. If you know android/java, you could just download the android APK file and look at the code.

 

Googled Bluetooth UDF and 1st and 4th result was: Bluetooth Detector/Switching Script and Bluetooth UDF!!!

I appreciate the reply.

For anyone following, the first link is for a script to detect bluetooth devices, no UDF for sending or receiving data.

The second link is in German.

Per JLogan's post, I sent an e-mail to the manufacturer and they are not interested in helping me.  My best bet seems to be to build my own and use an Arduino UNO board for communication.  

Share this post


Link to post
Share on other sites
1 minute ago, redpicker said:

The second link is in German.

The last comment in link is a code example with Bluetooth calls. Just to give you a starting point :)

here's the code extracted from Christoph54 on autoit.de:

#include <WinAPI.au3>


Local $phRadio
$hFind = _BluetoothFindFirstRadio($phRadio)
If $hFind = 0 Then
    MsgBox(16, "Hardware error", "Unable to find compatible bluetooth radio(s) on this machine.")
    _WinAPI_CloseHandle($phRadio)
    _BluetoothFindRadioClose($hFind)
    Exit
Else
    _WinAPI_CloseHandle($phRadio)
    _BluetoothFindRadioClose($hFind)
EndIf

_BluetoothFindFirstDevice()
Sleep(10000)
_BluetoothRegisterForAuthenticationEx()

Func _BluetoothFindFirstDevice($REMEMBER = False)
    Local $HRESULT[3], $tBLUETOOTH_DEVICE_INFO
    $tBLUETOOTH_DEVICE_SEARCH_PARAMS = DllStructCreate('DWORD;BOOL;BOOL;BOOL;BOOL;BOOL;BYTE;HANDLE')
    DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 1, DllStructGetSize($tBLUETOOTH_DEVICE_SEARCH_PARAMS))
    DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 2, False)
    DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 3, $REMEMBER)
    DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 4, True)
    DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 5, True)
    DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 6, True)
    DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 7, 6)
    DllStructSetData($tBLUETOOTH_DEVICE_SEARCH_PARAMS, 8, 0)
    $tBLUETOOTH_DEVICE_INFO = DllStructCreate('DWORD;UINT64;ULONG;BOOL;BOOL;BOOL;word[8];word[8];WCHAR[248]')
    DllStructSetData($tBLUETOOTH_DEVICE_INFO, 1, DllStructGetSize($tBLUETOOTH_DEVICE_INFO))
    $RESULT = DllCall("bthprops.cpl", "handle", "BluetoothFindFirstDevice", "struct*", $tBLUETOOTH_DEVICE_SEARCH_PARAMS, "struct*", $tBLUETOOTH_DEVICE_INFO)
    $HRESULT[0] = DllStructGetData($tBLUETOOTH_DEVICE_INFO, 9)
    $HRESULT[1] = DllStructGetData($tBLUETOOTH_DEVICE_INFO, 2)
    $HRESULT[2] = DllStructGetData($tBLUETOOTH_DEVICE_INFO, 3)
    Do
        $ULTRA = _BluetoothFindNextDevice($RESULT[0])
    Until $ULTRA = "0"
    Return $HRESULT
EndFunc   ;==>_BluetoothFindFirstDevice

Func _BluetoothFindFirstRadio(ByRef $phRadio)
    $tBLUETOOTH_FIND_RADIO_PARAMS = DllStructCreate('DWORD')
    DllStructSetData($tBLUETOOTH_FIND_RADIO_PARAMS, 1, DllStructGetSize($tBLUETOOTH_FIND_RADIO_PARAMS))
    $aResult = DllCall("bthprops.cpl", "handle", "BluetoothFindFirstRadio", "struct*", $tBLUETOOTH_FIND_RADIO_PARAMS, "handle*", 0)
    If @error Then Return SetError(2, @error, 0)
    $phRadio = $aResult[2]
    Return SetError($aResult[0] = 0, 0, $aResult[0])
EndFunc   ;==>_BluetoothFindFirstRadio

Func _BluetoothFindRadioClose($hBtFind)
    Local $aResult = DllCall("bthprops.cpl", "bool", "BluetoothFindRadioClose", "handle", $hBtFind)
    If @error Then Return SetError(2, @error, 0)
    Return SetError($aResult[0] = 0, 0, $aResult[0])
EndFunc   ;==>_BluetoothFindRadioClose

Func _BluetoothFindNextDevice($HANDLE)
    $t1BLUETOOTH_DEVICE_INFO = DllStructCreate('DWORD;UINT64;ULONG;BOOL;BOOL;BOOL;word[8];word[8];WCHAR[248]')
    $RESULTX = DllCall("bthprops.cpl", "Bool", "BluetoothFindNextDevice", "handle", $HANDLE, "struct*", $t1BLUETOOTH_DEVICE_INFO)
    Return $RESULTX[0]
EndFunc   ;==>_BluetoothFindNextDevice

Func _BluetoothRegisterForAuthenticationEx()
    Local $ZRESULT, $tBLUETOOTH_DEVICE_REG
    $tBLUETOOTH_DEVICE_REG = DllStructCreate('DWORD;UINT64;ULONG;BOOL;BOOL;BOOL;word[8];word[8];WCHAR[248]')
    DllStructSetData($tBLUETOOTH_DEVICE_REG, 1, DllStructGetSize($tBLUETOOTH_DEVICE_REG))
    DllStructSetData($tBLUETOOTH_DEVICE_REG, 2, 560)
    DllStructSetData($tBLUETOOTH_DEVICE_REG, 3, 550377916751)
    DllStructSetData($tBLUETOOTH_DEVICE_REG, 4, 9600)
    DllStructSetData($tBLUETOOTH_DEVICE_REG, 5, False)
    DllStructSetData($tBLUETOOTH_DEVICE_REG, 6, False)
    DllStructSetData($tBLUETOOTH_DEVICE_REG, 7, False)
    $ZRESULT = DllCall("bthprops.cpl", "handle", "BluetoothRegisterForAuthenticationEx", "struct*", $tBLUETOOTH_DEVICE_REG, "handle*", 0)
    Return $ZRESULT
EndFunc   ;==>_BluetoothRegisterForAuthenticationEx

 

1 person likes this

Share this post


Link to post
Share on other sites

Cool!  I guess the German just blinded me.

This is good.  It may take a while, but I might be able to get into it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0