-
Notifications
You must be signed in to change notification settings - Fork 44
Add callback support to advertise* and stop API's #25
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
base: master
Are you sure you want to change the base?
Conversation
|
Looks like it solves async problems, and gives the bleno start and stop error in the process. It still seems wierd though that if ble is off, you just wouldnt get anything back from the start callback right? Because eddystone will keep spinning waiting for statechange to be powered on? Also theres event to either get a global error (not sure why you would) or more likely to be notified that state change poweredoff and advertising has presumably stopped |
Correct. What are you thinking, should we call the callback with an error in this case (similar for other states: unauthorized, unsupported) |
|
Sure, but when? State isnt exposed to user currently so they have no way to wait until state before calling. So if you just return the error theyd have to just keep calling until success which isnt ideal. Or if you keep it as it currently is, youd use a timeout? but that feels awful. Think youd have to expose state. so you can do it the way bleno does it, wait for state then go |
Good point.
We can leave the callbacks in, but need to do something like: var eddystoneBeacon = require('eddystone-beacon');
eddystoneBeacon.on('adapterStateChange', function(adapterState) {
if (state === 'poweredOn') {
eddystoneBeacon.advertiseUrl('http://www.google.com');
} else {
console.log('can\'t start advertising, adapter state = %s', adapterState);
}
});So changes I'm thinking about are:
This is a breaking change, but I think it's for the best. @jacobrosenthal is this what you were thinking? cc/ @don |
|
I like the idea of calling the callback with an error if the adapter state is not poweredOn. But, re-emitting the bleno state changes makes the code work like bleno, which is a good thing. Is it worth duplicating the events or just using bleno? (Probably worth duplicating as long as we don't have to duplicate a bunch of other stuff too.) |
|
Turns out I need the state change in order to do my platform check. Currently we platform check every time we advertise, which can be 10+ times a second. I want to cache that on startup, but theres currently no way to know when bleno is ready (in my case, that the websocket is open) |
|
Hmm, I'm wondering if it would be better to have a static property, like |
|
I think you're saying what I thought I was saying. On Mon, Sep 28, 2015 at 2:15 AM, Sandeep Mistry notifications@github.com
|
|
@jacobrosenthal right, let's bring the discussion over to bleno then? We need to split this discussion up:
|
|
So back on callback support here, I actually get an error on linux with uid/with-tlm/js every time startadvertising is called, Command Disallowed, do you know what that one might refer to @sandeepmistry ? |
|
@jacobrosenthal that's the response to the HCI command bleno is issuing, you can run an |
Alternative to #22, need to update read me later.
Example:
@jacobrosenthal thoughts?