Isochronous USB transfer callback has no data - google-chrome-app

The documentation is straightforward here: http://developer.chrome.com/apps/app_hardware.html#isochronous_transfers
It says the callback will be done on the findDevice.onEvent callback. However, the documentation appears to be behind, because the API no longer uses usb.findDevice, instead, it is usb.findDevices. usb.findDevices does not appear to have an option to define an onEvent.
Here is the current usb.findDevices documentation: http://developer.chrome.com/apps/usb.html#method-findDevices
Packaged Apps concept is wonderful, but the documentation is very confusing at the moment. Would love some help. Thanks
Updated Question
My question is, how do I get the data back from the Isochronous connection?

Related

How do I access subscription data when using MonitoringMode.Sampling?

I'm trying to find out how to use Eclipse Milo, and finding out how subscriptions go. I can easily get any MonitoringMode.Reporting mode subscription to work, but when I use Sampling it doesn't call the callback method (as expected). According to the docs it's supposed to "queue" up the values without calling the callback, but I can't find any place I can access that queue or anything similar. The UaMonitoredItem doesn't have anything in its interface that looks like it, neither does the request.
It's probably something obvious, but what am I doing wrong?
Thank you in advance!
Answered in the GitHub repo discussions, but for posterity:
MonitoringMode.Sampling simply means the server continues to sample the underlying but does not report the values to the client.
The queued values are not available to you. If you change back to MonitoringMode.Reporting then they would be the first values reported for that item.

Best way to pass binary data (YUV Buffer) from plugin to browser

What is the best way to transfer binary data from plugin to browser.
We want to play YUV buffer received from network on browser tab.
currently am converting to base64 and giving via callback. but it is not efficient and am finding below issues
1> CPU and Memory is going up
2> Callback events are not passed when we change the browser tab, later all events are given at one shot on moving back to our tab.
I would also like to know is there any way we can directly draw YUV frame on browser using plugin thread itself.
Thanks in advance.
NPAPI has been removed from most major browsers... the last holdout, Safari, will be removing it as of macOS Mojave. That being the case, don't expect any updates of any kind to the spec -- however you're using it is likely a dying method.
That being the case, on windows there is a method (super hack, really) that you can use to draw directly to the window in the browser from a native message extension, but it's not portable and it depends on internal implementation details. I haven't actually looked into it since I wrote that other answer (linked in this paragraph) so I don't know if it still works or not.
Anyway, if you're on a browser which fully supports NPAPI then you could draw the YUV data directly to the plugin window given to you on the browser; there is an example of blitting image data in FireBreath which you could possibly trace through as an example.
You could also try some variation of listening on a TCP port in the plugin and connecting to it from the browser; you could easily run into some security issues there, but it is the only other method I can think of.
NPAPI simply wasn't ever designed to allow fast transfer of data between the plugin and the browser; I submitted a proposal to add that capability years ago but it was basically too close to the death of NPAPI (which is basically past at this point) for it to go anywhere. The issues you're seeing are 100% consistent with what I would expect, though... and it's still the best way I know.

Wake app at regular intervals while using UIBackgroundModes=location

I'm developing a navigation app which uses the UIBackgroundModes=location setting and receives CLLocationManager updates via didUpdateToLocation. That works fine.
The problem is that the intervals between location updates are very hard to predict and I need to make sure the app is called something like once every few seconds to do some other (tiny) amounts of work even if the location did not change significantly.
Can I do that? Am I allowed to do that? And how can I do that?
I found a blog post, but I'm not sure if this is really the way to proceed.
Permissible background operations are pretty limited in scope. You cannot, for example, just leave an NSTimer running to perform some arbitrary code while your application is in the background - so the simple answer to your question is no, you cannot. Definitely read the Apple documentation regarding what is and isn't allowed (most of what's allowed pertains to apps that "need" specific ongoing services, like the ability to play music, or respond to location changes (GPS type apps...). You may be able to construct a viable solution by responding to location or significant location change notifications...

Posting location updates in background from iOS4

Can i send location updates to my server in background from iOS4?. I want to get users location changes and post it to a server using a web-service call. Main question here is, is it possible to call a web-service or http-post while app is in background?
Absolutely, and you may want to review this earlier thread when I asked the same question - credit due to #RedBlueThing for providing the key information.
I've written this up as an example on our blog as well. The key to this working is beginBackgroundTaskWithExpirationHandler: without that you won't get reliable results as it will perhaps work some of the time, but not others.
Yes. You can basically do anything you want in the background callbacks.
I'd like to add that you should make sure you are aware of the possible impact on battery life, as the antennas may have to be turned on to perform your requests. Perhaps you could store the locations in core data, and post it to the server when the app resumes.
But there's no technical reasons to not do it, and afaik it will pass review too.

Architecture sketch for iphone stock app

I am currently trying to build a (simplified) stock app (like the one built-in on the iphone). I setup a simple server with a REST-interface which my app can communicate with.
However I am struggling to find the right/best way to build this kind of (streaming data consumer) client on the iphone.
My best bet at the moment is to use a timer to regularly pull the xml payload from the server (the connection is async but the xml parsing is not therefor the interface is blocked sometimes. I am a bit shy of thread programming since I learned some lessons the hard way on other platforms).
I read about websockets but it is not clear for me if and how they are supported on the iphone.
How would you do it?
Any hint would be appreciated, Thanks.
websockets aren't going to help you -- that's a server-side technology to make a socket-like interface work over HTTP.
If you don't want to block the GUI, you need to use another thread. You are right to be scared of doing this, so share as little as possible (preferably nothing) between the two threads. Use a message passing mechanism to get information from the background thread to the UI thread.
Take a look at ActorKit: http://landonf.bikemonkey.org/code/iphone/ActorKit_Async_Messaging.20081203.html
Take a look at this question.
It talks about asynchronous vs synchronous connections. You will want to use an asynchronous call to get your data so you don't lock up your UI. You could use that in conjunction with a polling timer to get your data from the server.
You can find more info about the NSURLConnection in apple's documentation here