particle-iot / spark-sdk-android Goto Github PK
View Code? Open in Web Editor NEWFormer home of the Official Particle Cloud SDK for Android
License: Apache License 2.0
Former home of the Official Particle Cloud SDK for Android
License: Apache License 2.0
Hello,
I am using the cloudsdk and used gradle to import the dependency (io.particle:cloudsdk:0.3.4. What I'm trying to achieve is to login using the Particle cloud sdk, get a list of devices and communicate with them. When it is in debugging mode, everything works fine. In release, I added the oauth credentials inside the strings.xml file. I get the following message when I try to login:
W/System.err: a.a.a.a.a.ac
06-28 01:46:08.516 952-1030/? W/System.err: at a.a.a.a.a.y.a(Unknown Source)
06-28 01:46:08.516 952-1030/? W/System.err: at com.bmertech.activities.k.a(Unknown Source)
06-28 01:46:08.516 952-1030/? W/System.err: at com.bmertech.activities.k.doInBackground(Unknown Source)
06-28 01:46:08.516 952-1030/? W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:292)
06-28 01:46:08.516 952-1030/? W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
06-28 01:46:08.516 952-1030/? W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
06-28 01:46:08.517 952-1030/? W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-28 01:46:08.517 952-1030/? W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-28 01:46:08.517 952-1030/? W/System.err: at java.lang.Thread.run(Thread.java:818)
Thank you for your on-going support,
Nirujan
I am just curious if there is a known date that subscribing to device events will be added.
Thanks
As seen in the Cloud Functions documentation, available here, the /v1/devices/{DEVICE_ID}/{VARIABLE}
call currently supports three data types: INT, DOUBLE and STRING (with a maximum string size of 622 bytes).
But the Android SDK getVariable()
function only supports the int type result.
This is defined in the int getVariable(String variableName)
function in the /cloudsdk/src/main/java/io/particle/android/sdk/cloud/SparkDevice.java
file, and the Responses.ReadVariableResponse
type, in the /cloudsdk/src/main/java/io/particle/android/sdk/cloud/Responses.java
file.
Any idea on when a patch will be available to solve this issue? and the updated version in Gradle?
Open for discussion on tools and approach
cc @jensck
I'm getting an odd error with release 3.4 of the Android SDK. For some reason whenever it tries to get one of my devices I get a nullpointerexception that crashes the whole app.
It looks like it's getting a null returned from one of my variables... But it's not null... and I can read it just fine from other sources (REST API, and the Spark Atom IDE...
It also seems to work fine with older versions of the SDK. Anyone else seeing similar issues? (The device in question is Spark, not a photon if that makes any difference...)
"FATAL EXCEPTION: AsyncTask #1
Process: screamingcities.com.autohomeultra, PID: 11659
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:309)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.NullPointerException: null value in entry: cMode=null
at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:33)
at com.google.common.collect.RegularImmutableMap.(RegularImmutableMap.java:88)
at com.google.common.collect.ImmutableMap.copyOf(ImmutableMap.java:294)
at io.particle.android.sdk.cloud.ParticleCloud.fromCompleteDevice(ParticleCloud.java:580)
at io.particle.android.sdk.cloud.ParticleCloud.getDevice(ParticleCloud.java:534)
at io.particle.android.sdk.cloud.ParticleCloud.getDevice(ParticleCloud.java:530)
at io.particle.android.sdk.cloud.ParticleCloud.getDevices(ParticleCloud.java:227)
at screamingcities.com.autohomeultra.FragmentRemoteLights$2.callApi(FragmentRemoteLights.java:72)
at screamingcities.com.autohomeultra.FragmentRemoteLights$2.callApi(FragmentRemoteLights.java:69)
at io.particle.android.sdk.utils.Async$AsyncApiWorker.doInBackground(Async.java:105)
at io.particle.android.sdk.utils.Async$AsyncApiWorker.doInBackground(Async.java:73)
at android.os.AsyncTask$2.call(AsyncTask.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
See which ones need attention and which do not - clean them up
The cloudsdk\build.gradle returns the following error when trying to load the project:
Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to "ccbf255801ffbc86319e3fd14bdc0682272bf5c9".
Modify signup function to support optional new accountInfo fields (first/last/company names, company account yes/no)
Hello,
I am currently working on the issue of not knowing how to get multiple variable out of one async task function.
I would be very happy about an example code showing how to do that because the example app currently only shows how to get one variable at a time.
That make it clear I am not that experienced in Android Studio or Java but I however did not find an answer to my issue.
Thanks
nuke resetFlashingState()
- work with global system events (rather than dumb flashing timer)
A working project in v0.2.1 errors in version v0.3.0.
Building the project works correctly, but trying to run/debug on my device causes this error to be thrown:
:app:dexDebug
AGPBI: {"kind":"simple","text":"UNEXPECTED TOP-LEVEL EXCEPTION:","sources":[{}]}
AGPBI: {"kind":"simple","text":"com.android.dex.DexException: Multiple dex files define Lorg/kaazing/gateway/client/transport/http/HttpRequestDelegateListener;","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:596)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:554)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:535)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:171)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.merge.DexMerger.merge(DexMerger.java:189)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:502)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.run(Main.java:277)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.dexer.Main.main(Main.java:245)","sources":[{}]}
AGPBI: {"kind":"simple","text":"\tat com.android.dx.command.Main.main(Main.java:106)","sources":[{}]}
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:dexDebug'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.7.0_75\bin\java.exe'' finished with non-zero exit value 2
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Not sure what Lorg/kaazing/gateway is.
As the title is saying, is it possible to redirect the API to our own cloud server?
please refer to the comments in the following forum post thread:
there are stack traces and http screenshots in that thread towards the very bottom.
When processProgressEvent is called with the complete event string (both lines) the event is parsed correctly and it emits an event with the correct event name and data. However, when it is called twice, once with the first line and then again with the second line, the event's name is not persisted between the two consecutive calls.
The variable name
in line 198 of AuthenticatedSseEventStream.java is set to the correct event name in the first call to the function, however at the second call it is set to the default: "message" and is emitted that way to the subscriber.
After upgrading to the io.particle:cloudsdk:0.2.2, the CallFunction() seems added a limitation on the argument length that breaks my App.
Could someone explain why the limit is set to 63 and would this be changed in the future sdk versions? It would be rather inefficient if I have to break the current argument and send in two steps.
Thanks!
Stack trace:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalArgumentException: Arguments 'cnt=8000|rdt=9000|mtt=11000|mot=8000|rlt=1500|rlp=1000|srr=19|srt=29' exceed max args length of 63
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
at io.particle.android.sdk.cloud.ParticleDevice.callFunction(ParticleDevice.java:265)
at com.rwmobi.garadget.activities.SettingsActivity$3.callApi(SettingsActivity.java:257)
at com.rwmobi.garadget.activities.SettingsActivity$3.callApi(SettingsActivity.java:253)
at io.particle.android.sdk.utils.Async$AsyncApiWorker.doInBackground(Async.java:103)
at io.particle.android.sdk.utils.Async$AsyncApiWorker.doInBackground(Async.java:71)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
rename changeDeviceName()
func to rename()
(or create an alias) to be consistent with func names on iOS.
cc @jensck what do you think?
Per #13 we can apparently cause mystery failures if Proguard-ed
Add missing fields that now are visible in getDevice response (compare to iOS)
Add proper getters for those and compare getter names to iOS SDK
Add a global listener for system events to update device connection/flashing status
(probably: have a weak pointer list of devices in the ParticleCloud class) - add a ParticleDeviceDelegate for auto updates (or relevant code pattern in Java)
A few hard-coded UI strings crept into the code -- convert to XML resources.
Cloud SDK Async
implementation occasionally throws RejectedExecutionException
(once ThreadPoolExecutor limit is exceeded). This exception was also a culprit behind few crashes on Tinker app.
Few options put forward by @jensck:
executeAsync()
allowing developers to specify ThreadPoolExecutor
limits.Async.setExecutor()
Once either option is implemented following has to be considered:
RejectedExecutionException
in all overloaded executeAsync()
methods.executeAsync()
call without throwing a ParticleCloudException
(perhaps we should return a boolean response indicating wether task was added to a queue).I don't see a clean way of developing a flexible app alongside a homescreen widget. Am I missing something?
add support for all device types names by platform id
currently only core=0/photon=5..6/electron=10 are supported.
Compare to iOS:
SparkDeviceTypePhoton=6, // or P0
SparkDeviceTypeP1=8,
SparkDeviceTypeElectron=10,
SparkDeviceTypeRaspberryPi=31,
SparkDeviceTypeRedBearDuo=88,
SparkDeviceTypeBluz=103,
SparkDeviceTypeDigistumpOak=82,
Also add a device-type to string method
-(BOOL)injectSessionAccessToken:(NSString * _Nonnull)accessToken;
-(BOOL)injectSessionAccessToken:(NSString *)accessToken withExpiryDate:(NSDate *)expiryDate
-(BOOL)injectSessionAccessToken:(NSString *)accessToken withExpiryDate:(NSDate *)expiryDate andRefreshToken:(NSString *)refreshToken;
Update the sdk to use Retrofit 2.0
Calling unsubscribeFromEventWithID
with the ID given by subscribeToEvents
doesn't really unsubscribe. Messages are not transmitted to the handler anymore but the connection to the cloud is kept as I can still see messages like those in the console:
entering org.kaazing.net.sse.impl.AuthenticatedSseEventSourceImpl.messageReceived {"data":"mydata","ttl":"60","published_at":"2016-08-19T00:34:34.796Z","coreid":"xxxxx"}
Of course doing some subscribe / unsubscribe sequences make the number of connections grow and there's no way to kill them and it hurts the battery.
This is in reference to this open topic on the particle community forums.
After digging through some of the cloud sdk's source code and understanding a portion of it, it seems that the sdk does not include the ParticleCloud instance's current access token as a parameter in the Uri that is passed to the EventReader.
I cloned the repo and made enough changes to get the uri that gets output to the log in subscribeToEventWithUri to function in a browser.
However the ParticleEventHandler I've implemented in my app still isn't receiving events.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.