Adding spaces around "=" when definining Kconfig template so
that is more consistent with overall style of these template
variables.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
The return of memset is never checked. This patch explicitly ignore
the return to avoid MISRA-C violations.
The only directory excluded directory was ext/* since it contains
only imported code.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
For ease of maintenance, let's swap the reader/writer initialization
syntax to:
.put_begin = put_begin,
.put_end = put_end,
...
This way we only assign used fields and adding new ones later is
less error prone.
Signed-off-by: Michael Scott <mike@foundries.io>
We set "insert" to true when the value is already in the buffer, but
we need to insert a TLV to denote things like RESOURCE_INSTANCE or
OBJECT_INSTANCE. In this case, let's not re-add the value.
Signed-off-by: Michael Scott <mike@foundries.io>
Let's implement put_begin/end_oi functions in the TLV formatter
so to mark the boundry of an object instance when more than 1
object instance is returned.
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/9470
Signed-off-by: Michael Scott <mike@foundries.io>
In order to re-use the put_begin_ri / put_end_ri logic, let's create
generic functions for them: put_begin_tlv and put_end_tlv
Signed-off-by: Michael Scott <mike@foundries.io>
Currently, we only save the resource id of the incoming path setting.
In the future, we will need to change other values in order to process
multi-instance READ operations.
Let's save and restore the entire path only at the beginning and end
of processing.
Signed-off-by: Michael Scott <mike@foundries.io>
Data formatters may need to process data at the beginning and end of
each object instance and/or resource. Currently, they can only add
processing at the beginning and end of resource instances.
Let's establish put_begin/end_oi (object instance) and put_begin/end_r
(resource) API functions that data formatters can use for this purpose.
Signed-off-by: Michael Scott <mike@foundries.io>
Optimize the resource processing loop to avoid extra
assignments before checking if we need to process the
actual resource.
Signed-off-by: Michael Scott <mike@foundries.io>
When reading multiple instances, the base name value should not
include an object instance id. The object instance id is added
to the individual resource name values.
Accomplish this by saving the original path level and adjusting
the (base) name where needed.
Signed-off-by: Michael Scott <mike@foundries.io>
The put_begin / put_end calls are to be used at the very beginning
and end of processing a READ op. Let's correct that logic.
Signed-off-by: Michael Scott <mike@foundries.io>
Now that formatters use their own private data to hold state,
let's remove the old member variables from lwm2m_output_context
which are now unused.
Signed-off-by: Michael Scott <mike@foundries.io>
Data formatters have various private state variables which are
currently located in the output context structure. Let's add
a place where data formatters can store a pointer to their
private data so that as we add more formatters the output
context doesn't get cluttered up.
Signed-off-by: Michael Scott <mike@foundries.io>
The plain-text format only supports READ op for a specific resource.
In all other cases return NOT_ALLOWED.
Signed-off-by: Michael Scott <mike@foundries.io>
Data formatters are becoming too complex for a simple do_read_op()
function to handle all in one place. Also, more data formatters are
going to be added for LwM2M v1.1 support in the future.
In order for data formatters to perform internal setup or deny
invalid requests (specific to the formatter's logic), let's
establish do_read_op_* functions in each formatter.
Once the internal processing is done, they can call back into the
more generic lwm2m_perform_read_op function.
Signed-off-by: Michael Scott <mike@foundries.io>
Let's correct the starting logic in do_read_op() to not assume
a default value of 0 will be present for the first object, when
reading multiple objects.
Signed-off-by: Michael Scott <mike@foundries.io>
The object instance list isn't sorted by object instance id. Let's
simplify this and fix the logic in lwm2m_next_engine_obj_inst() to make
sure that we always get the NEXT object instance by value of
obj_inst_id, not just the next object instance in the list.
NOTE: This change removes the "last" object instance pointer from the
parameters of lwm2m_next_engine_obj_inst(). Some of the logic to return
a NULL value for the end of the list has to be moved back into
do_read_op().
Signed-off-by: Michael Scott <mike@foundries.io>
Remove over-complicated match_type logic in do_read_op(). Replace
MATCH_* checks with actual path->level values.
Signed-off-by: Michael Scott <mike@foundries.io>
When processing an observe request we fail to check whether a
resource has the read permission set. Let's check and if it
doesn't return -EPERM.
NOTE: Also do diligence and return -ENOENT when an object field
cannot be found while looking for the permission.
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/8286
Signed-off-by: Michael Scott <mike@foundries.io>
Due to a change in the company name, the LwM2M copyrights need
to be changed from "Open Source Foundries Limited" ->
"Foundries.io".
Signed-off-by: Michael Scott <mike@foundries.io>
Up until now, Zephyr has patched Kconfig to use the last 'default' with
a satisfied condition, instead of the first one. I'm not sure why the
patch was added (it predates Kconfiglib), but I suspect it's related to
Kconfig.defconfig files.
There are at least three problems with the patch:
1. It's inconsistent with how Kconfig works in other projects, which
might confuse newcomers.
2. Due to oversights, earlier 'range' properties are still preferred,
as well as earlier 'default' properties on choices.
In addition to being inconsistent, this makes it impossible to
override 'range' properties and choice 'default' properties if the
base definition of the symbol/choice already has 'range'/'default'
properties.
I've seen errors caused by the inconsistency, and I suspect there
are more.
3. A fork of Kconfiglib that adds the patch needs to be maintained.
Get rid of the patch and go back to standard Kconfig behavior, as
follows:
1. Include the Kconfig.defconfig files first instead of last in
Kconfig.zephyr.
2. Include boards/Kconfig and arch/<arch>/Kconfig first instead of
last in arch/Kconfig.
3. Include arch/<arch>/soc/*/Kconfig first instead of last in
arch/<arch>/Kconfig.
4. Swap a few other 'source's to preserve behavior for some scattered
symbols with multiple definitions.
Swap 'source's in some no-op cases too, where it might match the
intent.
5. Reverse the defaults on symbol definitions that have more than one
default.
Skip defaults that are mutually exclusive, e.g. where each default
has an 'if <some board>' condition. They are already safe.
6. Remove the prefer-later-defaults patch from Kconfiglib.
Testing was done with a Python script that lists all Kconfig
symbols/choices with multiple defaults, along with a whitelist of fixed
symbols. The script also verifies that there are no "unreachable"
defaults hidden by defaults without conditions
As an additional test, zephyr/.config was generated before and after the
change for several samples and checked to be identical (after sorting).
This commit includes some default-related cleanups as well:
- Simplify some symbol definitions, e.g. where a default has 'if FOO'
when the symbol already has 'depends on FOO'.
- Remove some redundant 'default ""' for string symbols. This is the
implicit default.
Piggyback fixes for swapped ranges on BT_L2CAP_RX_MTU and
BT_L2CAP_TX_MTU (caused by confusing inconsistency).
Piggyback some fixes for style nits too, e.g. unindented help texts.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
The LwM2M engine will cleanup the net_app_ctx if there are
errors during initialization. The clean up calls here in
RD client are duplicated.
Signed-off-by: Michael Scott <mike@foundries.io>
During transfer of object data via OMA TLV format, we can
encounter resources which are optional or not handled in base
LwM2M engine. When these resources cannot be handled let's
read past them and continue on.
Signed-off-by: Michael Scott <mike@foundries.io>
Don't use hard-coded value of 4 for passing the # of options to
coap_find_options() in handle_request(). This can easily get
out of sync.
Signed-off-by: Michael Scott <mike@foundries.io>
LwM2M engine now supports optional resources that may need to be
setup or torn down in user-based code during object instance
creation / deletion.
Let's provide callbacks that can be used for this purpose.
Signed-off-by: Michael Scott <mike@foundries.io>
Let's rename lwm2m_engine_exec_cb_t to lwm2m_engine_user_cb_t so that
future user-code callbacks can make use of the same definition.
Signed-off-by: Michael Scott <mike@foundries.io>
Bool symbols implicitly default to 'n'.
A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.
Remove some 'default ""' properties on string symbols too.
Also make definitions more consistent by converting some
config FOO
<type>
prompt "foo"
definitions to a shorter form:
config FOO
<type> "foo"
This shorthand works for int/hex/string symbols too, not just for bool
symbols.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
If we use newlib the isdigit (and other similar functions) return an
error as char can possibly be viewed as signed:
usr/include/ctype.h:57:54: error: array subscript has type ‘char’ [-Werror=char-subscripts]
#define __ctype_lookup(__c) ((__ctype_ptr__+sizeof(""[__c]))[(int)(__c)])
Explicity cast to unsigned char so we deal with both this warning and
possible warning when -Wpointer-sign is enabled.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
When the priority of the LwM2M engine was lowered, it causes an
occasional registration update to fall outside of the registration
lifetime. This shows up as the following error:
Failed with code 4.4. Retrying registration
Let's try and retry a bit earlier to account for the priority
change.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
The ARRAY_SIZE() utility macro will actually test the parameter types,
and ensure that it is only called with arrays, and not arrays decayed
to pointers.
Changes were performed with a simple Coccinelle script.
Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
A typo in update_attrs() was setting every observer to a PMIN of 0.
This meant we could send observer data as often as the process was
called. This is out of spec as the default minimum is 10 seconds.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
The LwM2M engine thread is used for various periodic triggers.
None of these are in a critical path that requires super sensitive
timing and the current K_PRIO_COOP(7) setting was causing the
Bluetooth RX thread to have to wait too long for certain actions
to complete.
Let's lower the priority to -1 (effectively) to eliminate these
conflicts.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
During normal use, a CoAP packet can be resent due to network congestion
and other causes. During block transfer the LwM2M client checks to make
sure the block received is the one we expect and if not generates a
"duplicate" warning. When this happened, we were releasing the reply
handler and when the correct block was received the client would
generate a "No handler" error.
To avoid releasing the reply handler too early, let's set the coap_reply
"user_data" field to an error condition (1). Then, once the reply
processing is complete we can check the user_data field to be sure that
it's ok to release the reply handler.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
The next error check is much more suitable to handle the error due to
the error message which lets the user know that something went wrong.
Fixes#7661.
Signed-off-by: Daniel Egger <daniel@eggers-club.de>
When designing the registration client for LwM2M, I understood
that the LwM2M Technical Specification allows for a multi-server
connection setup where the client makes several connections
to various LwM2M servers and allows each of them to manage
various aspects of the LwM2M client based on Access Controls.
However, the way I implemented it was not well thought out and
as we look forward to adding Bootstrap support, it needs a
do over.
Let's remove all of the code dedicated to handling multiple LwM2M
client connections. This will simplify and reduce the code size
of the registration client considerably.
Later, once Bootstrap support has been added, we can implement
multi-server connections in a cleaner manner.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
This allows a user to customize the port used for downloading
firmware via the pull method of the LwM2M client. It's default
value of 0 will select a random port during initialization.
NOTE: If set, this value should not be the same port as the
LWM2M_LOCAL_PORT setting.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Due to a bug where LWM2M_LOCAL_PORT was not being honored, all
outgoing traffic from the LwM2M client was coming from a random
port determined during initialization.
Now that this bug bas been fixed, let's default the client to the
behavior that most users are expecting, and let new users customize
the outgoing port if needed (which should be rarely).
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Currently, CONFIG_LWM2M_LOCAL_PORT is never used when setting up
the LwM2M client. Let's set the port of the local address using
CONFIG_LWM2M_LOCAL_PORT, so that the client can bind to it.
NOTE: A setting of 0 will use a random port.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Using IPSO Smart Object Guideline: "Smart Objects Starter Pack 1.0"
dated May 27, 2017, let's mark the OPTIONAL resources for an
IPSO Temperature object (Section 10. "IPSO Object: Temperature").
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Using IPSO Smart Object Guideline: "Smart Objects Starter Pack 1.0"
dated May 27, 2017, let's mark the OPTIONAL resources for an
IPSO Light Control object (Section 16. "IPSO Object: Light Control")
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Using OMA Technical Specification LwM2M Enabler 1.0.2 dated
Feb. 9, 2018, let's mark the OPTIONAL resources for an LwM2M
Firmware Update object (Section E.6 "LwM2M Object: Firmware
Update")
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
Using OMA Technical Specification LwM2M Enabler 1.0.2 dated
Feb. 9, 2018, let's mark the OPTIONAL resources for an LwM2M
Device object (Section E.4 "LwM2M Object: Device")
As a result, the Device object no longer configures the default
buffers for data storage of several optional resources.
The LwM2M client sample is also changed to to setup these read-only
buffers instead.
Signed-off-by: Michael Scott <michael@opensourcefoundries.com>