fyne-io / fyne-x

Community extensions to the cross platform GUI in Go based on Material Design
Other
247 stars 59 forks source link

bluetooth drivers #58

Open MatejMagat305 opened 1 year ago

MatejMagat305 commented 1 year ago

this is not final version, but skeleton (base, it contains bugs and unrefactor things), I would like for some advise and notice
Goal is bring bluetooth on GO (Fyne) to android

andydotxyz commented 1 year ago

This is a really epic piece of work, thanks @MatejMagat305. I love the idea and would be happy to help push it forward. I think the main thing we need to do is figure out how to avoid the API being Android specific. The API should be agnostic to the OS so we can add more implementations in later. The two main things this means: 1) remove android from the naming 2) remove all the env and related contexts from the API (we can use the recent RunNative system so just need the fyne.App context).

I know this is a big ask, but it will make the result so much more useful over time. This may also mean that we need more interfaces where the current API is android specific structs, though in some cases it may be possible to switch out the details using compile flags.

Excellent work, thanks!

MatejMagat305 commented 1 year ago

so I remove env from functions, it is really nicer ...,

I created this for any Go library based on gomobile (I (we) will incorporate it with fyne-x, but other libraries could also import "fyne-x/..."), but if you say so, we can further integrate it with fyne (it would save several methods in C, for example streams).

there is still lots of work, but I finally believe the base form of API is done

andydotxyz commented 1 year ago

Fyne-x repo will always depend upon Fyne. If you want to offer the opportunity for people to use the Bluetooth work without that you might have to consider putting the contribution outside the fyne-x repository :(.

andydotxyz commented 1 year ago

You should not have to use linkname - you can just use RunOnJVM directly, or alias the function name to a local name if that is required for some reason. It's great to have another platform on here to show it can work - would it be possible to add a third "other" implementation that is a no-op so that apps won't fail to compile when the platform is not supported? (runtime error on init instead of a compile error).

MatejMagat305 commented 1 year ago

You should not have to use linkname - you can just use RunOnJVM directly, or alias the function name to a local name if that is required for some reason. It's great to have another platform on here to show it can work - would it be possible to add a third "other" implementation that is a no-op so that apps won't fail to compile when the platform is not supported? (runtime error on init instead of a compile error).

arch sorry, linkname was my experiment ..., and yes when it will finale version I will import .../internal/mobileinit... yes other will be done, but please give me moment, I have school exams period and I want make this for windows too, but it will hardest part of this. But thank for advise and feel free to change if you want

andydotxyz commented 1 year ago

Hi, that's all cool - no hurry. I was just catching up on PRs so people are not waiting on me or anyone in the team. Good luck with your exams.

MatejMagat305 commented 1 year ago

well I do not know the best way for windows would be https://github.com/golang/go/issues/52958, but it is stil proposial ..., what do you (@andydotxyz ) think should I try something with cgo with help tinygo.org/x/bluetooth or would I try for something like https://github.com/go-ole/go-ole/issues/198 which seems like pure go implementation? and on IOS i have no experience, I have found something, but ...

andydotxyz commented 1 year ago

think should I try something with cgo with help tinygo.org/x/bluetooth or would I try for something like go-ole/go-ole#198 which seems like pure go implementation?

I guess it's up to you, but I don't think we should be depending upon tiny at the repository level.

Also, if you are adding files from other repositories please do write a comment in the header or commit so it is clear - and double check the license of the source as well.

MatejMagat305 commented 8 months ago

I found https://github.com/OpenBluetoothToolbox/SimpleBLE can I ask you, cmd fyne can embed .jar or .dex file to apk? This jni is too complicated ..., but i do not want to bring something breaking new ... I am asking, because I found also https://git.wow.st/gmp/ble (which put idea in my head) and https://github.com/golang/sys/commit/66a0560e4e097a54e439cdc529e28fcd0f9014e8 (which add interface for windows bluetooth)

i maybe should reopen, but i do not know ...

MatejMagat305 commented 8 months ago

I found https://github.com/OpenBluetoothToolbox/SimpleBLE can I ask you, cmd fyne can embed .jar or .dex file to apk? This jni is too complicated ..., but i do not want to bring something breaking new ... I am asking, because I found also https://git.wow.st/gmp/ble (which put idea in my head) and golang/sys@66a0560 (which add interface for windows bluetooth)

i maybe should reopen, but i do not know ...

I do not know whether it will work as multiplatform, but it is progress ..., but if fyne can embede .dex file please write ......

andydotxyz commented 8 months ago

Our packaging does not support adding .jar or .dex file into the app at this time

can I ask you, cmd fyne can embed .jar or .dex file to apk? This jni is too complicated ..., but i do not want to bring something breaking new ...

No, Fyne package command cannot embed other libraries at this time