Skip to content

Java SDK for Iotivity

License

EPL-1.0, Unknown licenses found

Licenses found

EPL-1.0
LICENSE
Unknown
LICENSE.md
Notifications You must be signed in to change notification settings

Learn-iot/iochibity-java

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iotivity-java

Java API/SDK for Iotivity

This is the Java API and JNI wrapper code for Iotivity, broken out into a stand-alone project. It is derived from work by Petre Eftime (patch 7895).

It seems to build and work on Ubuntu with the latest source pulled from master. It also works with iochibity on Darwin.

building

jni

Step one is to adapt source.me to your system. The provided code assumes that this SDK is cloned to $HOME/iotivity/kit/java and that the Iotivity dev kit is at $HOME/iotivity/iotivity; change as needed, then source it: $ source source.me.

Then build the JNI layer. Edit jni/Makefile to adjust the vars to your setup, then just run $ make <host>, for example make linux.

Note
If you build it on the Edison, you want ARCH=x86; on 64 bit Ubuntu, make it x86_64.
Warning
The makefile is very much a Work-In-Progress. The goal is to make it like the one for Lua, which is very portable, but it needs some work.

api

To build the Java API, start by adjusting the version string in pom.xml. Then:

$ cd api
$ mvn install

The mvn command will compile the Java source, package it in a jar file, and install it to your local repository. The result should be in

$HOME/.m2/repository/iotivity/iotivity-api/1.1.0-SNAPSHOT

Note that this version number is for the Java API; it is not the version number of the Iotivity library.

examples

Only one of the original Android samples has been ported; it’s in examples/minimal.

Start by adjusting the versions in pom.xml

To build it, just run $ mvn package. Note that you do not need to install it.

To run it, do $ ./bin/<host>/<role>, for example, $ ./bin/linux/jserver.

If you get errors pertaining to linkage, check the source.me paths and the paths in the bin/<host>/<role> code.

ADJUST the api version in bin/jserver etc.

troubleshooting

java.lang.NoSuchMethodError: getOicSecAces - did you build the iotivity stack using SECURED=1?

darwin

On Darwin you may have to run the fixlinks.sh script to fixup the linkage info. Do this both for jni here and for your iochibity build (use bin/darwin/fixlinks.sh)

See also iotk/iotivity-clj, which is a Clojure SDK for Iotivity, built on this Java SDK.

For assistance, try iotivity-slack.

merging master

Run diff -qr against jni and api/src to see what’s changed/new etc.

copy changed and new files from master to here, remove deleted files

use (emacs) magit-status to review changes

jni merge

  • Until OCProvisioningManager.h has been renamed in master, all #include refs to this in header files must be edited to OCProvisioningManager.hpp

  • Use OC_UNUSED to eliminate warnings

in JniOcPlatform.cpp, restore #define UNUSED(expr) (void)(expr);

  • REQUIRED:

  • JniOcPlatform.cpp:

    • OCDeviceInfo deviceInfo = {

    • deviceName : NULL,

    • types : NULL,

    • specVersion : NULL

    • // dataModelVersions : NULL

    • }; -

The master codebase includes Android-dependent code. This repository is Java only, so merging master to this involves some tweaking.

  • JniCaInterface.[ch] compiles, but it’s for Android only - remove it?

  • fix #ifdef ANDROID code, e.g. in JniOcStack.h, etc.

  • switch from android/log.h to logger.h, e.g. in JniOcStack.h i.e. restore: #ifdef ANDROID #include <android/log.h> #else #include "logger.h" #endif

restore: -#ifdef ANDROID #define LOGI(…​) android_log_print(ANDROID_LOG_INFO, TAG, VA_ARGS) #define LOGD(…​) android_log_print(ANDROID_LOG_DEBUG, TAG, VA_ARGS) #define LOGE(…​) android_log_print(ANDROID_LOG_ERROR, TAG, VA_ARGS) -#else -#define LOGI(…​) OIC_LOG_V(INFO, TAG, VA_ARGS) -#define LOGD(…​) OIC_LOG_V(DEBUG, TAG, VA_ARGS) -#define LOGE(…​) OIC_LOG_V(ERROR, TAG, VA_ARGS__) -#endif

  • there are some casts that must be made explicit, e.g. in JniOcStack.h restore

    • if (g_jvm→AttachCurrentThread( (void**)&env, nullptr) < 0) for + if (g_jvm→AttachCurrentThread(&env, nullptr) < 0)

api merge

  • skip the ca stuff? except CaInterface.java and CaIpInterface.java?

  • OcDeviceInfo.java - the OcDeviceInfo class is not in sync with the OCDeviceInfo struct in octypes.h

add - private String mSpecVersion; // core.major.minor - private String mDataModelVersions; // <vertical>.major.minor

  • public OcDeviceInfo(String deviceName,

  • String specVersion,

  • String dataModelVersions) {

  • this.mDeviceName = deviceName;

  • this.mSpecVersion = specVersion;

  • this.mDataModelVersions = dataModelVersions;

  • this.mDeviceName = deviceName;

  • this.mDeviceTypes = new ArrayList<String>(){{

  • add("oic.wk.d");

  • }};

  • } -

    • OcPlatform.java and PlatformConfig.java must be adjusted since they are platform-specific. In master they assume Android.

      save originals to Android repo
      edit ctors in PlatformConfig
    • we use 'iotivity-jni' instead of 'ocstack-jni'

    • delete ^M (e.g. in OicSecAcl.java)

About

Java SDK for Iotivity

Resources

License

EPL-1.0, Unknown licenses found

Licenses found

EPL-1.0
LICENSE
Unknown
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 69.8%
  • Java 25.2%
  • Makefile 2.4%
  • C 2.3%
  • Shell 0.3%