-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connect requests are not responding #8
Comments
The problem is that this implementation uses XPC (as the original Noble implementation for node.js did). With XPC, some of the event codes seem to change on every MacOS release, and they are not documented. So at every releases Goble breaks until I figure out the new event codes and update. I used to be able to look at the Node.js code and take the new codes from there, but they have updated to use the new MacOS Bluetooth APIs, and it would be a lot of work for me (almost a full rewrite) to update this package. |
So, Node.js implementation is not using xpc anymore? |
Ok, I made some changes and now the discovery works. There may be other things that don't work, if you find anything let me know. I found a pull request for noble.js with some updates for catalina (see https://github.com/lzever/noble/blob/master/lib/mac/catalina.js) but I am not sure of how good they are (the message id for "start scanning" was wrong). |
@raff The discovery was working for me before. What was not working is the connect. I will give it another try. Thanks |
There should be a change for the connect also. Let me know if it works. |
@raff This is much better. Now I am getting a connect event back from the peripheral. Thank you so much for your help. |
@raff Just wanted to give you an update. It looks like there is still a problem after the connect. When I send a DiscoverServices request, I am getting a response with code 58 which currently is being handled as a response to a connect. I think 58 needs to match with the ServiceDiscovery response handler. Following is a trace of the events and you can see the issue: 2020/03/27 15:52:57 sendCBMsg xpc.Dict{"kCBMsgArgs":xpc.Dict{"kCBMsgArgName":"goble-1585338777", "kCBMsgArgOptions":xpc.Dict{"kCBInitOptionShowPowerAlert":0}, "kCBMsgArgType":0}, "kCBMsgId":1} // Receive StateChange // Send StartScanning //Receive Discover // Send Stop Scanning // Send Connect // Receive Connect // Send DiscoverServices // Receive 58 (This event is going to Connect response handler again) Please let me know what you thing. Thanks, |
You can try to do what I did for descriptorDiscover (case 75). In connect (case 58):
I guess I could also move the connect case right before the serviceDiscover case and do a "followthrough". Try it out and if it works, I'll update. |
That fixed the flow but somehow I was thinking that either the discover or the connect responses will provide the UUIDs for the services available. Right now, when I call DiscoverServices with empty list (as I did not get anything from the discover or connect commands), I am getting back empty list so I can't proceed from there. Thanks |
Also, I noticed that right after recieving the 58 event (which was rerouted to 82), I also received an event with id 60 which is being handled as a Discover event but because it does not have advertisement data, it is ignored. 2020/03/27 17:13:02 done event: 82 Is this event something that is returning the service uuid? Thanks |
I really don't know. Unfortunately none of this is documented, and I don't know BLE that much. I was mainly going with what noble.js was doing. Anyway, I'll update the code to support the connect and see if I find anything else. |
Thanks so much. Can you please point to what version of noble.js you are looking at? I found a few of them and I could not figure it out which one to look for guidance. |
This https://github.com/lzever/noble/ has a branch with Catalina support (https://github.com/lzever/noble/blob/master/lib/mac/catalina.js) but the message codes seem to be wrong. I used to look at https://github.com/noble/noble, but it seems that is not mantained anymore. And this one https://github.com/abandonware/noble has switched to use the new MacOS BLE APIs. I thought of doing a wrapper for their C code (it's actually ObjectiveC - see https://github.com/abandonware/noble/tree/master/lib/mac/src) but I don't really have time at this point. |
I was looking at some go implementations and it looks like the Service and Characteristics requests are treated differently than scanning and discover which are asynchronous. The Services and Characteristics requests seem to be done synchronously. I will continue digging a little bit more. Thanks |
@raff I was able to get the sample underhttps://github.com/abandonware/noble working and I am getting the correct results. Is anyway to figure it out the correct codes from this? Thanks and sorry for so many questions. |
Again, this version uses the new MacOS Bluetooth APIs. Completely different than the original version. To make it accessible to Go it would require a complete rewrite of goble (that I can't do at this time). |
just wondering if there is a current golang mac Catalina 10.15.7 ble package or are the node.js ones the only working at this point? |
You might find the following repo useful:
https://github.com/JuulLabs-OSS/ble
…On Thu, 1 Oct 2020 at 12:26, Andrew Arrow ***@***.***> wrote:
just wondering if there is a current golang mac Catalina 10.15.7 ble
package or is the node.js ones the only working at this point?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#8 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AALLO6XYQYJAQGIOLJUMLP3SISUSBANCNFSM4LUU6LRQ>
.
|
Somebody else suggested to have a look at this: go-ble/ble#67 |
ok, I guess we were looking at the same thing. |
Hello,
I was able to get the code compiled and seems to be working ok until I call ble.Connect. After calling connect I don't get any response from the peripheral.
Also, I have noticed that I am getting events of type 42 but the code does not handle that event type.
2020/03/26 20:51:29 event: 42 xpc.Dict{"kCBAdvDataDeviceAddress":[]uint8{0x6c, 0xf9, 0x45, 0xc7, 0x5c, 0xbb}}. These events are comming even after I called ble.StopScanning.
Following is a sequence of what I am doing:
Please advise if something else is required to be sent for getting a connection response.
Thanks,
Marcelo
The text was updated successfully, but these errors were encountered: