Skip to content

Commit

Permalink
Add Push Notification support (CR2483)
Browse files Browse the repository at this point in the history
  • Loading branch information
Joo-Chul Kevin Lee authored and Danielius1922 committed Sep 17, 2022
1 parent c76304e commit fdfccf9
Show file tree
Hide file tree
Showing 46 changed files with 4,514 additions and 168 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/CLA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
issue_comment:
types: [created]
pull_request_target:
types: [opened,closed,synchronize]
types: [opened, closed, synchronize]

jobs:
CLAssistant:
Expand All @@ -16,15 +16,15 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
PERSONAL_ACCESS_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }}
PERSONAL_ACCESS_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
with:
path-to-signatures: 'signatures/version1/cla.json'
path-to-signatures: "signatures/version1/cla.json"
#path-to-document: 'https://github.com/cla-assistant/github-action/blob/master/SAPCLA.md' # e.g. a CLA or a DCO document
path-to-document: 'https://github.com/iotivity/iotivity-lite/blob/master/LICENSE.md' # branch should not be protected
branch: 'main'
path-to-document: "https://github.com/iotivity/iotivity-lite/blob/master/LICENSE.md" # branch should not be protected
branch: "main"
allowlist: user1,bot*

#below are the optional inputs - If the optional inputs are not given, then default values will be taken
#below are the optional inputs - If the optional inputs are not given, then default values will be taken
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
#remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
#create-file-commit-message: 'For example: Creating file for storing CLA Signatures'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ name: CI building android
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
make_android:
make_android:
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/check-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ name: Check formatting
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "check-formatting"
# This workflow contains a single job called "check-formatting"
check-formatting:
# The type of runner that the job will run on
runs-on: ubuntu-latest
Expand All @@ -39,4 +39,3 @@ jobs:
cmake ../.
make format
git diff --exit-code --ignore-submodules=all
2 changes: 2 additions & 0 deletions .github/workflows/cmake-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
- args: "-DOC_SECURITY_ENABLED=OFF -DOC_TCP_ENABLED=ON"
# secure off, ipv4 on, tcp on
- args: "-DOC_SECURITY_ENABLED=OFF -DOC_TCP_ENABLED=ON -DOC_IPV4_ENABLED=ON"
# collection create if on, push notification on, tcp off
- args: "-DOC_COLLECTIONS_IF_CREATE_ENABLED=ON -DOC_PUSH_ENABLED=ON"

steps:
- name: Checkout repository
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ctt-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
issue-number: ${{ github.event.pull_request.number }}
body: |
:tada: Thank you for your code contribution! To guarantee the change/addition is conformant to the [OCF Specification](https://openconnectivity.org), we would like to ask you to execute OCF Conformance Testing of your change :point_up: **when your work is ready to be reviewed**.
---
:information_source: To verify your latest change (${{ github.event.pull_request.head.sha }}), label this PR with `OCF Conformance Testing`.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/doxygen-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI-doxygen-publish

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]
types: [closed]

# Allows you to run this workflow manually from the Actions tab
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/doxygen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: doxygen documentation

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -25,4 +25,3 @@ jobs:
doxygen --version
cd ${{ github.workspace }}/iotivity-lite/tools
./build_doc.sh
2 changes: 1 addition & 1 deletion .github/workflows/sonar-cloud-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
mkdir build && cd build
# sonar-scanner currently cannot handle multi configuration configuration (ie. compilation of the same file with different defines),
# so we enable as many features as possible so we get max. amount of code analysis
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON -DOC_CLOUD_ENABLED=ON -DOC_COLLECTIONS_IF_CREATE_ENABLED=ON -DOC_MNT_ENABLED=ON -DOC_WKCORE_ENABLED=ON -DOC_SOFTWARE_UPDATE_ENABLED=ON -DBUILD_TESTING=ON ..
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_VERBOSE_MAKEFILE=ON -DOC_CLOUD_ENABLED=ON -DOC_COLLECTIONS_IF_CREATE_ENABLED=ON -DOC_MNT_ENABLED=ON -DOC_WKCORE_ENABLED=ON -DOC_SOFTWARE_UPDATE_ENABLED=ON -DOC_PUSH_ENABLED=ON -DBUILD_TESTING=ON ..
cd ..
# for files defined in multiple cmake targets, sonar-scanner seems to take the configuration from the first compilation of the file,
# so we force client-server target to be compiled first so we get analysis of code with both OC_CLIENT and OC_SERVER enabled
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ jobs:
- name: Build with clang-tidy
run: |
mkdir linuxbuild && cd linuxbuild
cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DOC_CLANG_TIDY_ENABLED=ON -DOC_CLOUD_ENABLED=ON -DOC_COLLECTIONS_IF_CREATE_ENABLED=ON -DOC_MNT_ENABLED=ON -DOC_WKCORE_ENABLED=ON -DOC_SOFTWARE_UPDATE_ENABLED=ON -DBUILD_TESTING=OFF ..
cmake -DCMAKE_VERBOSE_MAKEFILE=ON -DOC_CLANG_TIDY_ENABLED=ON -DOC_CLOUD_ENABLED=ON -DOC_COLLECTIONS_IF_CREATE_ENABLED=ON -DOC_MNT_ENABLED=ON -DOC_WKCORE_ENABLED=ON -DOC_SOFTWARE_UPDATE_ENABLED=ON -DOC_PUSH_ENABLED=ON -DBUILD_TESTING=OFF ..
make all
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,7 @@ service/resource-directory/client/unittest/obj
build

python/plgd_headers.config

# eclipse config file
.cproject
.project
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ set(OC_WKCORE_ENABLED OFF CACHE BOOL "Enable well-known core resource.")
set(OC_OSCORE_ENABLED ON CACHE BOOL "Enable oscore support.")
set(OC_IPV4_ENABLED OFF CACHE BOOL "Enable IPv4 support.")
set(OC_DNS_LOOKUP_IPV6_ENABLED OFF CACHE BOOL "Enable IPv6 DNS lookup.")
set(OC_PUSH_ENABLED OFF CACHE BOOL "Enable Push Notification.")
set(OC_PUSHDEBUG_ENABLED OFF CACHE BOOL "Enable debug messages for Push Notification.")

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -88,6 +90,14 @@ set(PRIVATE_COMPILE_DEFINITIONS "")
set(PUBLIC_COMPILE_DEFINITIONS "")
set(MBEDTLS_COMPILE_DEFINITIONS "__OC_PLATFORM" "__OC_RANDOM")

if(OC_PUSH_ENABLED)
list(APPEND PUBLIC_COMPILE_DEFINITIONS "OC_PUSH")
if(OC_PUSHDEBUG_ENABLED)
list(APPEND PUBLIC_COMPILE_DEFINITIONS "OC_PUSHDEBUG")
endif()
set(OC_DYNAMIC_ALLOCATION_ENABLED ON)
set(OC_COLLECTIONS_IF_CREATE_ENABLED ON)
endif()
if(OC_DYNAMIC_ALLOCATION_ENABLED)
list(APPEND PUBLIC_COMPILE_DEFINITIONS "OC_DYNAMIC_ALLOCATION")
list(APPEND MBEDTLS_COMPILE_DEFINITIONS "OC_DYNAMIC_ALLOCATION")
Expand Down Expand Up @@ -162,6 +172,8 @@ if(OC_DNS_LOOKUP_IPV6_ENABLED)
list(APPEND TEST_COMPILE_DEFINITIONS "OC_DNS_LOOKUP_IPV6")
endif()



if(BUILD_TESTING)
list(APPEND PRIVATE_COMPILE_DEFINITIONS "OC_TEST")
endif()
Expand Down
12 changes: 12 additions & 0 deletions api/oc_core_res.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// limitations under the License.
*/

#include "util/oc_features.h"
#include "oc_core_res.h"
#include "api/cloud/oc_cloud_internal.h"
#include "oc_api.h"
Expand Down Expand Up @@ -51,6 +52,12 @@ static bool announce_con_res = false;
static int res_latency = 0;
static OC_ATOMIC_UINT32_T g_device_count = 0;

/*todo4me <2022/9/5> remove later*/
#ifdef OC_HAS_FEATURE_PUSH
void oc_create_pushconf_resource(size_t device_index);
void oc_create_pushreceiver_resource(size_t device_index);
#endif

/* Although used several times in the OCF spec, "/oic/con" is not
accepted by the spec. Use a private prefix instead.
Update OC_NAMELEN_CON_RES if changing the value.
Expand Down Expand Up @@ -422,6 +429,11 @@ oc_core_add_new_device(const char *uri, const char *rt, const char *name,
oc_create_cloudconf_resource(device_count);
#endif /* OC_CLIENT && OC_SERVER && OC_CLOUD */

#ifdef OC_HAS_FEATURE_PUSH
oc_create_pushconf_resource(device_count);
oc_create_pushreceiver_resource(device_count);
#endif

oc_device_info[device_count].data = data;

if (oc_connectivity_init(device_count) < 0) {
Expand Down
4 changes: 4 additions & 0 deletions api/oc_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ typedef enum {
SW_UPDATE_UPGRADING,
SW_UPDATE_DONE,
#endif /* OC_SOFTWARE_UPDATE */

#ifdef OC_HAS_FEATURE_PUSH
PUSH_RSC_STATE_CHANGED,
#endif /* OC_HAS_FEATURE_PUSH */
__NUM_OC_EVENT_TYPES__
} oc_events_t;

Expand Down
7 changes: 7 additions & 0 deletions api/oc_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ _oc_free_string(
}
}

void
oc_set_string(oc_string_t *ocstring, const char *str, size_t str_len)
{
oc_free_string(ocstring);
oc_new_string(ocstring, str, str_len);
}

void
oc_concat_strings(oc_string_t *concat, const char *str1, const char *str2)
{
Expand Down
10 changes: 9 additions & 1 deletion api/oc_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ static bool *drop_commands;
static bool drop_commands[OC_MAX_NUM_DEVICES];
#endif /* !OC_DYNAMIC_ALLOCATION */

#ifdef OC_HAS_FEATURE_PUSH
void oc_push_free();
#endif

static bool initialized = false;
static const oc_handler_t *app_callbacks;
static oc_factory_presets_t factory_presets;
Expand Down Expand Up @@ -374,6 +378,10 @@ oc_main_shutdown(void)
oc_collections_free_rt_factories();
#endif /* OC_COLLECTIONS && OC_SERVER && OC_COLLECTIONS_IF_CREATE */

#ifdef OC_HAS_FEATURE_PUSH
oc_push_free();
#endif

oc_ri_shutdown();

#ifdef OC_SECURITY
Expand Down Expand Up @@ -434,4 +442,4 @@ bool
oc_drop_command(size_t device)
{
return drop_commands[device];
}
}
Loading

0 comments on commit fdfccf9

Please sign in to comment.