GithubHelp home page GithubHelp logo

particle-iot / spark-sdk-android Goto Github PK

View Code? Open in Web Editor NEW
45.0 61.0 36.0 707 KB

Former home of the Official Particle Cloud SDK for Android

License: Apache License 2.0

Java 100.00%
particle photon electron core iot android java sdk

spark-sdk-android's Introduction

spark-sdk-android's People

Contributors

cityvibes avatar idokleinman avatar jensck avatar reddigfabian avatar zalsader avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spark-sdk-android's Issues

Add tests

  • Unit
  • Integration
  • Acceptance

Open for discussion on tools and approach
cc @jensck

Global listener in ParticleCloud for system events

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)

CallFunction(...) Arguments exceed max args length of 63

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) 

NullPointerException on getDevices

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)

AuthenticatedSseEventStream.processProgressEvent sometimes emits eventName = "message"

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.

getVariable() only supporting INT type result, not DOUBLE nor STRING

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?

Add support for all device types/names by platform id

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

Change to v0.3.0 causes dexDebug Error

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.

nuke resetFlashingState

nuke resetFlashingState() - work with global system events (rather than dumb flashing timer)

ParticleDevice.subscribeToEvents doesn't include access_token in Uri

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.

How to receive more than one variable in the async task?

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

System.err: a.a.a.a.a.ac

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

Compare session token injection to iOS SDK

-(BOOL)injectSessionAccessToken:(NSString * _Nonnull)accessToken;

-(BOOL)injectSessionAccessToken:(NSString *)accessToken withExpiryDate:(NSDate *)expiryDate

-(BOOL)injectSessionAccessToken:(NSString *)accessToken withExpiryDate:(NSDate *)expiryDate andRefreshToken:(NSString *)refreshToken;

Async RejectedExecutionException

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:

  • Use our own ThreadPoolExecutor with a higher limit
    • Overload executeAsync() allowing developers to specify ThreadPoolExecutor limits.
    • Add global mutable state Async.setExecutor()

Once either option is implemented following has to be considered:

  • Check/catch RejectedExecutionException in all overloaded executeAsync() methods.
  • Execute executeAsync() call without throwing a ParticleCloudException (perhaps we should return a boolean response indicating wether task was added to a queue).

Add missing fields that now are visible in getDevice response

Add missing fields that now are visible in getDevice response (compare to iOS)

  • platform_id/product_id
  • last_heard
  • firmware version (build target) - (also new for iOS)
  • IP Address
  • status? consult - might be unused as well
  • lastAppName - unsupported yet AFAIK

Add proper getters for those and compare getter names to iOS SDK

Unsubscribing from events not working

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.