Skip to content

Commit 38f11aa

Browse files
author
Gregg Reynolds
committed
get minimal example running
Signed-off-by: Gregg Reynolds <reynolds-gregg@norc.org>
1 parent 86f827d commit 38f11aa

File tree

22 files changed

+500
-493
lines changed

22 files changed

+500
-493
lines changed

README.adoc

+57-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ some work.
3131

3232
==== api
3333

34-
To build the Java API:
34+
To build the Java API, start by adjusting the version string in
35+
pom.xml. Then:
3536

3637
[source,sh]
3738
----
@@ -54,14 +55,26 @@ version number of the Iotivity library.
5455

5556
Only one of the original Android samples has been ported; it's in `examples/minimal`.
5657

58+
Start by adjusting the versions in pom.xml
59+
5760
To build it, just run `$ mvn package`. Note that you do not need to install it.
5861

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

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

64-
On Darwin you may have to run the `fixlinks.sh` script to fixup the linkage info.
67+
ADJUST the api version in bin/jserver etc.
68+
69+
== troubleshooting
70+
71+
`java.lang.NoSuchMethodError: getOicSecAces` - did you build the iotivity stack using SECURED=1?
72+
73+
==== darwin
74+
75+
On Darwin you may have to run the `fixlinks.sh` script to fixup the
76+
linkage info. Do this both for jni here and for your iochibity build
77+
(use bin/darwin/fixlinks.sh)
6578

6679
=== related
6780

@@ -73,6 +86,13 @@ For assistance, try https://iotivity-slack.herokuapp.com/[iotivity-slack].
7386

7487
== merging master
7588

89+
Run diff -qr against jni and api/src to see what's changed/new etc.
90+
91+
copy changed and new files from master to here, remove deleted files
92+
93+
use (emacs) magit-status to review changes
94+
95+
=== jni merge
7696
* Until OCProvisioningManager.h has been renamed in master, all
7797
#include refs to this in header files must be edited to
7898
OCProvisioningManager.hpp
@@ -82,7 +102,7 @@ For assistance, try https://iotivity-slack.herokuapp.com/[iotivity-slack].
82102
in JniOcPlatform.cpp, restore
83103
#define UNUSED(expr) (void)(expr);
84104

85-
105+
* REQUIRED:
86106
* JniOcPlatform.cpp:
87107
- OCDeviceInfo deviceInfo = {
88108
- deviceName : NULL,
@@ -125,3 +145,37 @@ restore
125145
- if (g_jvm->AttachCurrentThread( (void**)&env, nullptr) < 0)
126146
for
127147
+ if (g_jvm->AttachCurrentThread(&env, nullptr) < 0)
148+
149+
=== api merge
150+
151+
* skip the ca stuff? except CaInterface.java and CaIpInterface.java?
152+
153+
* OcDeviceInfo.java - the OcDeviceInfo class is not in sync with the
154+
OCDeviceInfo struct in octypes.h
155+
156+
add - private String mSpecVersion; // core.major.minor
157+
- private String mDataModelVersions; // <vertical>.major.minor
158+
159+
- public OcDeviceInfo(String deviceName,
160+
- String specVersion,
161+
- String dataModelVersions) {
162+
- this.mDeviceName = deviceName;
163+
- this.mSpecVersion = specVersion;
164+
- this.mDataModelVersions = dataModelVersions;
165+
- this.mDeviceName = deviceName;
166+
- this.mDeviceTypes = new ArrayList<String>(){{
167+
- add("oic.wk.d");
168+
- }};
169+
- }
170+
-
171+
172+
* OcPlatform.java and PlatformConfig.java must be adjusted since they are
173+
platform-specific. In master they assume Android.
174+
175+
save originals to Android repo
176+
177+
edit ctors in PlatformConfig
178+
179+
* we use 'iotivity-jni' instead of 'ocstack-jni'
180+
181+
* delete ^M (e.g. in OicSecAcl.java)

api/pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
<groupId>iotivity</groupId>
77
<artifactId>iotivity-api</artifactId>
88
<packaging>jar</packaging>
9-
<version>1.1.2-SNAPSHOT</version>
9+
<version>1.1.3-SNAPSHOT</version>
10+
<!-- build against 1.1.1 -->
1011
<name>Iotivity Java API</name>
1112
<properties>
1213
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

api/src/main/java/org/iotivity/base/ErrorCode.java

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public enum ErrorCode {
2828
RESOURCE_CREATED("RESOURCE_CREATED", ""),
2929
RESOURCE_DELETED("RESOURCE_DELETED", ""),
3030
CONTINUE("CONTINUE", ""),
31+
RESOURCE_CHANGED("RESOURCE_CHANGED", ""),
3132
/** Success status code - END HERE.*/
3233
/* Error status code - START HERE */
3334
INVALID_URI("INVALID_URI", ""),

api/src/main/java/org/iotivity/base/OcDeviceInfo.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
public class OcDeviceInfo {
3333

3434
private String mDeviceName;
35+
private List<String> mDeviceTypes;
3536
private String mSpecVersion; // core.major.minor
3637
private String mDataModelVersions; // <vertical>.major.minor
37-
private List<String> mDeviceTypes;
3838

3939
public OcDeviceInfo(String deviceName, List<String> deviceTypes) {
4040
this.mDeviceName = deviceName;

api/src/main/java/org/iotivity/base/OcPlatform.java

+87-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
package org.iotivity.base;
2424

25-
import org.iotivity.ca.CaInterface;
25+
// import org.iotivity.ca.CaInterface;
26+
//GAR import org.iotivity.base.BuildConfig;
2627

2728
import java.util.EnumSet;
2829
import java.util.Iterator;
@@ -39,7 +40,12 @@ public final class OcPlatform {
3940
System.loadLibrary("oc_logger");
4041
System.loadLibrary("octbstack");
4142
System.loadLibrary("oc");
42-
System.loadLibrary("iotivity-jni");
43+
// if (0 != BuildConfig.SECURED)
44+
// {
45+
// System.loadLibrary("ocprovision");
46+
// System.loadLibrary("ocpmapi"); ???
47+
// }
48+
System.loadLibrary("iotivity-jni");
4349
}
4450

4551
/**
@@ -84,7 +90,8 @@ private OcPlatform() {
8490
*/
8591
public synchronized static void Configure(PlatformConfig platformConfig) {
8692
if (!sIsPlatformInitialized) {
87-
CaInterface.initialize();
93+
// CaInterface.initialize();
94+
//GAR CaInterface.initialize(platformConfig.getActivity(), platformConfig.getContext());
8895

8996
sPlatformQualityOfService = platformConfig.getQualityOfService();
9097

@@ -533,6 +540,7 @@ private static native OcResourceHandle registerResource1(
533540
*/
534541
public static void registerDeviceInfo(
535542
OcDeviceInfo ocDeviceInfo) throws OcException {
543+
536544
OcPlatform.initCheck();
537545
OcPlatform.registerDeviceInfo0(
538546
ocDeviceInfo.getDeviceName(),
@@ -894,12 +902,88 @@ public static void sendResponse(OcResourceResponse ocResourceResponse)
894902
private static native void sendResponse0(OcResourceResponse ocResourceResponse)
895903
throws OcException;
896904

905+
/**
906+
* Method to find all devices which are eligible for direct pairing and return the list.
907+
*
908+
* @param timeout timeout for discovering direct pair devices.
909+
* @param FindDirectPairingListener Callback function, which will receive the list of direct
910+
* pairable devices.
911+
* @throws OcException
912+
*/
913+
public static native void findDirectPairingDevices(int timeout,
914+
FindDirectPairingListener onFindDirectPairingListener) throws OcException;
915+
916+
/**
917+
* Method to get list of all paired devices for a given device.
918+
*
919+
* @param GetDirectPairedListener Callback function, which will receive the list of direct
920+
* paired devices.
921+
* @throws OcException
922+
*/
923+
public native void getDirectPairedDevices(GetDirectPairedListener onGetDirectPairedListener)
924+
throws OcException;
925+
926+
/**
927+
* Method to perform direct pairing between two devices.
928+
*
929+
* @param peer Target peer
930+
* @param prmType Pairing Method to be used for Pairing
931+
* @param pin pin
932+
* @param DirectPairingListener Callback function, which will be called after
933+
* completion of direct pairing.
934+
* @throws OcException
935+
*/
936+
public static void doDirectPairing(
937+
OcDirectPairDevice peer,
938+
OcPrmType prmType,
939+
String pin,
940+
DirectPairingListener onDirectPairingListener) throws OcException {
941+
942+
OcPlatform.doDirectPairing0(
943+
peer,
944+
prmType.getValue(),
945+
pin,
946+
onDirectPairingListener
947+
);
948+
}
949+
950+
private static native void doDirectPairing0(OcDirectPairDevice peer,
951+
int pmSel, String pinNumber, DirectPairingListener onDirectPairingListener)
952+
throws OcException;
953+
954+
/**
955+
* An FindDirectPairingListener can be registered via the OcPlatform.findDirectPairingDevices call.
956+
* Event listeners are notified asynchronously
957+
*/
958+
public interface FindDirectPairingListener {
959+
public void onFindDirectPairingListener(List<OcDirectPairDevice> ocPairedDeviceList);
960+
}
961+
962+
/**
963+
* Listerner to Get List of already Direct Paired devices.
964+
* An GetDirectPairedListener can be registered via the OcPlatform.getDirectPairedDevices call.
965+
* Event listeners are notified asynchronously
966+
*/
967+
public interface GetDirectPairedListener {
968+
public void onGetDirectPairedListener(List<OcDirectPairDevice> ocPairedDeviceList);
969+
}
970+
971+
/**
972+
* Listner to get result of doDirectPairing.
973+
* An DirectPairingListener can be registered via the OcPlatform.doDirectPairing call.
974+
* Event listeners are notified asynchronously
975+
*/
976+
public interface DirectPairingListener {
977+
public void onDirectPairingListener(String devId, int result);
978+
}
979+
897980
/**
898981
* An OnResourceFoundListener can be registered via the OcPlatform.findResource call.
899982
* Event listeners are notified asynchronously
900983
*/
901984
public interface OnResourceFoundListener {
902985
public void onResourceFound(OcResource resource);
986+
public void onFindResourceFailed(Throwable ex, String uri);
903987
}
904988

905989
/**

api/src/main/java/org/iotivity/base/OcSecureResource.java

+40
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,46 @@ private native void provisionPairwiseDevices1(int type, int keySize, Object acl1
130130
Object device2, Object acl2,
131131
ProvisionPairwiseDevicesListener provisionPairwiseDevicesListener) throws OcException;
132132

133+
/**
134+
* Method to configure resource for direct pairing
135+
*
136+
* @param pin pin number
137+
* @param pdacls Array of Device Pairing Access Control List
138+
* @param type List of supported OcPrmType
139+
* @param edp enable (1) / disable (0)
140+
* @param ProvisionDirectPairing Callback function, which will be called after completion
141+
* of Direct Pairing.
142+
* @throws OcException
143+
*/
144+
145+
public void doProvisionDirectPairing(String pin, OicSecPdAcl[] pdacls, List<OcPrmType> type,
146+
boolean edp , ProvisionDirectPairingListener provisionDirectPairingListener)
147+
throws OcException {
148+
149+
int[] typeArray = new int[type.size()];
150+
int i = 0;
151+
for (OcPrmType ocPrmType:type) {
152+
typeArray[i++] = ocPrmType.getValue();
153+
}
154+
155+
this.provisionDirectPairing(pin, pdacls, typeArray, (edp?1:0),
156+
provisionDirectPairingListener);
157+
}
158+
159+
private native void provisionDirectPairing(String pin, OicSecPdAcl[] pdacls, int[] type,
160+
int edp , ProvisionDirectPairingListener provisionDirectPairingListener)
161+
throws OcException;
162+
163+
/**
164+
* provisionDirectPairingListener can be registered with doOwnershipTransfer
165+
* call.
166+
* Listener notified asynchronously.
167+
*/
168+
public interface ProvisionDirectPairingListener {
169+
public void provisionDirectPairingListener(List<ProvisionResult> provisionResultList,
170+
int hasError);
171+
}
172+
133173
/**
134174
* doOwnershipTransferListener can be registered with doOwnershipTransfer
135175
* call.

0 commit comments

Comments
 (0)