Giter VIP home page Giter VIP logo

sitewhere-android-sdk's Introduction

SiteWhere

SiteWhere Android SDK

license

This software development kit allows Android devices to interact with SiteWhere. By default, the MQTT protocol is used to create a persistent connection between the application and a SiteWhere instance. Devices can register with the system, publish events using the provided API and receive commands which can be used to execute code on the device.

Developer Setup

Quickstart

Step 1. Clone this repository.

Step 2. Create a new Project.

Step 3. Add the following to the settings.gradle file:

include ':sitewhere-android-sdk'
project(':sitewhere-android-sdk').projectDir = new File('../sitewhere-android-sdk') // <- points to the 'sitewhere-android-sdk' folder inside local repository cloned in Step 1 

Step 4. Select "Open Module Settings" and add module "sitewhere-android-sdk" in the Dependencies tab.

Sample Application

The sample app can be found in the SiteWhereExample folder. The app demostrates how an Android device can be an IoT gateway and/or client device for SiteWhere. As an IoT gateway you can register an Android device with SiteWhere and send location and measurement events. As an IoT client you can register to have events pushed in real-time to an Android device. Configuring what events get pushed to a specific device is done using server side filters and groovy scripts. The sample app uses the device's current location and accelerometer.

Discussion

Join the discussion

sitewhere-android-sdk's People

Contributors

bickster avatar ccastillo22 avatar derekadams avatar jorgevillaverde-sitewhere avatar scnets avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

sitewhere-android-sdk's Issues

Exception obtaining JWT

after when i use ISiteWhereClient initialized , Futere.get() code throws an exception.
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802) 
Caused by: java.util.concurrent.ExecutionException: com.sitewhere.spi.SiteWhereException: Exception obtaining JWT.
at java.util.concurrent.FutureTask.report(FutureTask.java:94)
at java.util.concurrent.FutureTask.get(FutureTask.java:164)
at com.zt.ztadvertisement.activity.newAct.SmallMainActivity.sitWhereLogin(SmallMainActivity.kt:454)
at com.zt.ztadvertisement.activity.newAct.SmallMainActivity.access$sitWhereLogin(SmallMainActivity.kt:49)
at com.zt.ztadvertisement.activity.newAct.SmallMainActivity$onMQTTServiceReady$1.run(SmallMainActivity.kt:340)
at android.os.Handler.handleCallback(Handler.java:755)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6141)
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:802) 
Caused by: com.sitewhere.spi.SiteWhereException: Exception obtaining JWT.
at com.sitewhere.rest.client.SiteWhereClient.initialize(SiteWhereClient.java:556)
at com.zt.ztadvertisement.activity.newAct.SmallMainActivity$SiteWhereClientConnector.call(SmallMainActivity.kt:590)
at com.zt.ztadvertisement.activity.newAct.SmallMainActivity$SiteWhereClientConnector.call(SmallMainActivity.kt:579)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
Caused by: java.net.UnknownHostException: Unable to resolve host "iot.dtznjg.com": No address associated with hostname
at java.net.Inet6AddressImpl.lookupHostByName(Inet6AddressImpl.java:125)
at java.net.Inet6AddressImpl.lookupAllHostAddr(Inet6AddressImpl.java:74)
at java.net.InetAddress.getAllByName(InetAddress.java:752)
at okhttp3.Dns$1.lookup(Dns.java:40)
at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:185)
at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.java:149)
at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:84)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:214)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at com.sitewhere.rest.client.SiteWhereClient$1.intercept(SiteWhereClient.java:575)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:254)
at okhttp3.RealCall.execute(RealCall.java:92)
at retrofit2.OkHttpCall.execute(OkHttpCall.

problem in use

When I build an ISiteWhereClient and initialized, is the login status successful? How do I get token?

Server verify failed

when i run this demo it shows thant 'Server verify failed unable to connect to sever ' , what should i do ?

Cant get the Exampleprogram to work / compile on AndroidStudio 3.0.1

Hi,
I'm not superexperience in programming so I might just be overlooking something ridiculously stupid. But when I load the Example Program, it doesnt compile. First it complains about miltidexing, then it cant see classes in com.google.protobuf:protobuf-java:2.5.0, etc etc etc.

Did anyone else try to compile this in the newest android studi, and if yes, did it work for you?

Kind Regards, JSN

Android Unable to Connect to Server

Server verify failed: Unable to connect to server

  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sitewhere.server.SiteWhereServer"

verify failed

E/SiteWhereConnectivity: SiteWhere version call failed.
com.sitewhere.spi.SiteWhereException: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "gitRevisionAbbrev" (class com.sitewhere.rest.model.system.Version), not marked as ignorable (5 known properties: "buildTimestamp", "versionIdentifier", "serverClass", "edition", "editionIdentifier"])
at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 51] (through reference chain: com.sitewhere.rest.model.system.Version["gitRevisionAbbrev"])
at com.sitewhere.rest.client.SiteWhereClient.processRestCall(SiteWhereClient.java:523)
at com.sitewhere.rest.client.SiteWhereClient.getSiteWhereVersion(SiteWhereClient.java:152)
at com.sitewhere.android.example.ConnectivityWizardFragment$HostVerifier.run(ConnectivityWizardFragment.java:665)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:459)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "gitRevisionAbbrev" (class com.sitewhere.rest.model.system.Version), not marked as ignorable (5 known properties: "buildTimestamp", "versionIdentifier", "serverClass", "edition", "editionIdentifier"])
at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 51] (through reference chain: com.sitewhere.rest.model.system.Version["gitRevisionAbbrev"])
at com.fasterxml.jackson.databind.DeserializationContext.handleUnknownProperty(DeserializationContext.java:822)
at com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1152)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1582)
at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1560)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:294)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:151)
at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1611)
at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1203)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:32)
at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)
at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:223)
at retrofit2.OkHttpCall.execute(OkHttpCall.java:186)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(ExecutorCallAdapterFactory.java:92)
at com.sitewhere.rest.client.SiteWhereClient.processRestCall(SiteWhereClient.java:516)
at com.sitewhere.rest.client.SiteWhereClient.getSiteWhereVersion(SiteWhereClient.java:152) 
at com.sitewhere.android.example.ConnectivityWizardFragment$HostVerifier.run(ConnectivityWizardFragment.java:665) 
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:459) 
at java.util.concurrent.FutureTask.run(FutureTask.java:266) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) 
at java.lang.Thread.run(Thread.java:764) 

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.