Skip to content
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

Add a Fat Beacon support and an example #42

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

hardillb
Copy link

@hardillb hardillb commented Sep 6, 2016

Based on the discussion in google/physical-web#814 this should add Fat Beacon support to node-eddystone-beacon

@jacobrosenthal
Copy link

Only looked at this for 2 seconds so far, but doesnt appear to work on osx (yosemite)

@hardillb
Copy link
Author

hardillb commented Sep 6, 2016

Unless something has changed I thought connects don't work on OSx

@hardillb
Copy link
Author

hardillb commented Sep 6, 2016

Also the on('accept') is Linux only

"<div>Adding more content to see if I can it over the MTU value</div>" +
"</body>" +
"</html>";

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about adding this in a separate file and using the fs module to read the contents?

@sandeepmistry
Copy link
Collaborator

@hardillb nice work!

Unless something has changed I thought connects don't work on OSx

This might be ok with Yosemite since the kCBAdvDataAppleMfgData key is used (which is a hidden key). @jacobrosenthal I can set up my Android tablet to test with later this week if you want me to try with OS X Yosemite.

@jacobrosenthal noticed the MTU was negotiated to 505 bytes, which seems a bit high ... I think the max according to spec is 256 bytes.

@hayesjordan
Copy link

Everything looks fine to me as far as FatBeacon is concerned. I have to admit I am not a Node expert though.

HTMLCharacteristic.prototype.onReadRequest = function(offset, callback) {
//var buf = new Buffer(this._html, 'utf8');
if (queueOffset < this._buffer.length) {
var transfer = currentMTU - 5;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hayesjordan can you comment on why physical web is using -5 instead of -3 overhead?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no specific reason for using -5, it can be anything less than 0. The only reason for it is to by pass the Android OS on the client device.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its currently oddly implemented on the android side. Transfer is defaulted to 20 (which would be default (23) -3 as Id expect, but then when mtu changes its mtu (505)-5 Seems like if you wanted it to be mtu-5 then transfer defined above there should be 18 not 20 for consistancy.. though it seems like it should be the size of the BLE spec overhead, which I think is 3.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not aware of a BLE spec for overhead, but the numbers didn't seem to be important at the time. I was only trying to keep them for easy multiples when I was debugging this is.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I come from the embedded world more, and I know 20 bytes of the 23 is typical for the nordic devices, I presume this is in the spec, perhaps its their limitations. Ill keep researching and maybe @sandeepmistry can illuminate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like as low as 1 actually. Ive heard 20 quoted a ton on nrf, wonder if thats correct over there.

3.4.7.1 Handle Value Notification
Attribute Value
0 to (ATT_MTU–3)

3.4.4.4 Read Response
0 to (ATT_MTU–1)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jacobrosenthal 23 bytes is the minimum MTU (and default). I'm reading from unofficial sources the maximum is 517 bytes. On Linux, bleno currently has a maximum MTU of 256 bytes, we can bump this up once we find the official maximum MTU size.

20 bytes is right for the maximum notification data size: 23 - 3

and 22 for the maximum size of read data if the MTU is 23: 23 -1

@jacobrosenthal
Copy link

So I can get this to 'work' on osx by altering just like the 'connectable' demo, waiting until after advertising starts to setServices
jacobrosenthal@848a1d6

However its .. very odd. It works once (ie probably before some kind of caching) then if I dont disable ble and reenable, were getting a read before the MTU change

first time after turning off ble or after a while (successful)
53 -> 23 mtu
82 connection update
53 -> 505 mtu (not sure why osx bleno gets 2 mtu changes, but we do on all clients so..)
19 readRequest offset 0
19 readRequest offset 0
82 connection update
22 unsubscribe

second time (odd behavior)
53 -> 505 mtu
19 readRequest offset 0
53 -> 505 mtu (not sure why osx bleno gets 2 mtu changes, but we do on all clients so..)
19 readRequest offset 504
19 readRequest offset 0
82 connection update
22 unsubscribe

The mtuchange is in the onConnectionStateChange, Ive tried moving it forward to the onServicesDiscovered but had the same result....

@jacobrosenthal
Copy link

Oh and one more thing, removing the mtu change request in android 'fixes' this with obviously many more transfers

@scottjenson
Copy link

I was traveling and fell behind on my github responsibilities. Where does this stand. Is this ready to merge or are there still some strong issues that still need to be resolved?

@sandeepmistry
Copy link
Collaborator

@jacobrosenthal can fill us in, but I don't think this can be merged. From what I recall OS X + Android had some weird caching issues with the MTU exchange.

I've proposed an alternative idea for the protocol instead of using read attributes here: google/physical-web#784 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants