Android Question BT Confusion

Terradrones

Active Member
Licensed User
Hi All

I think my Brain cells are decreasing with old age and I need help as usual please.

Using the BT Library, I can see other BT devices around me. When I want to connect, it gives me an error message all the time and I cannot connect.

I have had a look at Erel's Bluetooth Chat example and I come to the conclusion that the only way that this will work is if both devices run the same program.

How do I go about connecting to an external GPS or Total Station (an instrument that measures angles and distances) using BT?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Don't make duplicate posts.
that the only way that this will work is if both devices run the same program.
Almost. You can only connect to Bluetooth devices that are listening for SPP connections. You also need to know the service record UUID. The default value is 00001101-0000-1000-8000-00805F9B34FB"
 
Upvote 0

emexes

Expert
Licensed User
How do I go about connecting to an external GPS or Total Station (an instrument that measures angles and distances) using BT?

I was going to predict that your next question was going to be how to parse the data received from the gps station, but then your username rang a bell and I vaguely remembered you're miles ahead of me re: surveying. On the other hand, that happened after I dug this up, so... just in case:

1/ apparently a common format is SDR33, sample of it here: https://tops.iosa.it/2014/03/08/sdr33-format.html

2/ this manual has a half-reasonable description of the format: https://www.sitechwest.com/content/uploads/2016/01/TS662-UserGuide.pdf pages 175-178
 
Upvote 0

Terradrones

Active Member
Licensed User
Hi Emexes, my name is Michael Papenhagen and I am the developer of the mobile surveying program called "CEASER" (Civil Engineering And Surveying Earthworks Routines). This was developed in VB.net for the compact framework. This program is used by most Surveyors in Southern Africa and also elsewhere in the World.

I have the Interfacing Protocols for most of the Total Stations and GPS (Survey Grade) in VB.net and as B4A is very close to VB.net, I have already ported them over to B4A.

Maybe when you have time, you can dig up the Interfacing Protocols for the higher end Trimble Total Stations and GPS. All the Manufactures gave me their Protocols, except Trimble. The lower end Trimble Instruments are the same as Nikon.

Microsoft has stopped developing Windows Mobile any further for a couple of years now due to Android being more powerful and it is therefore logical for me to move over to Android as well.

Terradrones is the name of my Company where I use Drones for my Topographical Surveys.

If I can just get this BT to work.:(
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Hi @Terradrones
I remember you from the Basic4ppc days when I was very active writing libraries for it. Wasn't your user name 'ceaser' in those days? If I remember correctly (not always true nowadays) I wrote a Delauney2D triangulation library for you. I'm glad to see you are still in business and transferring to Android.
 
Upvote 0

Terradrones

Active Member
Licensed User
Hi Agraham, that is true. I switched over to VB.net because with Basic4ppc the Ceaser program took too long to load. With B4A it is super fast and much faster than with Windows Mobile.

Don't I still owe you money?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Upvote 0

Terradrones

Active Member
Licensed User
If I can just get this BT working. I am doing everything as per Erel's example, but I cannot get things to connect.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
For another example look at how my ESC/POS printer class connects
 
Upvote 0

Terradrones

Active Member
Licensed User
For another example look at how my ESC/POS printer class connects
Thank you very much Agraham, I will have a look on my PC as soon as the electricity comes on again. We sit without electricity 3 times a day for 2.5 hours each time. Sometimes its for 4 hours each each time=12 hours per day. I am sure Ukraine has more electricity than we do.
 
Upvote 0

f0raster0

Well-Known Member
Licensed User
Longtime User
@Terradrones try a couple things:
1. use nRF App to try to connect
(I know ?, I always say the same :) but it is true: it's the first step then if you can connect using nRF App the you can do it using B4X example.
1.1 make sure you have fine location ON on your Smartphone
1.2 make sure your device isn't connected somewhere else (ex.; your PC)

2. Maybe your device have to be paired in advance, example in post #12 will help you to connect from App to your device.
 
Upvote 0

Terradrones

Active Member
Licensed User
For another example look at how my ESC/POS printer class connects
Hi Agraham

I looked at the code for the Printer, but it is giving me the same error messages. I am doing something wong.

May I send you my coding to have a look at please. I am in the shit!!

I will pay you in advance via Paypal.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Have you paired your instrument? Does it appear in your connected devices list in settings? If so then it should be as simple as this
B4X:
' Ask the user to connect to a printer and return whether she tried or not
' If True then a subsequent Connected event will indicate success or failure
Public Sub Connect As Boolean
    Dim PairedDevices As Map
    PairedDevices = Serial1.GetPairedDevices
    Dim l As List
    l.Initialize
    For i = 0 To PairedDevices.Size - 1
        l.Add(PairedDevices.GetKeyAt(i))
    Next
    Dim Res As Int
    Res = InputList(l, "Choose a printer", -1) 'show list with paired devices
    If Res <> DialogResponse.CANCEL Then
        Serial1.Connect(PairedDevices.Get(l.Get(Res))) 'convert the name to mac address
        Return True
    End If
    Return False
End Sub
 
Upvote 0

Terradrones

Active Member
Licensed User
Have you paired your instrument? Does it appear in your connected devices list in settings? If so then it should be as simple as this
B4X:
' Ask the user to connect to a printer and return whether she tried or not
' If True then a subsequent Connected event will indicate success or failure
Public Sub Connect As Boolean
    Dim PairedDevices As Map
    PairedDevices = Serial1.GetPairedDevices
    Dim l As List
    l.Initialize
    For i = 0 To PairedDevices.Size - 1
        l.Add(PairedDevices.GetKeyAt(i))
    Next
    Dim Res As Int
    Res = InputList(l, "Choose a printer", -1) 'show list with paired devices
    If Res <> DialogResponse.CANCEL Then
        Serial1.Connect(PairedDevices.Get(l.Get(Res))) 'convert the name to mac address
        Return True
    End If
    Return False
End Sub
Hi Agraham, I paired outside my program, went back in and selected the paired unit, but still nothing happens.

May I send you my source code and if you could have a look at it. I will pay you in advance via PayPal. I am really getting desperate now.?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Hi Agraham, I paired outside my program, went back in and selected the paired unit, but still nothing happens.
Does this mean that your program displayed and allowed you to select the instrument? Did Connect return True. If so then I suspect you haven't set up the input and output streams. Look carefully at the EscPosPrinter class in my printer program. In particular the Serial1_Connected event.
 
Upvote 0
Top