Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a Java SE sensor API? [closed]

Tags:

java

api

sensors

Does anyone know of a "standardized" Java API for working with sensors, and which is closely tied to Java ME as is the case with JSR 256?

I'm writing a Java library for interfacing with a sensor network consisting of several different types of sensors (mostly simple stuff such as temperature, humidity, GPS, etc.).

So far I've rolled my own interface, and users have to write apps against this. I would like to change this approach and implement a "standard" API so that implementations aren't that closely tied to my library.

I've looked at JSR 256, but that really isn't a great solution as it's for Java ME, and my library is mostly used by Android devices or laptops running the full Java SE.

like image 319
Martin Strandbygaard Avatar asked Feb 25 '10 22:02

Martin Strandbygaard


3 Answers

JSR-256 does not seem to be limited or restricted in the types of sensors it supports. Appendix E contains sensor definitions, but those are just the recommended data a certain type of sensor should handle. There does not seem to be anything stopping somebody from defining additional sensor types.

I would suggest you implement to JSR-256 and then just include its packages:

  • javax.microedition.sensor
  • javax.microedition.sensor.control

...in your distribution. Since they're targeting limited devices, the library is bound to be very compact. As long as you would not be prohibited from re-distributing the reference implementation of JSR-256 it would make sense to plan to do so.

like image 182
shadit Avatar answered Oct 10 '22 14:10

shadit


Not quite. JSR-275 was intended to have part of its functionality (Quantities and a Unit type very similar to that in 256) but the SE/EE EC turned it down.

Consolidation between SE and ME as mentioned by Oracle may lead to a more common Sensor API and Unit framework some time, but it's unlikely before Java 8.

Werner

like image 24
Werner Keil Avatar answered Oct 10 '22 15:10

Werner Keil


In android there is the android.hardware package that contains a class Sensor, all in all quite similar to tje JSR 256 sensor api. Please see what you can do using that. Maybe it's even a reasonable approach to implement that in Java SE, for as far as I know, there is no Java SE sensor api.

like image 27
Bex Avatar answered Oct 10 '22 16:10

Bex