How to code a Bluetooth communication?

Hi,

I’m new to Go (a few weeks, a few projects - some with fyne.io) and I have another difficulty, I’m French (I know, no one is perfect).

I understand what is written in English but it is not always easy for me. Likewise, my expression in English is certainly not very good.

I have a project with an Arduino and an HC06 bluetooth adapter. This project is working.

I made an application on Android (with appinventor) that sends informations.

I want to port this application to Go to have an application on Linux and Windows (and why not on Android).
But I’m not sure which library is best for me and how to send a message (a string or just one character) in a Go code.

I saw the Tinygo package (https://pkg.go.dev/tinygo.org/x/bluetooth). With it, I don’t understand how to communicate via bluetooth.
I tested the example of the scanner that works but after …?

I don’t find some examples.

If you can help me.

Many thanks.

Jean Pierre.

1 Like

Hi Jean,

Interesting move there. I think you’ll need to know BLE programming: https://www.bluetooth.com/bluetooth-resources/bluetooth-le-developer-starter-kit/

This is also useful: https://learn.sparkfun.com/tutorials/bluetooth-basics/all

I have some questions though:

  1. Do you intend to build a GUI app?
  2. Why Go?

Hi,

Thanks for your reply and the links. I will read this as soon as possible.

I know I need to know more about Bluetooth, but part of my personal method of learning a programming language is to look at examples and research different information to understand the details of the implementation. Step by step.

I am a former programmer but now I work in education and I write code for associations or for fun.

So, I think there is somewhere (but it looks like I can’t find it) an example with a connection and just a few sent and received messages.

For your questions:

  1. Yes, with Fyne.io
  2. For several reasons: the language matches my logic, I can do a lot of things I need, cross-compilation, it’s a compiled language, just an executable program to be installed by the user, I don’t want not learn a lot of different languages ​​(and currently it’s Go), etc.

Jean-Pierre

Sounds like a fun project. I love tiny-go. When you mentioned “there is somewhere (but it looks like I can’t find it) an example…” did you mean this heartrate monitor client? It looks like it connects to a device and receives data.

Hi,

Thank you for that answer.

This project consists of making a moving target for archery. It works but if I can make a remote control for PC (Linux and Windows) and the same for Android (currently the remote for Android works) and maybe with a possibility of adaptation for Apple …
… because coded with Go (and Fyne).

I need to take a closer look at the heart rate monitor example … and test in a different way. When I saw it for the first time, I did not understand as with this second reading (and I will have to do several reads to fully understand).

Jean-Pierre.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.