Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error fixes and some feature enhancement from mbed-client #2632

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions features/FEATURE_CLIENT/mbed-client-classic/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Change Log

## mbed-os-5.1.4-rc1
[Full Changelog](https://github.com/ARMmbed/mbed-client-classic/compare/e35a2aeb46bf31bfc53a4379441c0eaab72bd902...586e697365999fc7d976afc8360e26e068f264ae)

**Closed issues:**

- IOTCLT-966 - Mbed-cloud-client-example dead after running over night (possible memory leak)

**Merged pull requests:**

commit 586e697365999fc7d976afc8360e26e068f264ae (HEAD, tag: mbed-os-5.1.4-rc1, origin/master, origin/HEAD, master)
Merge: e35a2ae 8e0b173
Author: Yogesh Pande <yogpan01@users.noreply.github.com>
Date: Tue Sep 6 18:54:56 2016 +0300

Merge pull request #36 from ARMmbed/socket-callback-task-identifier

Socket callback cleanup and change task identifier usage

commit 8e0b17320e0f3014e3e5af1b966639dfa5077ca5
Author: Jaakko Kukkohovi <jaakko.kukkohovi@arm.com>
Date: Fri Sep 2 17:16:31 2016 +0300

Socket callback cleanup and change task identifier usage

Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,21 @@ static MemoryPool<M2MConnectionHandlerPimpl::TaskIdentifier, MBED_CLIENT_EVENT_L
extern "C" void connection_tasklet_event_handler(arm_event_s *event)
{
tr_debug("M2MConnectionHandlerPimpl::connection_tasklet_event_handler");
M2MConnectionHandlerPimpl::TaskIdentifier *task_id = (M2MConnectionHandlerPimpl::TaskIdentifier*)event->data_ptr;
M2MConnectionHandlerPimpl* pimpl = (M2MConnectionHandlerPimpl*)task_id->pimpl;
M2MConnectionHandlerPimpl* pimpl = NULL;
M2MConnectionHandlerPimpl::TaskIdentifier *task_id = NULL;

if (event->event_type == M2MConnectionHandlerPimpl::ESocketSend) {
task_id = (M2MConnectionHandlerPimpl::TaskIdentifier*)event->data_ptr;
pimpl = (M2MConnectionHandlerPimpl*)(task_id->pimpl);
}
else {
pimpl = (M2MConnectionHandlerPimpl*)event->data_ptr;
}

if(pimpl) {
eventOS_scheduler_set_active_tasklet(pimpl->connection_tasklet_handler());
}

switch (event->event_type) {
case M2MConnectionHandlerPimpl::ESocketIdle:
tr_debug("Connection Tasklet Generated");
Expand All @@ -71,7 +81,7 @@ extern "C" void connection_tasklet_event_handler(arm_event_s *event)
break;
case M2MConnectionHandlerPimpl::ESocketSend:
tr_debug("connection_tasklet_event_handler - ESocketSend");
if(pimpl) {
if(pimpl && task_id) {
pimpl->send_socket_data((uint8_t*)task_id->data_ptr,(uint16_t)event->event_data);
if (task_id->data_ptr) {
free(task_id->data_ptr);
Expand All @@ -81,6 +91,8 @@ extern "C" void connection_tasklet_event_handler(arm_event_s *event)
default:
break;
}

// Free the task identifier if we had it
if (task_id) {
memory_pool.free(task_id);
}
Expand Down Expand Up @@ -157,17 +169,12 @@ bool M2MConnectionHandlerPimpl::resolve_server_address(const String& server_addr
_server_port = server_port;
_server_type = server_type;
_server_address = server_address;
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
return false;
}
task->pimpl = this;

arm_event_s event;
event.receiver = M2MConnectionHandlerPimpl::_tasklet_id;
event.sender = 0;
event.event_type = ESocketDnsHandler;
event.data_ptr = task;
event.data_ptr = this;
event.priority = ARM_LIB_HIGH_PRIORITY_EVENT;
return eventOS_event_send(&event) == 0 ? true : false;
}
Expand Down Expand Up @@ -280,7 +287,14 @@ bool M2MConnectionHandlerPimpl::send_data(uint8_t *data,
event.event_data = data_len;
event.priority = ARM_LIB_HIGH_PRIORITY_EVENT;

return eventOS_event_send(&event) == 0 ? true : false;
if (eventOS_event_send(&event) == 0) {
return true;
}

// Event push failed, free task identifier and buffer
free(buffer);
memory_pool.free(task);
return false;
}

void M2MConnectionHandlerPimpl::send_socket_data(uint8_t *data,
Expand Down Expand Up @@ -326,23 +340,13 @@ int8_t M2MConnectionHandlerPimpl::connection_tasklet_handler()

void M2MConnectionHandlerPimpl::socket_event()
{
TaskIdentifier* task = memory_pool.alloc();
if (!task) {
_observer.socket_error(M2MConnectionHandler::SOCKET_READ_ERROR, true);
return;
}
task->pimpl = this;

arm_event_s event;
event.receiver = M2MConnectionHandlerPimpl::_tasklet_id;
event.sender = 0;
event.event_type = ESocketReadytoRead;
event.data_ptr = task;
event.data_ptr = this;
event.priority = ARM_LIB_HIGH_PRIORITY_EVENT;
int8_t error = eventOS_event_send(&event);
if(error != 0) {
_observer.socket_error(M2MConnectionHandler::SOCKET_READ_ERROR, true);
}
eventOS_event_send(&event);
}

bool M2MConnectionHandlerPimpl::start_listening_for_data()
Expand Down
99 changes: 99 additions & 0 deletions features/FEATURE_CLIENT/mbed-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Change Log

## [v1.15.1](https://github.com/ARMmbed/mbed-client/releases/tag/v1.15.1) (07-Sep-2016)
[Full Changelog](https://github.com/ARMmbed/mbed-client/compare/v1.13.4...v1.15.1)

** New feature **

- Introduce new API's to handle block-wise messages in application level

**Closed issues:**

- IOTCLT-1001 - mDS does not sent RST anymore for Client after DELETE /subscriptions

**Merged pull requests:**

commit ae89da57afcafb68d02e1e591db0bc2c9b03d5bd (HEAD, tag: v1.15.1, origin/master, origin/HEAD, master)
Author: Antti Yli-Tokola <antti.yli-tokola@arm.com>
Date: Wed Sep 7 17:58:16 2016 +0300

version v1.15.1

commit 7bf71c457443b7806137d128da66b4c3c5f0333a
Merge: ce709e0 6d07835
Author: Antti Yli-Tokola <antti.yli-tokola@arm.com>
Date: Wed Sep 7 17:55:51 2016 +0300

Merge pull request #280 from ARMmbed/post_req_fix

Fix post request handling in object and object instance level

commit 6d078357fb5fc16f7328d11dc98c2290091f2199
Author: Antti Yli-Tokola <antti.yli-tokola@arm.com>
Date: Wed Sep 7 14:42:57 2016 +0300

Fix post request handling in object and object instance level

commit ce709e08039407ee69ce1f638543652261742439 (HEAD, tag: v1.15.0, origin/master, origin/HEAD, master)
Author: Teemu Takaluoma <teemu.takaluoma@arm.com>
Date: Tue Sep 6 18:52:15 2016 +0300

version v1.15.0

commit a2158dd9abf35fe98ef675ebfb77cd77b5a13747
Merge: 783678e c4bf82c
Author: Teemu Takaluoma <teemu.takaluoma@arm.com>
Date: Tue Sep 6 18:51:42 2016 +0300

Merge pull request #278 from ARMmbed/IOTCLT-1001

implement platform agnostic IP handling, Fix IOTCLT-1001

commit c4bf82cc792c9e5f5bc2ddcfc062234c31d586d9
Author: Teemu Takaluoma <teemu.takaluoma@arm.com>
Date: Tue Sep 6 18:17:22 2016 +0300

update doxygen in header

commit d4c802be2e43fe60e19b416917d60e7bf4ae7375
Author: Teemu Takaluoma <teemu.takaluoma@arm.com>
Date: Mon Sep 5 19:34:28 2016 +0300

fix unittests

commit 0cb20925e00ac4641e7b40c08c9798133d6c0755
Author: Teemu Takaluoma <teemu.takaluoma@arm.com>
Date: Sat Sep 3 14:20:46 2016 +0300

remove unnessary assignments

commit 0d7f1080aa2f9c236f9740d6fcbd7e34d8cc9ed7
Author: Teemu Takaluoma <teemu.takaluoma@arm.com>
Date: Sat Sep 3 13:56:43 2016 +0300

Fix for IOTCLT-1001, implement platform agnostic IP handling

commit 783678ef926a4e52609b3f7e67eedcf60ff05161
Author: Antti Yli-Tokola <antti.yli-tokola@arm.com>
Date: Tue Sep 6 15:26:36 2016 +0300

Update documentation to cover external block-wise message storing (#274)

* Update documentation to cover external block-wise message storing

commit 98bb9cf8652d9fa3f7882d5c3d5e15c21a1e55a9 (tag: v1.14.0)
Author: Antti Yli-Tokola <antti.yli-tokola@arm.com>
Date: Tue Sep 6 09:19:08 2016 +0300

version v1.14.0

commit 32cd77e498dda4cb54688fbab6032634a2ee909c
Author: Antti Yli-Tokola <antti.yli-tokola@arm.com>
Date: Tue Sep 6 09:05:31 2016 +0300

Introduce new API's to handle block-wise messages in application level (#272)

* Introduce new API's in resource level.
* set_incoming_block_message_callback(), used when application wants to store block-wise messages in their own memory
* set_outgoing_block_message_callback, used to read block wise message data from application memory

59 changes: 59 additions & 0 deletions features/FEATURE_CLIENT/mbed-client/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# Makefile for mbed Client C++ Library
#
# List of subdirectories to build
TEST_FOLDER := ./test/

# Define compiler toolchain with CC or PLATFORM variables
# Example (GCC toolchains, default $CC and $AR are used)
# make
#
# OR (Cross-compile GCC toolchain)
# make PLATFORM=arm-linux-gnueabi-
#
# OR (ArmCC/Keil)
# make CC=ArmCC AR=ArmAR
#
# OR (IAR-ARM)
# make CC=iccarm

LIB = libmbedclient.a

# List of unit test directories for libraries
UNITTESTS := $(sort $(dir $(wildcard $(TEST_FOLDER)*/utest/*)))

# If configuration is not specified, use linux
ifeq (,$(CONFIG))
CONFIG := linux
endif

include sources.mk
include include_dirs.mk
include config/$(CONFIG).mk

SERVLIB_DIR := ../../libService
NSDL_C_DIR := ../../nsdl-c
override CFLAGS += -I$(SERVLIB_DIR)/libService
override CFLAGS += -I$(NSDL_C_DIR)/nsdl-c
override CFLAGS += $(addprefix -I,$(INCLUDE_DIRS))
override CFLAGS += $(addprefix -D,$(FLAGS))
ifeq ($(DEBUG),1)
override CFLAGS += -DHAVE_DEBUG
endif

COVERAGEFILE := ./lcov/coverage.info

#
# Define compiler toolchain
#
include ../../libService/toolchain_rules.mk

$(eval $(call generate_rules,$(LIB),$(SRCS)))

# Extend default clean rule
clean: clean-extra

$(CLEANDIRS):
@make -C $(@:clean-%=%) clean

clean-extra: $(CLEANDIRS)
45 changes: 44 additions & 1 deletion features/FEATURE_CLIENT/mbed-client/docs/Howto.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,47 @@ static void c_style_function(void *) {
}
resource->set_execute_function(&c_style_function);
```
There are additional APIs that provide getter and remove functions for Resource and Resource Instances in the `M2MResource` and `M2MResourceInstance` classes. Check [the API documentation](https://docs.mbed.com/docs/mbed-client-guide/en/latest/api/annotated.html) for their usage.
There are additional APIs that provide getter and remove functions for Resource and Resource Instances in the `M2MResource` and `M2MResourceInstance` classes. Check [the API documentation](https://docs.mbed.com/docs/mbed-client-guide/en/latest/api/annotated.html) for their usage.

##### Setting an external handler for block-wise messages

For dynamic Resources, you can pass a function pointer to the Resource Instance. It will be executed when mbed Device Server calls a `PUT` method on that resource with large payload using block-wise operation. The Resource must support the `PUT` operation mode for this feature to work. If the callback is set, the application will be notified for every incoming block-wise message and the message is not stored in mbed Client side anymore. In such case, it is application's responsibility to store each block-wise message and combine them when the last block has arrived.

<span class="notes">**Note:** Due to a limitation in the mbed-client-c library, GET request can only contain data up to 65KB.</span>

To pass the function pointer for an incoming block-wise message:

```
virtual void set_incoming_block_message_callback(incoming_block_message_callback callback);
void block_message_received(M2MBlockMessage *argument) {
// Code
}
resource->set_incoming_block_message_callback(incoming_block_message_callback(this, &block_message_received));
```

To pass the function pointer for an outgoing block-wise message:

```
virtual void set_outgoing_block_message_callback(outgoing_block_message_callback callback);
void block_message_requested(const String& resource, uint8_t *&data, uint32_t &len) {
// Code
}
resource->set_outgoing_block_message_callback(outgoing_block_message_callback(this, &block_message_requested));
```

Applications can define their own maximum incoming message size in bytes at build time. For mbed OS, create a `mbed_app.json` file in the application level and overwrite the value as described below:

```
"target_overrides": {
"*": {
"mbed-client.sn-coap-max-incoming-message-size": 100000
}

```
For yotta based builds, you need to create a `config.json` file in the application level:

```
{
"coap_max_incoming_block_message_size": 100000
}
```
6 changes: 3 additions & 3 deletions features/FEATURE_CLIENT/mbed-client/docs/Introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ _interface->set_entropy_callback(ent_cb);

The maximum single UDP message size that mbed Client can receive is 1152 bytes. The actual payload size is 1137 bytes, the header information using the remaining 15 bytes.

For transferring larger amounts of data, the Blockwise feature must be deployed. When using this feature, mbed Client can handle messages up to 64KB. This feature is disabled by default.
For transferring larger amounts of data, the Blockwise feature must be deployed. When using this feature, mbed Client can handle messages up to 65KB by default. This feature is disabled by default. To receive more than 65KB, see [Setting an external handler for block-wise messages](Howto.md#setting-an-external-handler-for-block-wise-messages).

For mbed OS, to enable Blockwise feature , create a `mbed_app.json` file in the application level and overwrite Blockwise value as described below:
To enable the Blockwise feature in mbed OS, create a `mbed_app.json` file in the application level and overwrite Blockwise value as described below:

*Example:*
```
Expand All @@ -112,7 +112,7 @@ For mbed OS, to enable Blockwise feature , create a `mbed_app.json` file in the

```

For yotta based builds, to enable the Blockwise feature, you need to create a `config.json` file in the application level.
To enable the Blockwise feature in yotta based builds, you need to create a `config.json` file in the application level.

*Example:*
```
Expand Down
Loading