Commit 85063f40 authored by George Nash's avatar George Nash

Merge 'origin/swig' in 'master'

This merge brings the work done on the swig branch to master.

The swig branch used a tool SWIG (Simple Wrapper and Interface
Generator) to help generate Java/JNI language bindings for the
IoTivity-lite APIs.

This enables writing and running Java applications.

The primary target for this work is for Android app developers.

It is not limited only to Android app developers.  This also
opens up Java development on Windows and Linux platforms.

We have tried really hard to make few changes to the existing C
code base. There are a few modifications to the existing C code.
Most of the time it is a minor white space difference or giving
a name to a typedef struct so the struct can be found by the
swig interface files.

Notable exceptions:
  - logging code updated to log to android logcat when built for
    Android
  - android STORE_PATH_SIZE changed from 64 to 128 to handle the
    longer path names encountered using Android.
  - Updates to android oc_config.h based on testing
  - make files and windows build updated to add ability to
    Generate and build JNI code.
  - Some build warnings resolved on the swig branch that
    probably should have been resolved on master brach.

Another Notable exception to changes to master are the updates
to the root level README.rst file to include instructions for
onboarding and added contact information.

The swig/README.md file is provided to instruct how to build and
use the code added in this commit.

If Android is the primary target a much simpler README is
provided for Android developers that targets only Android. See
port/android/README.md

Change-Id: I273ee181d8b07ff8f2f89d5028fdaae3e280b848
Signed-off-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
parents 0b100dc5 ec911818
port/android/client
port/android/server
port/android/temp_sensor
port/android/simpleclient
port/android/simpleserver
port/android/server_collections_linux
port/android/client_collections_linux
port/android/client_block_linux
port/android/server_block_linux
port/android/smart_home_server_linux
port/android/multi_device_client
port/android/multi_device_server
port/android/onboarding_tool
port/android/server_multithread_linux
port/android/client_multithread_linux
port/android/smart_lock
port/android/libiotivity-lite-client.*
port/android/libiotivity-lite-server.*
port/android/libiotivity-lite-client-server.*
port/android/*.so
port/linux/client
port/linux/server
port/linux/temp_sensor
......
......@@ -145,6 +145,10 @@ apps/*
service/*
contains OCF services
swig/*
contains instructions and code to build Java language bindings using
the SWIG tool.
Setup source tree
-----------------
......@@ -216,3 +220,94 @@ This needs to be present in one of the include paths.
Pre-populated (sample) configurations for the sample applications for all
targets are present in ``port/<OS>/oc_config.h``.
Onboarding and Provisioning
----------------------------
Runing the onboarding tool
~~~~~~~~~~~~~~~~~~~~~~~~~~~
At this time there are three versions of the onboarding tool. The command line C version, the
command line Java version, and the GUI Android version. Both command line versions are identical.
It does not matter which version of the onboarding tool is used.
The C version of the onboarding tool can be found in ``<iotivity-lite>/port/linux`` see Linux build
instructions.
A Java version of the onboarding-tool can be found in
``<iotivity-lite>/swig/apps/java_onboarding_tool``
The following instructions assume the onboarding tool has been built and can run.
Simple Step-by-Step guide for onboarding and provisioning
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This guide assumes you are starting one discoverable device at a time. Multiple devices can be
discovered and onboarded at the same time however it becomes the responsibility of the user to
figure out which UUID belongs to which device.
Once you have successfully onboarded the samples the first time using the following step-by-step
options feel free to RESET the devices and play around with different provisioning options.
The below steps use the command line version of the onboarding tool. The steps for the Android
onboarding tool is very similar but are not described here.
(Step 1) Onboard and Provision the Server
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
There are multiple methods to onboard and provision server and client samples. Below is given one
of the many possible ways the this could be done.
- start the server sample
- start onboarding tool it will print a menu with many option
- Type ``1`` **Enter** to ``Discover un-owned devices``
- Type ``8`` **Enter** to *Take ownership of device*
+ Type ``0`` **Enter**. If you have multiple unowned devices you will have to select the correct
device from the list.
- Type ``4`` **Enter** to ``Discover owned devices`` the device you just took ownership of should be
listed.
- Type ``13`` **Enter** to ``Provision ACE2``. There are many ways to properly provision the device.
This will give instruction for using wildcard provisioning.
+ Type ``0`` **Enter**. If you have multiple unowned devices you will have to select the correct
device from the list.
+ Type ``1`` **Enter** for an ``auth-crypt`` ACE
+ Type ``1`` **Enter** in response to ``Enter number of resources in this ACE:``
+ Type ``0`` **Enter** in response to ``Have resource href? [0-No, 1-Yes]:``
+ Type ``1`` **Enter** in response to ``Set wildcard resource? [0-No, 1-Yes]:``
+ Type ``2`` **Enter** to select the ``All discoverable resources`` option
+ Type ``0`` **Enter** in response to ``Enter number of resource types [0-None]:``
+ Type ``0`` **Enter** in response to ``Enter number of interfaces [0-None]``
+ Type ``0`` **Enter** for CREATE, ``1`` **Enter** for RETRIEVE, ``1`` **Enter** for UPDATE,
``0`` **Enter** for DELETE, and ``1`` **Enter** for NOTIFY.
+ ``Successfully issued request to provision ACE`` should be printed on the screen upon success
(Step 2) Onboard the client
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- start the client sample
- Type ``1`` **Enter** to ``Discover un-owned devices``
- Type ``8`` **Enter** to *Take ownership of device*
+ Type ``0`` **Enter**. If you have multiple unowned devices you will have to select the correct
device from the list.
- Type ``2`` **Enter** to ``Discover owned devices`` the server and client should be listed
(Step 3) Pair Server and Client
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Start the client and server samples
- Type ``12`` **Enter** to ``Provision pair-wise credentials``
- Type ``0`` **Enter** ``1`` **Enter** to pair the client and server. If you have multiple owned
devices you will have to select the correct devices from the list.
(Step 4) Restart and Test
~~~~~~~~~~~~~~~~~~~~~~~~~~
The samples should be onboarded and provisioned. Restart the server and then the client they should
discover each other and run without difficulty.
Send Feedback
-------------------------------------------------
Questions
`IoTivity-Lite Developer Mailing List <https://iotivity-dev@lists.iotivity.org>`_
Bugs
`Jira bug reporting website <https://jira.iotivity.org/projects/LITE>`_
......@@ -28,8 +28,7 @@
#include "oc_cloud.h"
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
typedef struct cloud_conf_update_t
......
......@@ -29,8 +29,7 @@
#include "oc_ri.h"
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/** Resource Directory URI used to Discover RD and Publish resources.*/
......
......@@ -20,6 +20,7 @@
#include "oc_core_res.h"
#include "oc_endpoint.h"
#include "oc_introspection_internal.h"
#include <inttypes.h>
#include <stdio.h>
#ifndef OC_IDD_API
......@@ -43,6 +44,9 @@ gen_idd_tag(const char *name, size_t device_index, char *idd_tag)
void
oc_set_introspection_data(size_t device, uint8_t *IDD, size_t IDD_size)
{
(void) device;
(void) IDD;
(void) IDD_size;
#ifdef OC_SECURITY
char idd_tag[MAX_TAG_LENGTH];
gen_idd_tag("IDD", device, idd_tag);
......
......@@ -17,9 +17,10 @@
#ifndef OC_MNT_INTERNAL_H
#define OC_MNT_INTERNAL_H
#include <stddef.h>
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/**
......
......@@ -18,8 +18,7 @@
#define OC_SESSION_EVENTS_INTERNAL_H
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
void oc_handle_session(oc_endpoint_t *endpoint, oc_session_state_t state);
......
......@@ -560,10 +560,10 @@ static void *
ocf_event_thread(void *data)
{
(void)data;
static const oc_handler_t handler = {.init = app_init,
.signal_event_loop = signal_event_loop,
.register_resources =
register_resources };
static const oc_handler_t handler = { .init = app_init,
.signal_event_loop = signal_event_loop,
.register_resources =
register_resources };
oc_storage_config("./cloud_tests_creds");
......
......@@ -206,7 +206,7 @@ typedef void (*oc_random_pin_cb_t)(const unsigned char *pin, size_t pin_len,
void oc_set_random_pin_callback(oc_random_pin_cb_t cb, void *data);
/**
@brief Returns whether the oic.wk.con res is announed.
@brief Returns whether the oic.wk.con res is announced.
@return true if announced (default) or false if not
@see oc_set_con_res_announced
@see oc_set_con_write_cb
......
......@@ -24,8 +24,7 @@
#include "oc_session_events.h"
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/**
......
......@@ -23,8 +23,7 @@
#include <stdint.h>
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
typedef void (*oc_core_init_platform_cb_t)(void *data);
......@@ -38,7 +37,7 @@ typedef struct oc_platform_info_t
void *data;
} oc_platform_info_t;
typedef struct
typedef struct oc_device_info_t
{
oc_uuid_t di;
oc_uuid_t piid;
......
......@@ -50,8 +50,9 @@
#ifndef OC_INTROSPECTION_H
#define OC_INTROSPECTION_H
#include <stddef.h>
#include <wchar.h>
#include <inttypes.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
......
......@@ -69,7 +69,7 @@ typedef struct oc_separate_response_s oc_separate_response_t;
typedef struct oc_response_buffer_s oc_response_buffer_t;
typedef struct
typedef struct oc_response_t
{
oc_separate_response_t *separate_response;
oc_response_buffer_t *response_buffer;
......@@ -123,7 +123,7 @@ typedef enum {
typedef struct oc_resource_s oc_resource_t;
typedef struct
typedef struct oc_request_t
{
oc_endpoint_t *origin;
oc_resource_t *resource;
......
......@@ -77,7 +77,7 @@ extern bool oc_ri_invoke_coap_entity_handler(
void *request, void *response, oc_blockwise_state_t **request_state,
oc_blockwise_state_t **response_state, uint16_t block2_size,
oc_endpoint_t *endpoint);
#else /* OC_BLOCK_WISE */
#else /* OC_BLOCK_WISE */
extern bool oc_ri_invoke_coap_entity_handler(void *request, void *response,
uint8_t *buffer,
oc_endpoint_t *endpoint);
......@@ -457,7 +457,7 @@ coap_receive(oc_message_t *msg)
if (oc_ri_invoke_coap_entity_handler(message, response, &request_buffer,
&response_buffer, block2_size,
&msg->endpoint)) {
#else /* OC_BLOCK_WISE */
#else /* OC_BLOCK_WISE */
if (oc_ri_invoke_coap_entity_handler(message, response,
transaction->message->data +
COAP_MAX_HEADER_SIZE,
......
......@@ -15,6 +15,25 @@
# It is expected that higher versions then API 24 should work without any
# further modifications.
#
# Download NDK: https://developer.android.com/ndk/downloads/index.html
# Unzip downloaded package.
# Choose architecture and API level.
# cd <NDK>/build/tools
# ./make_standalone_toolchain.py --arch <architecture> --api <level> --install-dir <path>
# For example: ./make_standalone_toolchain.py --arch arm --api 23 --install-dir ~/android-arm-23
# This makefile uses then the NDK in <install-dir>.
# For further setup see: https://developer.android.com/ndk/guides/standalone_toolchain.html
#
# Either set ANDROID_API and ANDROID_BASE in this makefile
# or invoke like this: make NDK_HOME=/opt/android-ndk ANDROID_API=23
#
# Example Usage: make IPV4=1 DEBUG=1
#
# The default JAVA=1 build is recomended for Android builds. Its is possible to
# only build and run native code. There may be write access problems when using
# SECURITY=1 and a native only build. The following instructions are intended
# for native only builds.
#
# Testing compilations on non-rooted Android phones:
# - Enable USB debugging on your phone.
# - Install ADB or Android Studio
......@@ -38,31 +57,21 @@
# (ie. simpleserver will not be discovered). But the clients
# should work.
#
# Download NDK: https://developer.android.com/ndk/downloads/index.html
# Unzip downloaded package.
# Choose architecture and API level.
# cd <NDK>/build/tools
# ./make_standalone_toolchain.py --arch <architecture> --api <level> --install-dir <path>
# For example: ./make_standalone_toolchain.py --arch arm --api 23 --install-dir ~/android-arm-23
# This makefile uses then the NDK in <install-dir>.
# For further setup see: https://developer.android.com/ndk/guides/standalone_toolchain.html
#
# Either set ANDROID_API and ANDROID_BASE in this makefile
# or invoke like this: make NDK_HOME=/opt/android-ndk ANDROID_API=24
# Location of the installation directory and the API level.
ANDROID_API := 23
export OS=android
export ANDROID_API := 23
ifeq (${NDK_HOME},)
ANDROID_BASE := "${HOME}/android-arm-${ANDROID_API}"
export ANDROID_BASE := "${HOME}/android-arm-${ANDROID_API}"
else
ANDROID_BASE := "${NDK_HOME}"
export ANDROID_BASE := "${NDK_HOME}"
endif
# Compiler prefix
ANDROID_HOST := arm-linux-androideabi-
BIN_BASE := ${ANDROID_BASE}/bin/${ANDROID_HOST}
ifeq ($(origin CC),default)
CC := ${BIN_BASE}gcc
export CC := ${BIN_BASE}gcc
endif
ifeq ($(origin AR),default)
AR := ${BIN_BASE}ar
......@@ -71,28 +80,36 @@ RM ?= rm
MKDIR ?= mkdir
DYNAMIC ?= 1
SECURE ?= 1
PKI ?= 1
export SECURE ?= 1
export PKI ?= 1
IPV4 ?= 1
export TCP ?= 1
export CLOUD ?= 1
# unlike other IoTivity-lite builds Android assumes we want to build Java by