Token is missing when we jump to the error and token is not yet setup.
To correct it, we grab the token from the input packet at the beginning
of the handle_request()
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
Copy/paste error was checking minimum measurements where it
should have been checking maximum measurements.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Initial values for the min/max measurements were 0 and this caused
issues with sensors maximums that weren't above 0 and minimums that
went below 0. Let's update those to MAX_INT so the first sensor
value update will set those to correct values.
When resetting the measured values, let's use the current sensor
value not 0.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Introducing CMake is an important step in a larger effort to make
Zephyr easy to use for application developers working on different
platforms with different development environment needs.
Simplified, this change retains Kconfig as-is, and replaces all
Makefiles with CMakeLists.txt. The DSL-like Make language that KBuild
offers is replaced by a set of CMake extentions. These extentions have
either provided simple one-to-one translations of KBuild features or
introduced new concepts that replace KBuild concepts.
This is a breaking change for existing test infrastructure and build
scripts that are maintained out-of-tree. But for FW itself, no porting
should be necessary.
For users that just want to continue their work with minimal
disruption the following should suffice:
Install CMake 3.8.2+
Port any out-of-tree Makefiles to CMake.
Learn the absolute minimum about the new command line interface:
$ cd samples/hello_world
$ mkdir build && cd build
$ cmake -DBOARD=nrf52_pca10040 ..
$ cd build
$ make
PR: zephyrproject-rtos#4692
docs: http://docs.zephyrproject.org/getting_started/getting_started.html
Signed-off-by: Sebastian Boe <sebastian.boe@nordicsemi.no>
Update the firmware update_result accordingly by checking return
value of the firmware data write callback registered by application.
Also, set response code according.
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
We should call coap_update_from_block() which will determine the minimum
size of the BLOCK1 SIZE between server/client and update the current
offset and total size(if available) accordingly.
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
Now that objects and samples have their return values fixed, let's
propagate them back up to the user if there's an error.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Previously, post_write and execute callbacks returned 1 when handled
and 0 for error condition. However, this wasn't detailed enough and
the engine can't propagate any sort of error back to users -- so it
doesn't even check the return values in many cases!
Let's adjust the resource callback functions of all objects and the
lwm2m_client sample to return 0 for success or a valid error code.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Now that we can access resource data in the lwm2m subsys, let's use
the user provided firmware push buffer (5/0/0) to also store the
firmware pull data.
This way the size of the firmware pull buffer is completely up to the
application.
NOTE: This patch adds a 64 byte firmware buffer to the lwm2m_client
sample for this purpose.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
With the change to support multi-fragement buffers in the LwM2M subsys,
the OPAQUE data type was direct write methods were broken.
Let's fix OPAQUE handling by using the newly introduced getter methods
which can use multiple user callbacks (depending on the size of the
user provided buffer). Let's also add public methods for users to set
/ get OPAQUE data in resources for future use with DTLS key data.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
The lwm2m_engine_get_resource() function needs to be made available to
other portions of the lwm2m subsys in order for firmware resource data
to be used in the future.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
During conversion from the ZoAP to CoAP APIs the use for this variable
was removed, but the variable itself was left in place.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
No need for 2 different defines to specify URI lengths in the source
for firmware pull method. Let's combine them.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Each content formatter should have a way of handling opaque data.
For instance TLV data will individually be able to specify a length
but plain text will take up the rest of the packet.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
The existing LwM2M framework expected contiguous buffers and this
was the reason for the 384 byte buffer sizes. This was previously
a limitation of the ZoAP API. The new CoAP API doesn't have this
limitation and the LwM2M library has already been migrated to use
it.
Let's finish the process by replacing any contiguous buffer handling
with the correct net_pkt APIs to parse across multiple fragments.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
application/octet-stream is used to indicate opaque payload format.
Use plain text handler to handle the opaque format.
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
When moving to the new CoAP API, I thought we would need to parse
incoming option values longer than 12 characters.
This hasn't proven to be true, so let's remove the auto-selection of
this config. If needed user can set this option later.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Remove the RD client's stack in favor of using the engine's periodic
service to trigger RD client events. This saves 5K RAM of stack based
memory.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Remove the stack from the device object and instead make use of
the periodic engine service which will trigger the device service
when it's ready.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Stacks cost a lot of RAM in Zephyr. We have 3 total stacks in
the LwM2M lib. We can remove 2 of these if add a service handler
into the main LwM2M engine. Each service can register with this
handler so that they can be called based on their own periodic
timer. The handler itself will search through these registered
services and call them when they become due otherwise sleep
until another is ready.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Let's use conservative defaults for the LwM2M library to enable
hardware with constrained resources. Users can increase where
necessary.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Let's use snprintk for simple formatting to allow for possible disabling
of printf and protect calls to sprintf from string overruns.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
When using Leshan REST API to perform a discover OP on a client, only an
accept field is sent with "application/link-format". Current logic uses
the content-type to determine when a discover OP is indicated. Let's
handle this case as well.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Let's rename lwm2m_release_message() to lwm2m_reset_message()
and add a parameter to let the function know whether or not to
release the lwm2m_message resource back to the pool.
By adding the optional release parameter, we can keep the
lwm2m_message but reset the underlying net_pkt / net_buf resources.
This allows us to regenerate the net_pkt after determining
an error has occured. In this case, we don't want the previously
added net_pkt contents but we do want to maintain the message id,
token, etc.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
This patch moves from the ZoAP API in subsys/net/lib/zoap to
the CoAP API in subsys/net/lib/coap which handles multiple
fragments for sending / receiving data.
NOTE: This patch moves the LwM2M library over to the CoAP APIs
but there will be a follow-up patch which re-writes the content
formatter reader / writers to use net_pkt APIs for parsing
across multiple net buffers. The current implementation assumes
all of the data will land in 1 buffer.
Samples using the library still need a fairly large NET_BUF_DATA_SIZE
setting. (Example: CONFIG_NET_BUF_DATA_SIZE=384)
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Don't use names like "strlen" for parameters. Try and name buffer
parameters consistently.
NOTE: For several functions I removed "const" flag. This is
intentional and will be needed in upcoming patches.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
Remove some left over TODOs and also fix a TODO where we need to return
the appropriate error code to generate a 4.05 response.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
The stack of rd client is exhausted while running lwm2m client w/ IPv6
and network log global enabled. Increase the stack size to 1536 when
NET_LOG_GLOBAL is enabled.
Detail described at #4424
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
".well-known/core" is mainly used with method GET for performing the
resource discovery (RFC 6690). Since we are implementing a LwM2M client
and is not implement a resource directory which allow others to do the
resource registration (POST to .well-known/core). Only GET method is
allowed for the usage. Report 4.5 (Method Not Allowed) if other methods
are requested.
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
Modify zoap_options_to_path() to return error when URI contains
character other than digits and return 4.04 NOT FOUND to caller.
PATH such as "/1a/2/3" was treated as "/1/2/3" after parsring
which is incorrect.
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
Return 4.05 Method Not Allowed when path is empty ('/') to the
caller for it's only use by bootstrap delete. This change also avoid the
empty path being treated as request targeted at 0/0/0.
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
1) Respond NOT FOUND to caller when object doesn't exist
2) Report as internal server error when OP not handled
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
Applications may want to be notified when various events
happen in the LwM2M rd client. Let's implement an event
callback which sends: connect, disconnect and update events.
Signed-off-by: Michael Scott <michael.scott@linaro.org>
CoAP allows a proxy to be used when transferring data (CoAP-CoAP and/or
CoAP-HTTP) by creating request on a specific URI path and by using the
Proxy URI CoAP option. Create specific Kconfig options for the proxy
server address and port, until a parser gets implemented.
Code tested with Californium acting as CoAP proxy.
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
[michael.scott@linaro.org: rebased on net_app + lwm2m_message
refactoring + firmware update changes.]
Signed-off-by: Michael Scott <michael.scott@linaro.org>
During firmware download via block-wise transfer, we can see
packets occaionally get re-transmitted (normal logic in the
pending / retry functions). However, both of these packets
end up coming through the reply handler and we should ignore
any block-wise transfer that has a current value less than
where we expect to be.
NOTE: This fixes K64F ethernet transfers where we were getting
too many packets back in the handler.
Signed-off-by: Michael Scott <michael.scott@linaro.org>