Commit graph

2591 commits

Author SHA1 Message Date
Andrei Emeltchenko 8f21a37861 usb: Clean up code to meet Zephyr standard
Add missing "{}" braces and remove unneeded "()" braces.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Andrei Emeltchenko 60f8c6e272 usb: usbnet: Clean up code
Use common logging method and correct braces.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Andrei Emeltchenko 17735e8a04 usb: netusb: Remove USB custom_handler()
Custom handler is not used, cleaning code.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Andrei Emeltchenko 6e2e2dbb1b usb: msc: Clean up comment
Trivial cleaning

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-31 07:42:19 -05:00
Michael Scott afb9830441 net: lwm2m: fix retransmit_request() pending process / packet send
During the CoAP API change, slight changes were made the ref / unref
packet pending process.  Let's re-align with the coap-client sample
in how we apply the packet refs in retransmit_request() and also
replace the lwm2m_send_message() call with a direct call of
net_app_send_pkt().  This avoids a second processing of the pending
packets and keeps the ref/unref flow cleaner.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-31 12:20:41 +02:00
Michael Scott db09596b1d net: lwm2m: correct packet pending process in lwm2m_send_message()
During the CoAP API change, the way packets were ref'd and then
unref'd in order to stop the packet sending functions from releasing
the net_pkts was changed and never updated in the LwM2M library.

Let's use coap_pending_cycle() and coap_pending_clear() to do the
ref/unref the same way as the coap-client samples in order to
match the pending process with the current CoAP APIs.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-31 12:20:41 +02:00
Vinayak Kariappa Chettimada d03ad43dbb Bluetooth: controller: Fix to restrict addr set in active scan
Fix controller implementation to only restrict HCI LE Set
Random Address command when advertising and/or active
scanning is enable.

Continues to pass the following LL.TS.5.0.2 conformance
test:
LL/SEC/SCN/BV-01-C [Random Address Scanning]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-31 10:16:47 +01:00
David B. Kinder baed5a59c7 doc: fix misspellings in Kconfig files
Fix misspellings in Kconfig files used for configuration docs.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-01-30 20:03:40 -05:00
Ramakrishna Pallala 5155e68105 subsys: disk: Kconfig: add prompt messages for config options
Add prompt messages for config options dependent on DISK_ACCESS_FLASH

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
2018-01-30 11:32:02 -05:00
Robert Chou 6fbd86113d net: lwm2m: fix reporting attributes with negative fraction
Fraction could be stored with negative value.
The implementation was only considering the positive value case.
Therefore, we have to modify the code to take care of the case.

To test it
======================================================================
1. launch eclipse/wakaama lwm2m server
2. launch zephyr lwm2m client and wait for registration completed
3. Issue commands from server
   * attr 0 /1/0/1 -0.1 0.1
   * disc 0 /1/0

Current output
----------------------------------------------------------------------
Client #0 /1/0 : 2.05 (COAP_205_CONTENT)
105 bytes received of type application/link-format:
</1/0>,</1/0/0>,</1/0/1>;gt=0.1;lt=0/00000,</1/0/2>,</1/0/3>,</1/0/4>,
</1/0/5>,</1/0/6>,</1/0/7>,</1/0/8>

Expected output
----------------------------------------------------------------------
Client #0 /1/0 : 2.05 (COAP_205_CONTENT)
102 bytes received of type application/link-format:
</1/0>,</1/0/0>,</1/0/1>;gt=0.1;lt=-0.1,</1/0/2>,</1/0/3>,</1/0/4>,
</1/0/5>,</1/0/6>,</1/0/7>,</1/0/8>

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-29 23:30:44 -05:00
Jukka Rissanen d1675bf3e6 net: http: Remove the old legacy API
There are no internal users for old HTTP API so removing it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-01-29 22:44:45 -05:00
Kamil Sroka 95cb365fae subsys: net: ip: l2: Add OpenThread L2
Add OpenThread to Zephyrs net stack as data link layer.
OpenThread requires to call process function when an event occurs.
This process function is called from cooperative thread.

Packet conversion and dispaching is implemented in openthread.c
as well as addresses forwarding.

Signed-off-by: Kamil Sroka <kamil.sroka@nordicsemi.no>
2018-01-29 22:42:03 -05:00
Kamil Sroka 83b2218ab5 subsys: net: lib: Add OpenThread platform
OpenThread requires platform definition with standarized API
so we have to add wrappers to make it compatible with Zephyr.
OpenThread is based on autoconf, this requires
more specific CMakeLists.txt which allows to clone specific
commit or point to local copy of openthread.

Signed-off-by: Kamil Sroka <kamil.sroka@nordicsemi.no>
2018-01-29 22:42:03 -05:00
Vinayak Kariappa Chettimada f117505773 Bluetooth: controller: Fix to restrict addr set in active states
Fixed implementation to disallow setting Bluetooth device
address under active advertising or scanning states.

Fixes LL.TS.5.0.2 conformance tests:
LL/CON/INI/BV-01-C [Connection Initiation]
LL/SEC/ADV/BV-01-C [Advertising With Static Address]
LL/SEC/SCN/BV-01-C [Random Address Scanning]

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-29 18:03:15 +01:00
Alberto Escolar Piedras ec7727077b native: nrf52 changes to HAL to support running on simulated HW
Conditionally compiled changes to the NRF52 HAL so it can
run on simulated HW on the native port.
(HW models are not included in this commit)

All changes are under ifdefs and therefore will not have any
effect on normal builds

Signed-off-by: Alberto Escolar Piedras <alpi@oticon.com>
2018-01-29 16:02:29 +01:00
Vinayak Kariappa Chettimada 619bcf56c4 Bluetooth: controller: Refactor mayfly integration into hal
Refactor mayfly based execution context solution out into
the HAL folder. This opens up the possibility to use
tasklets (if and when kernel gets the support) style
execution contexts.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-29 13:04:15 +01:00
Vinayak Kariappa Chettimada f5d64aafaa Bluetooth: controller: Fix CPR initiation while in Enc. setup
Fixes a bug where in Connection Parameter Request was
initiated by slave role while Encryption Setup had been
started by the peer master.

Fixes: #5823

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-26 11:35:17 +01:00
Johann Fischer daa83f8823 usb: mass_storage: rework and cleanup logging
This patch reworked logging so that the logging levels are more
finely graded and the locations with non-critical error handling
(below usb_ep_set_stall's) are logged with SYS_LOG_WRN.
Also cleanup, add log domain and fix indents.

Signed-off-by: Johann Fischer <j.fischer@phytec.de>
2018-01-26 08:35:08 +05:30
Kumar Gala 26e4da52cf arm: nordic: flash: Use FLASH_DEV_NAME define
We want to move to use a common FLASH_DEV_NAME across the various flash
drivers. So samples, tests, or other code can be a bit more generic.  So
replace CONFIG_SOC_FLASH_NRF5_DEV_NAME with FLASH_DEV_NAME.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-01-25 15:23:00 -06:00
Vinayak Kariappa Chettimada 4d7d9de342 Bluetooth: controller: Refactor LL up and downstream interface
Rename some legacy upstream and downstream interfaces in
radio_* namespace to ll_* namespace for consistency.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-25 22:09:17 +01:00
Vinayak Kariappa Chettimada 5b0cd2c69b Bluetooth: controller: Conditional compile BT_LL_SW variant
Refactor Kconfig and CMakelists.txt to be able to
conditionally compile in BT_LL_SW variant in the controller
subsystem. This is done to support future controller with
vendor specific variant implementations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-25 11:51:10 +01:00
Vinayak Kariappa Chettimada ae9f5b38d0 Bluetooth: controller: Add missing CPR and DLE cond. compilation
Add missing conditional compilation in controller's HCI
implementation, removing redundant code being compiled in.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-25 11:16:45 +01:00
Vinayak Kariappa Chettimada 5f4a7ea119 Bluetooth: shell: Support a non-connectable build
Add conditional compilation and move code to support
building a non-connectable Bluetooth shell application.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-25 10:51:54 +02:00
Vinayak Kariappa Chettimada be0aa2ac2c Bluetooth: controller: Remove redundant clear of NRF_RADIO events
Remove redundant code that clears NRF_RADIO->EVENT_*
registers that are only used in PPI context. Only EVENT_*
registers that are read back need to be cleared.

Relates to: #5753

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-24 11:07:06 +01:00
Ioannis Glaropoulos 9d1ca9c390 Bluetooth: controller: remove redundant PPI channel and TIMER CC
This commit implements the SW-based radio switch for TIFS for LE
Coded PHY S2 in nRF52840 with a single PPI channel and a single
TIMER CC register.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-01-24 11:06:33 +01:00
Ioannis Glaropoulos adaef465e4 Bluetooth: controller: minor refactoring in nrf5 radio driver
This commit moves the radio enable on-tick functionality in
function hal_radio_enable_on_tick_ppi_config_and_enable() in
radio_nrf5_ppi.h.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-01-24 11:06:33 +01:00
Ioannis Glaropoulos 36ded0b516 Bluetooth: controller: adjust nRF52840 HW radio timings for Coded PHY
This commit adjust the nRF52840 HW Radio timings for LE Coded PHY.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-01-24 11:06:33 +01:00
Vinayak Kariappa Chettimada 13130dbe73 Bluetooth: controller: Fix BT_CTLR_DEBUG_PINS Kconfig help text
Help text for BT_CTLR_DEBUG_PINS incorrectly mentioned
specific GPIO pins being reserved for this feature, but in
reality the pins reserved vary on the SoC selected, hence
any specific mention of pin details is removed from help
text.

Fixes: #5499

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-24 11:05:51 +01:00
Paul Sokolovsky 996c6dd603 net: if: Handle new address type of NET_ADDR_OVERRIDABLE
The meaning of this address type is the same as NET_ADDR_MANUAL,
but with a provision that DHCP can override such an address.
It's intended for the usecase when there's a default static
configuration for when DHCP is not available, but DHCP should
override it.

Before going to add another address type, there was an attempt
to repurpose TENTATIVE address state, but it doesn't work as
expected, as indeed, all existing address types/states already
have clearly semantics, and it makes sense to just another
address type to avoid confusion and unexpected behavior.

Fixes: #5696

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-23 09:25:51 +02:00
Paul Sokolovsky c57abaa7c8 net: app: Allow to specify both static IP settings and DHCPv4.
The idea is that static config is used unless/until DHCP values
arrive. This allows to have the same network configuration values
for both a case of direct board - workstation connection (where
DHCP is usually not available), and a case where both a board and
workstation connect to a router (which serves DHCP).

The changes in this commit however take care of netmask and gateway
settings, but not about IP address itself. This is addressed in the
next patch.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-23 09:25:51 +02:00
Vinayak Kariappa Chettimada 5d4a32b70a Bluetooth: controller: Fix missing TIFS_HW cond. compilation
Fix a missing !CONFIG_BT_CTLR_TIFS_HW conditional
compilation when nRF52840 is configured to use hardware
Trx switching, that caused compile error.

Fixes: #5779
Fixes: #5761

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-01-22 15:33:15 -06:00
Anas Nashif e1d284f648 shell: rename get_mod_cmd
rename function and call out module in the name.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif d7777d3bd5 shell: support standalone commands
This will allow us to register commands directly without a need for a
module.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif 8d1931504a shell: rename module sections
Prepare for supporting stand-alone commands.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif 16424cf0bc shell: kernel: rename tasks -> threads
Rename tasks -> threads, task was the common name for threads before the
unified kernel was introduced.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Anas Nashif dd013691b2 shell: add a shell banner
Give details about running version and add a line about usage.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-19 12:01:08 -05:00
Mariusz Skamra 0572fe99ec Bluetooth: mesh: Check Heartbeat Pub count prior scheduling delayed work
This check is needed to not schedule the delayed work if current
message to be sent is the last heartbeat message.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-19 14:07:48 +02:00
Mariusz Skamra 37122d7205 Bluetooth: mesh: Reset Heartbeat Pub timer before sending message
The timer should be reset before sending to ensure correct
publication period.

This patch allows to pass MESH/NODE/CFG/HBP/BV-02-C.

This patch is ported from mynewt:
Commit: d4b84638df47e7ea21629e6919f547f5dcd47285

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-19 14:07:48 +02:00
John Andersen b0d8075709 net: ip: dhcpv4: Handle DHCPV4_OPTIONS_DNS_SERVER
Actually set Zephyr's default DNS server based on the corresponding
DHCP option received. This makes DHCP-based setup Zephyr complete:
now it's possible to connect Zephyr DHCP-enabled system to a typical
router, and it will fully auto-configure to access Internet.

This initial implementation uses just first DNS server address as
returned in DHCP message, it may need to be extended in the future
based on the need.

Signed-off-by: John Andersen <john.s.andersen@intel.com>
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-18 17:30:40 +02:00
Paul Sokolovsky d965598ee2 net: dns: Allow to initialize DNS servers from struct sockaddr[]
In some cases, we need to initialize DNS servers from a binary
addresses, e.g. in case of DHCP processing. With existing API,
such addresses would need to be converted to strings, just to
be converted back to struct sockaddr in dns_resolve_init().
This is not efficient, and with a number of addresses quite
cumbersome. So instead, allow to pass DNS server either as
strings, or as struct sockaddr's (or both).

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-18 17:30:40 +02:00
Paul Sokolovsky a3231798ae net: lib: dns: dns_resolve_close: Mark context as unused
So it can be dns_resolve_init()ed again.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-18 17:30:40 +02:00
Ioannis Glaropoulos 55d3ce111c Bluetooth: controller: Refactoring nRF5 radio driver
This commit refactors the nRF5 radio driver of Bluetooth controller
to use symbolic names for PPIs. It also revisits the Radio hardware
timing constants to align with experimental measurements.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-01-18 10:58:04 +01:00
Andrei Emeltchenko ca9c3ad8f1 usb: rndis: Use offsetof macro to ease offset calculations
Use macro offsetof() for calculating offset inside structure.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko be1d865409 usb: Add RNDIS packet boundary check
Add check for rndis_set_handle() packet.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko cd4cea0527 usb: netusb: Add Networking logging debug level
Adding Networking USB Device Debug level allows to fine-tune
logging.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 6d61c2cf24 usb: rndis: Select USB_COMPOSITE_DEVICE for RNDIS
Windows works better with this option.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 2a1bdc2549 usb: Set Class Handler buffer size to 256 for RNDIS
Set default value for RNDIS.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 33e9851254 usb: rndis: Add Remote NDIS protocol handling
Add implementation of Microsoft Remote NDIS USB Ethernet protocol.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 337601b42f usb: rndis: Add RNDIS device descriptors to the table
Add needed descriptors for USB Remote NDIS Ethernet Network.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko b4ae3ec32f usb: Add init() callback to network device functions
Add init() callback needed for RNDIS and maybe others functions.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 2615658027 usb: Use standard SYS_LOG_USB_DEVICE_LEVEL for log level
Change hardcoded value to configuration defined.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 7e80f41162 usb: Rename SYS_LOG_USB to SYS_LOG_USB_DEVICE
At the moment CONFIG_SYS_LOG_USB_LEVEL name does not specify that this
is log level for the Device Stack. Make it clear renaming to the
proper name.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Andrei Emeltchenko 42d160a315 usb: netusb: Remove unneeded debug
Remove old unneeded debug statements.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-17 18:53:05 -05:00
Paul Sokolovsky 9e37dbeabe net: shell: Fix typo in description of "dns" command.
Was "is configure", should be "is configure*d*".

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-17 17:08:54 -05:00
Mariusz Skamra 385240ad0c Bluetooth: Fix BT_TESTING option dependency
This removes BT_DEBUG dependency on BT_TESTING flag.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-16 14:40:54 +02:00
Michael Hope ed35aa8c63 net: use UNALIGNED_ACCESS when accessing s_addr on received packets.
The offset of the IP header in a received packet depends on the L2
header size.  For Ethernet this is 14 bytes which puts the u32 IPv4
addresses on a non-u32 byte boundary.  This causes chips that don't
support unaligned access (like the Cortex-M0) to fault.

The fixes in this patch are enough to ping the board and run the
http_server sample.

Signed-off-by: Michael Hope <mlhx@google.com>
2018-01-16 11:27:48 +02:00
Patrik Flykt 010fb40b95 subsys: usb: Set Zephyr project USB Vendor and Product IDs
Document USB Vendor and Product IDs and their intended usage.
Set the Vendor and Product IDs and define the USB bcdDevice
Device Descriptor Device Release Number to be the binary
coded decimal representation of the Zephyr major and minor
kernel version number.

Signed-off-by: Patrik Flykt <patrik.flykt@intel.com>
2018-01-15 15:47:53 -05:00
Andrzej Puzdrowski f8a674b45e subsys: storage: flash_map: devices bindings fetch optimalization
Moved fetch of flash device bindings to early initialization of the
application.
Device bindings are constant while the application is running so
it is better to fetch it at startup, and not every time flash_map
procedures are called.


Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-01-15 15:46:37 -05:00
Andrzej Puzdrowski b7f1289847 subsys: fs: Add Flash Circular Buffer
Zephyr already supports NFFS as a storage layer, but it might
be a little bit too heavyweight for certain applications in
memory-restricted ICs.

This module is response for need of Lightweight flash storage
capability. FCB is ported form MyNewt as native zephyr module.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-01-15 15:46:37 -05:00
Andrzej Puzdrowski 25269fb0ed subsys: storage: Add flash_map abstraction module
Introduce flas_map module is abstraction over flash memory and its
driver for using flash memories along with description of
available flash areas.
Module provides simple API for write/read/erase and so one.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
2018-01-15 15:46:37 -05:00
Tomasz Bursztyka 6eec2d2aa5 net/ieee802154: Normalize parameter on radio API helper
For some reason, ieee802154_verify_channel had a device parameter
instead of an iface like all the others.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka ebfa2df113 net/ieee802154: Use helpers to call radio API functions
Now the code is a bit cleaner.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka 6f51ac7f2b net/ieee802154: Introduce helpers to call radio api function
Basically to make code nicer and more readable.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka 208e7f2bf6 net/lib: 15.4 interface is set UP after channel is configured
Once it has - at least - set up the channel, it can request the iface to
be put up.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka 9078378bed net/ieee802154: Do not set the device UP by default
It will be up to the user to configure a valid channel, through
net_mgmt, and call net_if_up() in order to get the device up.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka 6fa3d0fa3e net/ieee802154: Verify in L2 the Sub-Ghz channel value
Depending on device's band, the upper channel limit can vary a lot in
Sub-Ghz. Thus verifying it directly in L2 before requesting it to the
device.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Tomasz Bursztyka 9aa2f45d23 net/ieee802154: Add Sub-Ghz dedicated function on the radio API
Sub-Ghz bands have different limit of channels. 10, or more than a
thousand is actually possible. Thus the device needs to expose such
limit to the L2 which is unaware of frequency band logic. L2 will
then allow user to select a proper channel.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2018-01-15 15:15:38 +02:00
Paul Sokolovsky cb140154b0 net: tcp Remove recv_max_ack field from struct net_tcp
This field is set and maintained, but not actually used for anything.
The only purpose for it would be to validate ACK numbers from peer,
but such a validation is now implemented by using send_seq field
directly.

Fixes: #4653

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-15 15:08:22 +02:00
Paul Sokolovsky e36f67d1d9 net: tcp: Remove incorrect logging of "ACK errors"
Case #1: If ACK received and our retransmit (i.e. unacked) queue is
empty, it's error. It's incorrect because TCP requires ACK to set for
every packet of established connection. For example, if we didn't
send anything to peer, but it sends us new data, it will reuse the
older ack number. It doesn't acknowledge anything new on our side,
but it's not an error in any way.

Case #2: If retransmit queue is only partially acknowledged, it's an
error. Consider that we have 2 packets in the queue, with sequence
numbers (inclusive) 100-199 and 200-399. There's nothing wrong if
we receive ACK with number 200 - it just acknowledges first packet,
we can remove and finish processing. Second packet remains in the
queue to be acknowledged later.

Fixes: #5504

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-15 15:07:49 +02:00
Paul Sokolovsky ac7b1291da net: tcp: Validate incoming ACK number
Per RFC 793:

  A new acknowledgment (called an "acceptable ack"), is one for which
  the inequality below holds:

    SND.UNA < SEG.ACK =< SND.NXT

If acknowledgement is received for sequence number which wasn't yet
sent, log an error and ignore it.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-15 15:07:49 +02:00
Robert Chou b7af740f3a net: lwm2m: update observe_node when attributes are written or cleared
As title, we should update the existing observe_node when new attributes
are written from server side. Add the implementation to handle that.

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-12 20:57:34 -05:00
Robert Chou 2281f6fd7d net: lwm2m: get attributes from obj/obj_inst/res for observe_node
1. Read notification attributes set by server to setup the
   minimum/maximum notification period of a observation request.
2. Reordering to check observe_node duplication first
   (bailout earlier)
3. Simplify remove observe_node condition checking

NOTE: attributes are inheritable, priority: res > obj_inst > obj
Reference: LwM2M spec V1_0_1-20170704-A, section 5.1

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-12 20:57:34 -05:00
Robert Chou b0e7a039ee net: lwm2m: report attributes on discover op
Since we've added storing notification attributes written by server.
We can now append these attributes as part of link-format for discover
op.

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-12 20:57:34 -05:00
Robert Chou 09fcd83b98 net: lwm2m: add write-attribute WRITE support
Implement write-attribute on obj/obj_inst/res according to LwM2M spec
20170704-A, sec 5.1.2. Support pmin/pmax/st/gt/lt parameters on WRITE
operation.

The basic idea is to add sys_slist_t to obj/obj_inst/res structure.
And attach struct lwm2m_attr to the list when attributes are written
from server side (implement lwm2m_write_attr_handler accordingly)

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-12 20:57:34 -05:00
Jukka Rissanen ff22595c31 net: ip: shell: Fix ipv4 echo reply callback to unref packet
The ICMPv4 handler needs to unref the received echo reply packet
because we are returning NET_OK to caller. Similar change was done
for IPv6 earlier.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2018-01-12 20:51:32 -05:00
Andrei Emeltchenko af0bf06aa3 usb: Fix USB Device dependency
USB Device stack should depend on supported drivers not on menuconfig
option.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2018-01-12 07:46:28 -05:00
Carles Cufi 7d764b35f3 cmake: Use path-corrected version of ZEPHYR_BASE
Instead of accessing the environment variable ZEPHYR_BASE every time we
require accessing the source code root, use an intermediate variable
that has OS path separators correctly set to '/' to avoid issues on
Windows.

Note: This removes the ZEPHYR_SOURCE_DIR CMake variable. External
applications using that will need to change to use the new ZEPHYR_BASE
variable.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2018-01-11 14:59:03 -05:00
Paul Sokolovsky 84e3d3e7e8 libc: Kconfig: Move STDOUT_CONSOLE from subsys/debug
This option is clearly not related to debugging, but affects libc
features.

Fixes: #5566

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-11 12:47:10 -05:00
Pedro Martucci df37588b6f net: ip: shell: Fix ipv6 echo reply callback to unref packet
When testing ping6 with net shell, it was noticed that after some
sucessive calls the applications stopped to handle rx packets.
Analyzing other icmpv6 register callbacks it was verified that is
necessary to unref packets before returning NET_OK.

Signed-off-by: Pedro Martucci <pedropaulomartucci@gmail.com>
2018-01-11 09:19:48 +02:00
Michael Scott a21563d1a8 net: lib: lwm2m: fix coap proxy resource option
commit 2a7546fb5a ("net: lwm2m: add support for coap2coap proxy")
erroneously changed the COAP_OPTION_* used to specify the coap2coap
or coap2http proxy resource used from COAP_OPTION_URI_PATH to
COAP_OPTION_PROXY_SCHEME.

Changing it back to COAP_OPTION_URI_PATH requires us to re-order how
the coap options are appended to the packet as the coap options must
be added in the order specified by the numbers in:
https://tools.ietf.org/html/rfc7252#section-12.2

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-11 09:18:45 +02:00
Robert Chou 33030721c4 net: lwm2m: increase packet reference to avoid packet being freed
CoAP packet w/ confirmation flag set is required to be retransmitted
before it got the ACK message from the peer.

However, the packet is usally unreference once it's sent to the network.
Although we set the timeout as no wait when calling function
net_app_send_pkt(), it's still possible that the packet is unreferenced
before we got a chance to increase the packet reference by calling
coap_pending_cycle().

Usually, the IP stack will generate an ARP packet first and then send
out the packet.  However, this is not the case when the remote is a
loopback address.

As issue #5101 described, when asking client to perform a firmware pull
on URL "coap://127.0.0.1:7783/large". The packet will be unreferenced
immediately after calling net_app_send_pkt(). Which then result in
client hang.

The solution to the issue is to increase the reference count on the
sending packet and decrease it after the process is finished.

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2018-01-11 09:18:10 +02:00
Michael Scott 33ea1b5c89 net: skip TX max send calculation in net_pkt_append() for RX packets
We shouldn't limit the amount of data appended to RX packets based on
the max send size of TX packets.  Skip this check for packets in the
RX slab.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-10 21:48:20 -05:00
Michael Scott 6338ec0546 Revert "net: net_app: set packet data_len on incoming packets"
This reverts commit 3599d793c2.

Setting a packet's data_len here doesn't fix the fact that we shouldn't
be using it at all on RX packets.  Fix belongs in net_pkt_append().

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-10 21:48:20 -05:00
Michael Scott a75458131a net: lib: app: trigger TLS closure when connection is closed
When testing TLS connections on production web server, it was noticed
that the TLS mainloop was getting "hung" after a connection was made
via HTTPS and then closed by the server.  The TLS mainloop was never
being notified that the connection was closed and was stuck waiting
for more data.

The next time that connection was used, TLS would fail to start.

Let's force trigger a closure of the TLS process when the net-app layer
is notified of the connection closure.  This allows the connection to
be successfully reused later.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-10 21:47:46 -05:00
Mariusz Skamra 2f81942754 Bluetooth: mesh: Fix model subscription groups cleanup
Virtual address labels array entries were not updated on va deletion,
so that STATUS_INSUFF_RESOURCES error was returned after few
subsequent Config Model Subscription Virtual Address Add, Delete,
Overwrite commands, even if there shall be free space available.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-10 16:38:53 +02:00
Mariusz Skamra 4ba9543bdd Bluetooth: mesh: Fix LPN subsciption groups update on VA deletion
This fixes missing bt_mesh_lpn_group_del call in mod_sub_va_del.
If Config Model Subscription Virtual Address Delete was received
and successfully proceeded, subscription address shall be also
deleted from LPN Subscribe Groups.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-10 16:38:53 +02:00
Anas Nashif 4d2ad0a8a5 Bluetooth: remove unused BT_DEBUG_COLOR
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-09 10:59:41 -05:00
Paul Sokolovsky d9e886bc6e net: Kconfig: Don't select STDOUT_CONSOLE
The net code doesn't use libc stdio stdout in any way, so there's no
need tweak those options.

Fixes: #5565

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-05 10:00:26 -05:00
Mariusz Skamra 253e40ad0e Bluetooth: mesh: Do not set RFU bits in Heartbeat Publication Features
Features received in Config Heartbeat Publication Set message can have
Feature bits set to RFU values.
This patch fixes setting this RFU bits in Heartbeat Publication
Features, so that those are not indicated in Config Heartbeat
Publication Status message.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-05 09:31:50 +02:00
Paul Sokolovsky 7c7223982a net: shell: conn: Cross-ref TCP control block to owning context
Previously "conn" command dumped TCP control blocks without
referencing it to an owning context, making it hard to figure
out what happens. Now, dump context address.

Example before:

net> conn
     Context    Iface         Flags Local               Remote
[ 1] 0x00403360 0x0041fac0    6ST   [::]:4242   [::]:0
[ 2] 0x004033c8 0x0041fac0    4ST   0.0.0.0:4242        0.0.0.0:0
[ 3] 0x00403430 0x0041fac0    6DU   [::]:4242   [::]:0
[ 4] 0x00403498 0x0041fac0    4DU   0.0.0.0:4242        0.0.0.0:0
[ 5] 0x00403500 0x0041fac0    4ST   192.0.2.1:4242      192.0.2.2:55314

TCP        Src port  Dst port   Send-Seq   Send-Ack  MSS
0x00403c00     4242         0 2541690653          0  1440
0x00403cbc     4242         0 2797902539 3233948882  1460
0x00403d78     4242     55314 2797902539 3233948882  1460

Example after:

net> conn
     Context    Iface         Flags Local               Remote
[ 1] 0x00403360 0x0041fac0    6ST   [::]:4242   [::]:0
[ 2] 0x004033c8 0x0041fac0    4ST   0.0.0.0:4242        0.0.0.0:0
[ 3] 0x00403430 0x0041fac0    6DU   [::]:4242   [::]:0
[ 4] 0x00403498 0x0041fac0    4DU   0.0.0.0:4242        0.0.0.0:0
[ 5] 0x00403500 0x0041fac0    4ST   192.0.2.1:4242      192.0.2.2:55424

TCP        Context   Src port Dst port   Send-Seq   Send-Ack  MSS
0x00403c00 0x00403360    4242        0 1854382523          0  1440
0x00403cbc 0x004033c8    4242        0 1420360158 2064582979  1460
0x00403d78 0x00403500    4242    55424 1420360158 2064582979  1460

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-04 18:38:19 -05:00
Paul Sokolovsky 94995cbd0f net: ip: Optimize statements for setting packet lengths.
Use native C operators for converting a word to bytes.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2018-01-04 18:37:18 -05:00
Mariusz Skamra fdca8d8f54 Revert "Bluetooth: Mesh: Fix ignoring invalid Transport OpCode as LPN"
This reverts commit ada5771d7c.

MESH/NODE/FRND/LPN/BI-02-C in Mesh Test Specification 1.0.1
has been fixed according to TSE #9774.

IUT shall ignore the message with an RFU Transport Control Opcode
but another Friend Poll message shall be sent with an alternating
FSN value.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-04 15:33:19 +01:00
Mariusz Skamra cc1a960730 Bluetooth: mesh: Fix status returned from mod_unbind
According to Mesh Specification v1.0 4.3.2.48 Config Model App Status:
"The Status Code shall be Success if the received request was redundant
(bind request of existing binding, or unbind of a non-existing binding),
with no further action taken."

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-04 15:08:43 +01:00
Michael Scott 3599d793c2 net: net_app: set packet data_len on incoming packets
This fixes a bug when calling net_pkt_append[_all] which uses
pkt->data_len as part of the maximum packet length calculation
when the net_context is set.

Without this change the maximum packet length is calculated as 0
(the value of pkt->data_len) and an ENOMEM error is returned.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-03 19:02:31 -05:00
Michael Scott e71f95b946 net: ip: net_pkt: set pkt context, iface and family in net_pkt_get()
Commit 753daa6 ("net: pkt: Compute TX payload data length")
removed the default packet setup on incoming packets when they
belong to the rx_pkt pool.

Let's restore this behavior, as MBEDTLS processing in net_app library
needs to use packet family to determine IP header length on
incoming packets.

NOTE: A future cleanup patch could set the IP header length based
on the context IP family.  However, there are many places in the code
where this is being set, so care should be taken.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2018-01-03 19:02:31 -05:00
Mariusz Skamra 813ec50838 Bluetooth: btp: Add event indicating expiration of incomp timer
This event indicates that segmented message incomplete timer
expired.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra 9977caefa1 Bluetooth: testing: Move bt_test_mesh_net_recv to internal API
This function is called only within mesh stack.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra 8274cbabf6 Bluetooth: btp: Add Mesh Clear Replay Protection List Cache command
This command is needed for Bluetooth Mesh testing against PTS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra a909aa3a0b Bluetooth: btp: Add LPN Subscribe/Unsubscribe commands
This adds commands to manage Friend node Subscription List.
Those will be used to add or remove and group/virtual address
from subscription list.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra 0bd3790d5b Bluetooth: btp: Add event indicating invalid provisioning BearerOpcode
This adds BTP event indicating reception of provisioning message
with invalid (RFU) BearerOpcode.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra 0d71cef1f2 Bluetooth: tester: Add BTP Mesh Model Send command implementation
This command will be used to test if model can properly send
segmented and unsegmented messages to a given destination address.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Jan Van Winkel 36e2efaf91 fs: nffs: Corrected types in OS specific functions
Corrected types in OS specific functions to be inline with NFFS
declarations.

Fixes #5467

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
2018-01-02 13:34:02 -05:00
Anas Nashif 13b08296e1 net: remove zoap library
We now have coap, all dependencies have been removed, so cleanup for the
next release.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-02 09:41:24 -05:00
Ravi kumar Veeramally 1e277e0f20 net: app: Do not reset net_context information
Do not reset net_context information in net_app_close. In case of
TCP behind the curtains connection might wait for some timers to
expire and send some messages (e.g. ACK). If we set source port to
'0', unexpected behaviour might happen with peer connection.
Only reset net_app context related information on net_app_close.
Let net_context_put will take care of proper connection closure.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-12-31 11:58:27 -05:00
Ravi kumar Veeramally a0371ae92f net: tcp: Add initial support for TIMEWAIT timer
Right now in FIN_WAIT1 state, if we receive FIN+ACK message, then
tcp state changed to FIN_WAIT2 on ACK flag and immediately on FIN
flag state changed to TIME_WAIT. Then final ACK is prepared and sent
(in queue at-least) to peer. Again immediately state changed to
TCP_CLOSED, where context is freed. net_context_put frees context
and releases tcp connection. Final ACK packet which is in queue
is dropped.

As a side effect of freed ACK packet, peer device keep on sending
FIN+ACK messages (that's why we see a lot of "TCP spurious
retransimission" messages in wireshark). As a result
of context free (respective connection handler also removed), we see
lot of packets dropped at connection input handler and replying with
ICMP error messages (destination unreachable).

To fix this issue, timewait timer support is required. When tcp
connection state changed to TIMEWAIT state, it should wait until
TIMEWAIT_TIMETOUT before changing state to TCP_CLOSED. It's
appropriate to close the tcp connection after timewait timer expiry.

Note: Right now timeout value is constant (250ms). But it should
be 2 * MSL (Maximum segment lifetime).

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-12-31 11:58:27 -05:00
Ravi kumar Veeramally 124c067027 net: tcp: Cancel the fin_timer on FIN message in FIN_WAIT1 state
fin_timer will be started after sending FIN to peer. After successful
reception of FIN+ACK message in FIN_WAIT1 state, fin_timer should be
cancelled.

Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
2017-12-31 11:58:27 -05:00
Manivannan Sadhasivam 045d146d9f subsys: bluetooth: host: mesh: shell: Fix IVIndex parsing
Fix the parsing of IVIndex value from shell command line for
cmd_provision

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2017-12-30 08:28:00 +01:00
Paul Sokolovsky e25df54eae various: Update/fix some textual material and code comments.
Of these, only struct net_ipv6_nbr_data::send_ns is a descriptive
change:

send_ns is used for timing Neighbor Solicitations in general, not
just for DAD.

The rest are typo/grammar fixes.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-12-29 09:45:39 -05:00
Vinayak Kariappa Chettimada 891ba80087 Bluetooth: controller: Fix S2 coding Rx chain delay timing const
Fix the S2 coding Rx chain delay timing constant based on
manual observations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-29 10:31:44 +01:00
Vinayak Kariappa Chettimada d3585cd1d9 Bluetooth: controller: Add tIFS SW switching for Coded PHY
Add implementation to consider differing Rx chain delays for
S2 and S8 Coded PHY PDU reception. These changes are
required to meet tIFS timings for transmission after a
reception on S8 coding.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-29 10:31:44 +01:00
Vinayak Kariappa Chettimada e00282af6e Bluetooth: Fix build failure with -Wshadow CFLAGS
Fixes many instances of errors similar to below:
zephyr/subsys/bluetooth/controller/ll_sw/ctrl.c:5927:22:
    error: declaration of ‘s_link’ shadows a previous
        local [-Werror=shadow]
  static memq_link_t s_link;
                     ^~~~~~
zephyr/subsys/bluetooth/controller/ll_sw/ctrl.c:5905:21:
    note: shadowed declaration is here
  static memq_link_t s_link;
                     ^~~~~~

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-20 12:29:52 -05:00
Mariusz Skamra a87840e8e2 Bluetooth: Expose Bluetooth Testing API
This moves Bluetooth testing header file to the include/bluetooth.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2017-12-18 12:43:23 +01:00
Anas Nashif e2122cbf89 lib: move ring_buffer from misc/ to lib/
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-15 20:02:01 -05:00
Michael Scott 2c208e99ad net: lwm2m: cleanup transfer_request error handling
Consolidate and standardize error handling throughout
lwm2m_obj_firmware_pull.c.  As well as handle previously
unhandled errors returned from transfer_request().

NOTE: in general, unhandled errors will now result in
RESULT_UPDATE_FAILED.  Previously, unhandled errors in
transfer_request() would result in RESULT_CONNECTION_LOST
which might or might not be over-written with another
result later.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2017-12-15 18:02:25 -05:00
Michael Scott 2fc554b8fc crypto: config: config-coap: add CONFIG for setting max content length
The CoAP samples use an MBEDTLS config "config-coap.h" which could be
re-used by the LwM2M sample, except that most servers use a larger
maximum content length setting of 1500 bytes.

Let's add a CONFIG to set this for users of the CoAP lib and set the
CONFIG value for the samples to the 256 size currently used.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2017-12-15 17:52:13 -05:00
Michael Scott 2a7546fb5a net: lwm2m: add support for coap2coap proxy
Currently, LwM2M firmware download only supports coap2http proxy.
Let's add support for coap2coap proxy as well.

This was tested running Californium demo app cf-proxy on the host
machine with the following setting changed in Californum.properties:
MAX_RESOURCE_BODY_SIZE=524288

Add the following to the samples/net/lwm2m_client/prj.conf:
CONFIG_LWM2M_FIRMWARE_UPDATE_PULL_COAP_PROXY_SUPPORT=y
CONFIG_LWM2M_FIRMWARE_UPDATE_PULL_COAP_PROXY_ADDR="coap://[2001:db8::2]:5682"

Build the sample for qemu_x86 as you would normally, but now
you can use a real world coap address to pull firmware using the 5/0/1
resource.  The host machine running cf-proxy will pull the remote
resource and then deliver it to the running qemu sample.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2017-12-15 16:47:30 -05:00
Michael Scott 6ddbd56853 net: lwm2m: add support for DTLS
- Add needed settings for DTLS support to the lwm2m_ctx structure.
- Add initialization of MBEDTLS to the LwM2M lib based on the
  user application settings in lwm2m_ctx.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2017-12-15 16:46:48 -05:00
Michael Scott 7111491be3 net: lwm2m: use correct remote address when DTLS is enabled
The default net_context remote address is scrambled when using a
connection via DTLS.  Instead let's use the dtls context remote.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2017-12-15 16:46:48 -05:00
Michael Scott 8f4b4db71f net: lwm2m: fix possible dereference in RD client
While looping through possible lwm2m_ctx matches, we're referencing
remote before checking that the context itself is valid.

Also, reduce indentation issues.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2017-12-15 16:46:48 -05:00
Michael Scott e0b8d172a9 net: lwm2m: setup LwM2M build as static library
Instead of building under the "app" context, let's build the
LwM2M library as a separate static library.  This will be helpful
later when adding support for DTLS as w/o this configuration,
the build breaks on MBEDTLS config includes.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2017-12-15 16:46:48 -05:00
Michael Hope 9dd4399edd fs: only select the disk subsystem if the filesystem needs it.
Of the filesystems under subsys/fs/, only the ELM FAT filesystem needs
the disk layer as others (like NFFS) talk directly to the flash API.

This removes the need to define CONFIG_DISK_ERASE_BLOCK_SIZE and
similar which are used by the disk subsystem but not by NFFS.

Signed-off-by: Michael Hope <mlhx@google.com>
2017-12-14 16:49:18 -06:00
Anas Nashif 429c2a4d9d kconfig: fix help syntax and add spaces
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-13 17:43:28 -06:00
Mariusz Skamra 700328ac55 Bluetooth: Introduce Bluetooth Testing API
This introduces Bluetooth internal API intended to be used for
qualification purposes. Application may register callbacks to get
data that is not exposed by public API.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2017-12-13 11:26:32 +02:00
Tomasz Bursztyka 4a3afb8506 net/ieee802154: Do not expose l2 specific context in generic net_l2.h
This will avoid exposing IEEE 802.15.4 Zephyr's L2 private context data
to unrelevant places.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-12-12 09:29:48 -05:00
Tomasz Bursztyka c88000a051 net/ieee802154: Split the net mgmt part from the L2 specific header
L2 specific data and IEEE 802154 net mgmt interface are not related.
Plus, application may use the net mgmt part, not the L2 one. So let's
split the content in relevant headers.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-12-12 09:29:48 -05:00
Robert Chou 685db067d5 net: lwm2m: separate write operation from write-attributes op
Content-format is used to determine the type of the PUT/POST
request. Therefore, it's incorrect to assign default when the
caller does not include one in the request.

Define LWM2M_FORMAT_NONE=65535 to indicate the format is missing.
The 65000~65535 is reserved for experiments and should be safe for
the purpose. Check content-type at PUT method to setup
write/write-attrs operation accordingly.

Also, add reporting write-attrs as not implemented to the caller.

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-12-12 09:26:31 -05:00
Robert Chou e237ae7d35 net: lwm2m: reduce code size of coap_options_to_path()
Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-12-12 09:26:31 -05:00
Robert Chou dfbe275c64 net: lwm2m: discover op does not depend on input format type
According to LwM2M specification V1_0_1-20170704-A, table 25,
incoming request is a discover op if it is method GET with
accept format as application/link-format

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-12-12 09:25:59 -05:00
Robert Chou 3062e76858 net: lwm2m: correct lwm2m discover operation behavior
According to LwM2M specification 20170208-A, there are two different
discover interfaces supported by the device.
(1) Bootstrap discover (sec 5.2.7.3) (To be implemented)
(2) Device management discover interface (Sec 5.4.2)
 - object ID is required (i.e. root directory discover is not allowed)
 - attributes should be responded accordingly when implemented

This patch correct the behavior according to the spec and summarized
as follow
(1) Still support CoAP ".well-known/core" but change to report only
    first level of the URI.
(2) Respond to caller only when object ID is provided unless it's
    bootstrap discover

Fixes #4941

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-12-12 09:25:59 -05:00
Robert Chou 7929aaf307 net: lwm2m: remove unused options variable
Remove it for we are not using it after calling the
coap_packet_parse().

Signed-off-by: Robert Chou <robert.ch.chou@acer.com>
2017-12-12 09:25:59 -05:00
Paul Sokolovsky 2a795a19ff drivers: eth_mcux: Implement IPv6 multicast group joining/leaving
IPv6 mcast addr to MAC mcast conversion was factored out to
subsys/net/ip/l2/ethernet.c for reuse by other drivers.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-12-12 09:24:51 -05:00
Tomasz Bursztyka f8cf3b99d9 subsys/net/lib: Clear up CMakeLists.txt
Tiny cleanups to clarify, and 80 chars limit fix.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-12-11 09:34:16 -05:00
Tomasz Bursztyka 8d2c0b4707 subsys/net/ip: Clear up content in CMakeLists.txt
Empty CMakeLists.txt in l2 and l2/ieee802154 deserved to get filled-in
relevantly, instead of centralizing everything in ip/ location.
Also making sure lines don't get over 80 chars.
Also, no need of linking against mbetls unless net shell is enabled.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2017-12-11 09:34:16 -05:00
Paul Sokolovsky f161633109 net: if: Join solicited-node multicast addr for each unicast addr
https://tools.ietf.org/html/rfc4862#section-5.4.2 :

"""
Before sending a Neighbor Solicitation, an interface MUST join the
all-nodes multicast address and the solicited-node multicast address
of the tentative address.
"""

So, joining should happen before sending DAD packets, and it should
happen for each unicast address added. This is achieved by joining
from net_if_ipv6_addr_add() call. Note that we already leave
solicited-node group from net_if_ipv6_addr_rm(). In particular, we
leave it if DAD fails (as that function is called in this case).

Fixes #5282.

Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
2017-12-11 09:09:48 -05:00
Aska Wu fa934009cb subsys: console: Fix the buffer size checking
Fix the problem that no compiler error even the buffer size is not power
of 2.

Signed-off-by: Aska Wu <aska.wu@linaro.org>
2017-12-10 19:49:02 -05:00
Anas Nashif f46c0c2472 kconfig: remove deprecated DEBUG_TRACING_KERNEL_OBJECTS
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-09 08:48:51 -06:00
Anas Nashif a254359c1a kconfig: stack_usage: remove extra space
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-09 08:48:51 -06:00
Vinayak Kariappa Chettimada ec5a787da2 Bluetooth: controller: Fix multiple master role event scheduling
When the controller is connecting to multiple connectable
advertisers, the events are scheduled consecutively avoiding
overlapping events. Calculation of the window offset did not
consider the preparation time before the event, causing the
new master role connection event to overlap with previous
event. This is now fixed by including the preparation time
in the used window offset from the end of connect_ind PDU
transmitted.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-09 09:24:37 +02:00
Michał Narajowski 06facdcad7 Bluetooth: Mesh: Fix typo in Kconfig help message
300 * 100 ms = 30000 ms = 30 s

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2017-12-07 17:15:47 +02:00
Vinayak Kariappa Chettimada ba13c99141 Bluetooth: controller: Fix conn param req initiation check
Fixed the check related to initiating connection parameter
request procedure. This will avoid sending invalid repeated
dispatch of connection parameter request PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-06 11:30:42 -06:00
Vinayak Kariappa Chettimada 73a493eae6 Bluetooth: controller: Fix missing CPR procedure reset
When connection parameter request procedure was responded
by master role with Unsupported Link Layer Parameter Value,
a missing reset of the connection parameter request
procedure state caused next connection parameter request to
be incorrectly responded with same procedure collision
extended reject ind PDU. This caused an eventual connection
disconnection with reason LMP response timeout. This is now
fixed by reseting the state correctly.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-06 10:24:26 -06:00
Johan Hedberg 8b51b60634 Bluetooth: Mesh: Proxy: Don't try to advertise when it's not possible
If we have the maximum number of supported connections, then it
doesn't make sense to try to do connectable advertising.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg e4cac812df Bluetooth: Mesh: Proxy: Fine-tune subnet advertising rotation
Create a slightly smarter algorithm for choosing how long to advertise
each subnet. This is particularly important for the mesh_shell app,
since it uses a 10 second NODE_ID_TIMEOUT, meaning starting Node ID
advertising through user interaction would only succeed in advertising
one subnet (due to this being configured to 10 seconds).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg 6e89138823 Bluetooth: Mesh: Suppport multiple subnets for app-triggered Node ID
Mesh Profile Specification 1.0 section 7.2.2.2.3:

"When the server starts advertising as a result of user interaction,
the server shall interleave the advertising of each subnet it is a
member of"

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg 174facc02a Bluetooth: Mesh: Prioritize subnets with Node ID
Node ID advertising is short lived, so it's important to make sure
that subnets that get it enabled are first in queue to start
advertising.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg 86ac86c6ca Bluetooth: Mesh: Add helpers for starting/stopping Node ID
We'll soon extend the start functionality with a bit more stuff
(prioritizing the started subnet), so in order to avoid excessive code
duplication, create helpers for these actions.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg 62777755f9 Bluetooth: Mesh: Add Proxy advertising support for multiple subnets
Until now the proxy server code would only advertise with the first
subnet. Introduce tracking of what the last advertised subnet was, and
give each subnet 10 seconds of advertising at a time.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg 364ce8801f Bluetooth: Mesh: Add support for sending NetKey Add message
Add configuration client model support for NetKey Add message, as well
as a mesh shell command for calling the new API.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg 74e1f51350 Bluetooth: Mesh: Coding-style: Remove redundant whitespace
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Michael Scott 2386ce7af8 net: if: fix ND reachable calculation
The reachable calculation for ND is using fractions combined with
integers and getting rounded to very small results (1ms or 0ms).
Let's split up the fraction into it's numerator and denominator
and perform the math in a better way to get the correct results.

Signed-off-by: Michael Scott <michael@opensourcefoundries.com>
2017-12-05 07:51:59 -06:00
Johan Hedberg 22f3d36ba7 Bluetooth: Mesh: Fix relaying from GATT to Advertising
The logic for choosing to relay from the GATT bearer to the
advertising bearer was still buggy. This patch refactors the logic to
a separate helper function to make it clearer.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 13:52:10 +02:00
Johan Hedberg 7d7121b1ee Bluetooth: Mesh: Fix copy-paste mistake in log message
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 13:36:31 +02:00
Johan Hedberg dd839d90ac Bluetooth: Mesh: shell: Fix AppKey Add command handler
The command handler already has support for decoding from hex, however
it was not using the decoded value when calling the client API.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 13:36:31 +02:00
Johan Hedberg 39298cf3c5 Bluetooth: Mesh: Fix format specifier for s32_t
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 13:36:31 +02:00
Johan Hedberg c0b5a91588 Bluetooth: Mesh: Fix using the correct transmit state
If relaying is not supported, or disabled, the Relay Transmit state
will normally be 0, which is not what we want to use when proxying out
packets from GATT clients. The bt_mesh_net_relay() function is also
used for sending out locally originated packets, in which case the
Relay Retransmit state is also the wrong one to use (the Network
Transmit state should be used instead).

This patch makes sure we only use the Relay Retransmit state for
packets originating from the advertising bearer, and for all other
packets use the Network Transmit state.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 11:13:31 +02:00
Johan Hedberg 4871d8567b Bluetooth: Mesh: Fix relaying conditions for Adv & GATT bearers
The bt_mesh_net_relay() function was missing several important checks
for whether a PDU should be relayed or not. In particular, it would
relay a packet from adv to adv even if the Relay state was set to
disabled, as long as GATT Proxy was set to enabled. The code would
also relay packets to the GATT Proxy bearer if the Relay state was set
to enabled but GATT Proxy was set to disabled. This patch addresses
both of these issues.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 11:13:31 +02:00
Johan Hedberg ad6f9b15e6 Bluetooth: Mesh: Fix changing Relay state from Not Supported (0x02)
If the Relay state is set to Not Supported (0x02) the Config Relay Set
message should not change the state, rather just return its current
value.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 11:13:31 +02:00
Johan Hedberg 967d8b5b59 Bluetooth: Mesh: Fix beacon cache handling
The beacon cache handling was severely broken in the way that the
cache_add() function was incorrectly mapping net_idx to array index,
which could have lead to array overflows.

To fix this, while also cleaning things up, move the cache to the
actual bt_mesh_subnet struct. This e.g. lets us avoid having to track
the net_idx twice.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-01 12:28:56 +02:00
Johan Hedberg a3448aba9f Bluetooth: Mesh: Fix setting an upper limit on beacon interval
https://www.bluetooth.org/errata/errata_view.cfm?errata_id=9807

"If the computed Beacon Interval is less than 10 seconds, it should be
set to 10 seconds. If the computed Beacon Interval is greater than 600
seconds, it should be set to 600 seconds."

The lower limit is already covered by how frequently the delayed work
callback gets called, so we just need enforce the 600 second maximum.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-01 12:28:56 +02:00
Johan Hedberg 77ca943fd5 Bluetooth: Mesh: Fix sending beacons to Friend Queue & GATT clients
Whenever there's a security change (Key Refresh or IV Update) we
should immediately send beacons to any Friend Queues or connected GATT
clients. Introduce a helper function to do this, and make sure it's
called from all places that change the Key Refresh or IV Update
states.

This fixes test case MESH/SR/PROX/PB-12-C.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-30 19:29:15 +02:00
Johan Hedberg 8f2a7f2d46 Bluetooth: Mesh: Fix logging mesh addresses
Addresses are 16-bit and not 8-bit.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-30 19:29:15 +02:00
Johan Hedberg 1210258603 Bluetooth: Mesh: Clearly document the magic 18 byte minimum length
This makes it clear why 18 is a valid minimum network PDU length to
enforce. This is particularly important since as of writing this patch
there's at least one PTS test case which sends too small PDUs, which
could potentially lead to people thinking the implementation is at
fault (it's not).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-30 14:58:09 +02:00
Johan Hedberg 6078f8acc2 Bluetooth: Mesh: Introduce API for clearing the RPL
Some Transport Layer tests (MESH/NODE/TNPT/BV-13-C in particular)
require manual clearing of the RPL. Introduce an API for it as well as
a command to the mesh shell to call the API.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-29 13:49:45 +02:00
Johan Hedberg 3222662553 Bluetooth: Mesh: Fix Replay Protection List checking
If we the stored RPL entry was for an old IV Index, and the received
PDU is for a new IV Index we should not be comparing the sequence
number (as it's by definition always greater than the old one).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-29 13:49:45 +02:00
Johan Hedberg 859afbf39b Bluetooth: Mesh: Fix disconnecting clients when disabling GATT Proxy
Section 4.2.11 of the Mesh Profile Specification 1.0 states:

"Upon transition from GATT Proxy state 0x01 to GATT Proxy state 0x00
the GATT Bearer Server shall disconnect all GATT Bearer Clients."

This also makes test case MESH/SR/MPXS/BV-08-C pass.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-29 13:05:34 +02:00
Johan Hedberg 90ea44cc4b Bluetooth: Mesh: Fix initializing Node ID start time
The bt_mesh_proxy_identity_enable() function was missing a line to
properly initialize the start time for Node Identity advertising.
Without it this public function wouldn't work as intended.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-29 13:05:34 +02:00
Johan Hedberg 012e763311 Bluetooth: Mesh: Fix GATT Proxy Service CCC read permissions
Test case MESH/SR/MPXS/BV-04-C requires the Proxy Service CCC to have
read permissions in order to pass.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-29 13:05:34 +02:00
Johan Hedberg ff7d5ca910 Bluetooth: Mesh: Fix GATT Proxy & Node Identity state binding
Section 4.2.11.1 of the Mesh Profile specification 1.0 states:

"When the GATT Proxy state is set to 0x00, the Node Identity state for
all subnets shall be set to 0x00 and shall not be changed."

When the proxy state has been changed we also need to wake up the
advertising module to make sure we do the right kind of advertising.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-29 13:05:34 +02:00
Johan Hedberg 84409d0161 Bluetooth: Mesh: Deliver TTL=1 PDUs only to the local net interface
Section 3.4.5.2 in the Mesh Profile Specification (1.0) states:

"The output filter of the interface connected to advertising or GATT
bearers shall drop all messages with TTL value set to 1."

Also: https://www.bluetooth.org/errata/errata_view.cfm?errata_id=9811

Note that this is specifically 1 and not 0, since e.g. Friend PDUs
always go out with TTL 0.

Another noteworthy thing is that the way this has to be implemented is
slightly contrary to how it's presented in the specification (both in
the text as well as the Message processing flow diagram in section
3.11. If this was implemented following the spec to its word, then any
PDU received over GATT or Advertising with TTL 2 would never be
relayed (since the TTL would be 1 when the PDU gets rerouted back to
the bearer). This would be both counterintuitive to the intended
purpose of the TTL, and would also be contrary to the test
specification (see Test Procedure step 1 in MESH/NODE/RLY/BV-01-C).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-29 13:05:34 +02:00
Johan Hedberg bed5472cab Bluetooth: Mesh: Remove unnecessary variable
Most places in bt_mesh_friend_req() used rx->sub (which is already
quite short in itself), so just remove the only remaining user and the
helper variable itself.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-29 13:05:34 +02:00
Vakul Garg 26f43950f2 net: pkt: Corrected data length appended in net_pkt_append()
The maximum data length that can be appended using net_pkt_append()
should be set to TCP send_mss only if it is smaller than allowed
payload length in net_pkt.

Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
2017-11-28 12:30:01 -05:00
Vakul Garg 687bd0d710 net: pkt: Account for IP header length for allowable payload data
For calculating amount of payload data that can be added in a packet,
we need to subtract IPv6 or IPv4 header lengths from MTU.

Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
2017-11-28 12:30:01 -05:00
Ding Tao 6caf6964cd net: pkt: Fix possible division by zero
When net debugging is enabled, the count variable is initialized to -1.
This may cause division by zero if there is only one fragment in pkt.
Solve this by setting the count to 0 and checking the value before the
print at the end of the function.

Successfully tested on STM32F407 SoC.

Signed-off-by: Ding Tao <miyatsu@qq.com>
2017-11-28 12:28:10 -05:00
Johan Hedberg c393bfd8e3 Bluetooth: Mesh: Fix Friend messaging state tracking
There were several issues with the code:

 - queue_size wasn't properly kept up to date, leading to erroneous
   buffer discarding logic.

 - Poll timeout when there were buffers in the Friend Queue didn't
   work because we didn't track if there'd been a preceding request
   for messages or not (hence the added pending_req variable).

 - We would overwrite the recv_delay timer if there was another
   request while the previous one was still sending (a likely scenario
   if we send out multiple advertising events per packet).

 - We weren't canceling the sending of a buffer if the Friendship was
   suddenly cleared.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg 49c5e5546a Bluetooth: Mesh: Log information about the on-behalf-of flag
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg b123799ebe Bluetooth: Mesh: Reduce logging clutter for LPN lookups
The logs for looking up LPNs were spamming the console a bit too much.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg c65d04655d Bluetooth: Mesh: Fix looking up existing friendship contexts
When receiving Friend Offers we should also consider unestablished
contexts, and simply start from the beginning if that happens.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg a9a18cec7b Bluetooth: Mesh: Fix clearing Friend state upon reset
Not clearing the Friend state could risk invalid timers staying
active, etc.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg 2d63f5e480 Bluetooth: Mesh: Fix & clean up Friendship Credential handling
Pass the subnet to some friend_cred_* APIs since it contains all
necessary information for choosing the right keys to generate them
from. Also shorten the API names to avoid awkward line splitting -
these are internal APIs so it's an acceptable compromise. One bug that
this fixes as part of the cleanup is using the right NetKey Index when
clearing Friendship: previously the code was always using the index of
the first subnet, regardless of which subnet the Friendship was based
on.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg e7199060c6 Bluetooth: Mesh: Remove unnecessary logic for key selection
Key Refresh Phase 2 is analogous to the Key Refresh flag being set.
This means that the flag can directly be used as the index to the
new/old key two-element array.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg 46f8c7fb44 Bluetooth: Mesh: Fix clearing network message cache
Since the stack supports runtime reset and reprovisioning, we need to
clear the network message cache whenever creating a new mesh network.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg 48e6bfaaa7 Bluetooth: Mesh: Fix proxy advertising handling
Remove inconsistent and sometimes unreliable tracking of what
advertising parameters should be used and when the Node Identity
advertising started. The main change that facilitates this is to have
the Node ID start timestamp as part of the mesh subnet context.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg bdcf8c3692 Bluetooth: Mesh: Use 32-bit math for Node ID duration
The Node Identity duration is at most 60 seconds, so it's safe to use
32-bit timestamps.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg 7909c3d3fa Bluetooth: Mesh: Introduce option for Node ID timeout
Some PTS test cases only work when we're advertising using Network
Identity. Using the default timeout of 60 seconds for Node Identity
will cause this test cases to fail (i.e. the PTS gives up before
Zephyr transitions to advertising from Node Identity to Network
Identity).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg 699a7c9e85 Bluetooth: Mesh: shell: Fix parsing "boolean" parameters
The shell was being inconsistent in its parsing of boolean parameters.
Some commands were documented as accepting "on" but were actually
parsing the parameter with strtoul() which would result in 0.
Introduce a new helper to convert a string to a u8_t which still
accepts "on" or "enable". This gives us full flexibility of having a
simple interface to the user, but still allowing non-boolean values to
be tested (since on-air the value is a full octet).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg f81b23a624 Bluetooth: Mesh: shell: Add command for setting the UUID
Instead of having a hard-coded UUID, introduce a command to change it.
This is particularly useful if there are many unprovisioned nodes
around.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Johan Hedberg 4c180d6fbf Bluetooth: Mesh: shell: Make Static OOB optional
Having the Static OOB value set up-front can be confusing to the user
since they will not know what the value is. Start off by having it
unset, but introduce a new command using which the user can either set
or clear it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-28 17:17:48 +02:00
Anas Nashif 1092a25978 kconfig: move GDB_INFO kconfig to subsys/debug
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-11-27 22:15:30 -05:00
Vinayak Kariappa Chettimada b022f72cf4 Bluetooth: shell: Fix compile error due to missing memq.h include
Fixes the following compile error when building
tests/bluetooth/shell application:

In file included from subsys/bluetooth/shell/ticker.c:16:0:
subsys/bluetooth/shell/../controller/util/mayfly.h:21:2:
error: unknown type name 'memq_link_t'
  memq_link_t *_link;
  ^~~~~~~~~~~

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-11-27 13:48:24 -08:00
Johan Hedberg f20afb7473 Bluetooth: Mesh: Restrict scope of variables in health_get_registered()
Don't declare the variables in a wider scope than what they're needed
for.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-27 12:10:49 +02:00
Johan Hedberg c2fd67699d Bluetooth: Mesh: shell: Fix sending health publication
We need to send out a Health Fault Current Status (the Health Model's
publication message) when all faults are cleared. The logic for
calculating number of faults was also wrong after the updated model
publication API.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-27 12:10:49 +02:00
Johan Hedberg 8a13066a4e Bluetooth: Mesh: shell: Fix health publication message size
The Health Current Fault message size was being set too small to fit
any faults. Use a macro to make sure the size gets applied in both
places where appropriate.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-27 12:10:49 +02:00
Vakul Garg d5134d9bf3 Bluetooth: Added missing checks for whether CONFIG_BT_PRIVACY is enabled
Fixes error encountered during connecting BLE endpoint.
[bt] [ERR] le_remote_feat_complete: Unable to lookup conn for handle 32

This is to work around a buggy controller that states support for
enhanced privacy, but misbehaves when it's enabled. This change
makes it possible to ensure the host doesn't try to enable the enhanced
event by simply disabling the privacy feature in Kconfig.

Signed-off-by: Vakul Garg <vakul.garg@nxp.com>
2017-11-27 11:30:00 +02:00
Johan Hedberg d0826f3392 Bluetooth: Mesh: Fix NetKey Update behavior in Phase 1
If we get a different key value in Phase 1 we should return the same
"Cannot Update" error as in phases 2 and 3. This fixes test case
MESH/NODE/KR/BI-02-C.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-27 10:17:54 +02:00
Johan Hedberg 48aecd1513 Bluetooth: Mesh: Add IV Update test mode API
This makes it possible to pass all IV Update tests without having to
build a custom configuration for some of the tests. We also disable
the feature in all sample configurations, but leave it on in the
tests.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-27 10:17:54 +02:00
Johan Hedberg a41449ef2a Bluetooth: Mesh: shell: Add iv-update command
This command is needed to pass some IV Update-related PTS tests.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-27 10:17:54 +02:00
Johan Hedberg 6e2a3863ac Bluetooth: Mesh: Fix creating initial beacon data
There was a chance that initial beacons for subnets would be sent with
uninitialized data. Make sure we initialize the beacon data each time
when we create a new subnet.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-27 10:17:42 +02:00
Johan Hedberg a48724fd0f Bluetooth: Mesh: shell: Fix & clean up command help
Use NULL instead of "", fix typos, and indicate app-key-add last
parameter as optional (to match the command implementation).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-24 17:12:20 +02:00
Johan Hedberg 35fd523b03 Bluetooth: Mesh: Add support for manipulating Label UUIDs
Add support for sending messages that add, delete or overwrite Label
UUIDs, and add commands for these to the shell. With the help of these
commands it's possible to pass Transport Layer PTS tests (in
particular TNPT/BV-05-C) by manually adding a Label UUID through
module subscription, since the test case itself does not do this.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-24 17:12:20 +02:00
Johan Hedberg 23ffed0511 Bluetooth: Mesh: Improve logging related to Label UUID lookups
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-24 17:12:20 +02:00