platform/upstream/bluez.git
3 years agomesh: Refactor heartbeat pub/sub
Inga Stotland [Fri, 7 Aug 2020 01:38:34 +0000 (18:38 -0700)]
mesh: Refactor heartbeat pub/sub

Move heartbeat publication/subscription timers and housekeeping
to net.c since this is where the trigger events and control messages
are handled. Configuration server (cfgmod-server.c) stays
responsible for parsing the set pub/sub message parameters and
assemblying the pub/sub status messages.

Also, make sure that the correct message status is reported.

Change-Id: I3243b98a1f970717b7c48d6a3bbe0344e24fb1ac
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config KR phase messages
Inga Stotland [Fri, 7 Aug 2020 01:38:33 +0000 (18:38 -0700)]
mesh: Clean up handling of config KR phase messages

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Also, this checks for the correct relationship between KR transition
and KR phase values. Correct error codes are sent on unsuccessful
requests and malformed requests are ignored.

Change-Id: I5fa1f9e4d33c99cf5a5788d924951dcf2d1241c2
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config net transmit messages
Inga Stotland [Fri, 7 Aug 2020 01:38:32 +0000 (18:38 -0700)]
mesh: Clean up handling of config net transmit messages

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Change-Id: Idb6fded370e1145fbcc304dba05cfeb324aa813a
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config poll timeout message
Inga Stotland [Fri, 7 Aug 2020 01:38:31 +0000 (18:38 -0700)]
mesh: Clean up handling of config poll timeout message

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Change-Id: I0d04b74c9619e53319f1443a4c331ec33d40ef18
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config relay messages
Inga Stotland [Fri, 7 Aug 2020 01:38:30 +0000 (18:38 -0700)]
mesh: Clean up handling of config relay messages

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Change-Id: I41fca45bc147f8483c9cb0be17976bed5b5eebf1
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config net and app key messages
Inga Stotland [Fri, 7 Aug 2020 01:38:29 +0000 (18:38 -0700)]
mesh: Clean up handling of config net and app key messages

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Change-Id: If73686f788afbcbc0988faaa8631469474280c94
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config publication messages
Inga Stotland [Fri, 7 Aug 2020 01:38:28 +0000 (18:38 -0700)]
mesh: Clean up handling of config publication messages

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Also, return Feature Not Supported errror code when credential
flag is set, but the node does not support LPN feature

Change-Id: I5f18606fa1bcb959fbb62247834a53bb9e193d05
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config node identity message
Inga Stotland [Fri, 7 Aug 2020 01:38:27 +0000 (18:38 -0700)]
mesh: Clean up handling of config node identity message

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Change-Id: I8e60fab5765702d588714462afc993cebe11483c
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config model binding messages
Inga Stotland [Fri, 7 Aug 2020 01:38:26 +0000 (18:38 -0700)]
mesh: Clean up handling of config model binding messages

This modification allows using a single point for sending out
the composed status messages by the Config Server.

Also, remove unused definitions for binding functions in node.h

Change-Id: I65253b2ba3d31dec2a361e24978b0548823ab402
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up handling of config subscription messages
Inga Stotland [Fri, 7 Aug 2020 01:38:25 +0000 (18:38 -0700)]
mesh: Clean up handling of config subscription messages

This provides better functional grouping based on whether a group or
a virtual label is used for the subscription address.

Also, use a single point for sending out the composed Config Server
status messages.

Change-Id: I22edc58fa0d3c26bfd70dc66b521e74335a5bc7d
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Use correct TTL value to send model publication
Inga Stotland [Thu, 6 Aug 2020 22:55:23 +0000 (15:55 -0700)]
mesh: Use correct TTL value to send model publication

When sending model publishing data, use TTL value configured for
that publication instead of the default TTL value used for regular
messages.

Change-Id: I0ddf7ed197e807407ca13402a70af2f9c1dfcd54
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Allow deleting non-existing net key
Michał Lowas-Rzechonek [Thu, 6 Aug 2020 14:21:08 +0000 (16:21 +0200)]
mesh: Allow deleting non-existing net key

When deleting a non-existing key, first check that it doesn't exist (and
return success), then verify it's not the last key we have.

Change-Id: I70f686bb3ab175270d6d4cb4059d7408ff34ec49
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Allow deleting non-existing app key
Michał Lowas-Rzechonek [Thu, 6 Aug 2020 14:13:09 +0000 (16:13 +0200)]
mesh: Allow deleting non-existing app key

Mesh Profile v1.0.1, section 4.3.2.40 Config AppKey Status

(...) The Status Code shall be Success if the received request was
redundant (add of an identical existing key, update of an identical
updated key, or delete of a non-existent key), with no further action
taken.

Change-Id: Ib85ca021261c77b49a5d9d6bc3ee7f2955e8b9b5
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Add strings for SIG Model IDs
Michael N. Moran [Tue, 4 Aug 2020 15:54:04 +0000 (11:54 -0400)]
mesh: Add strings for SIG Model IDs

Change-Id: I8619d949b26903fcd242044c846af4ceadc334b6
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix calculation of model publication period
Inga Stotland [Tue, 28 Jul 2020 18:10:51 +0000 (11:10 -0700)]
mesh: Fix calculation of model publication period

This fixes the extraction of bit fields from model publication
period octet received as part of Congif Publication Set message.

The step resolution field is extracted as upper 2 bits (shift by 6)
and the number of steps field is extracted by masking lower 6 bits.

Change-Id: I198e44cddc517359e7ae17c1dd657f7f6003faec
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Add guard against wedging outbound queue
Brian Gix [Wed, 29 Jul 2020 00:24:49 +0000 (17:24 -0700)]
mesh: Add guard against wedging outbound queue

When using HCI command chains, the first packet send that starts an
outbound sequence needs to still exist when command chain completes, or
the outbound queue will wedge.  The simplest solution is to send packets
at least twice on an empty queue, if there is a chance it could be canceled.

Change-Id: I883422c7143d71fe8309604dd487095de6703f9f
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Move model functionality out of node.c to model.c
Inga Stotland [Thu, 23 Jul 2020 22:00:21 +0000 (15:00 -0700)]
mesh: Move model functionality out of node.c to model.c

This moves the model related code out of node.c to model.c providing
for better functional separation of modules.

Also, use the value of 0xFFFF for internal representation of vendor ID
for BT SIG defined models. This allows to maintain a single internal
vendor ID / model ID space.

Change-Id: I64c18e37a66987ba4d8ef1b3ce5fe2a1e8fcb58c
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix memory leak on provisioning timeout
Brian Gix [Tue, 21 Jul 2020 19:44:38 +0000 (12:44 -0700)]
mesh: Fix memory leak on provisioning timeout

If the Provision Acceptor times out without completing successfully, the
timer it was using was never freed.

Change-Id: I9ca97162dd8b9951568615d99f1f150752497952
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agotools/mesh-cfgclient: Fix segfault on remote node reset
Inga Stotland [Mon, 20 Jul 2020 20:42:06 +0000 (13:42 -0700)]
tools/mesh-cfgclient: Fix segfault on remote node reset

This fixes a segfault that is caused by freeeing non-allocated memory.
Happens upon the removal of a remote node when remote's net key and/or
app key queues are destroyed.

__GI___libc_free (mem=0x1) at malloc.c:3102
    destroy=destroy@entry=0x55761f63a3b0 <l_free>) at ell/queue.c:107
    destroy=destroy@entry=0x55761f63a3b0 <l_free>) at ell/queue.c:82
    at tools/mesh/remote.c:140
    at tools/mesh/cfgcli.c:764
    at tools/mesh/cfgcli.c:764
    msg=0x5576213aa6f0, user_data=<optimized out>)
    at tools/mesh-cfgclient.c:1522
    dbus=dbus@entry=0x55762132f860, message=message@entry=0x5576213aa6f0)
    at ell/dbus-service.c:1793
    user_data=0x55762132f860) at ell/dbus.c:285
    user_data=0x55762132f940) at ell/io.c:126

Change-Id: Ieaddbc0863f83780f3f3166e1665c553c8ae9b0f
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Add size checks for every opcode in config server
Inga Stotland [Mon, 13 Jul 2020 23:05:27 +0000 (16:05 -0700)]
mesh: Add size checks for every opcode in config server

This adds missing size checks for the incoming config server messages.

Change-Id: I0632200ec4b9d168f68ef99ba86247eba621c02e
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Use static array to hold config server response
Inga Stotland [Mon, 13 Jul 2020 23:05:26 +0000 (16:05 -0700)]
mesh: Use static array to hold config server response

This eliminates dynamic allocation for long responses and local
arrays for short responses. Instead, aclear text response from
config server is written into a static buffer and then encoded
into dynamically allocated messafe buffer to use in actual
transmission.

Change-Id: Ia4de6dc44cf1c3781521eeacf2b1e793ac30007c
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix node composition change detection
Brian Gix [Wed, 15 Jul 2020 15:30:49 +0000 (08:30 -0700)]
mesh: Fix node composition change detection

This fixes a bug that caused disallowed composition changes from being
detected and rejected. The only fields that are allowed to freely change
are CID, PID, VID and CRPL.

Change-Id: I147eab5fac9f20b5d3cf2ef161776cc385fd470d
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agotools/mesh: Get rid of "unreliable opcodes" in models
Inga Stotland [Tue, 7 Jul 2020 16:44:39 +0000 (09:44 -0700)]
tools/mesh: Get rid of "unreliable opcodes" in models

This removes an old notion of unreliable opcodes in models , i.e.,
a correctly formatted acknowledged message always gets a response.

Change-Id: I9d6702927addac5a8ad25728046ea2d741f2022e
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Get rid of "unreliable opcodes" in config server
Inga Stotland [Tue, 7 Jul 2020 16:44:38 +0000 (09:44 -0700)]
mesh: Get rid of "unreliable opcodes" in config server

This removes an old notion of unreliable opcodes in config server
model , i.e., a correctly formatted acknowledged message always
gets a response.

Change-Id: Ibf3597971c2392b2bbe9ab79feb8ed46019b93e1
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Add Composition page storage to node.json
Brian Gix [Fri, 3 Jul 2020 21:51:49 +0000 (14:51 -0700)]
mesh: Add Composition page storage to node.json

Mesh supports multiple Composition Pages, although only one is defined
in the current specification. This change allows saving and retrieval of
any pages, numbered 0-255.

Change-Id: I8d1d20ac9221ab9ce3465488984a088dc2570641
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix Seg Fault - App unattached IVIndex chg
Brian Gix [Fri, 3 Jul 2020 16:13:19 +0000 (09:13 -0700)]
mesh: Fix Seg Fault - App unattached IVIndex chg

Object path to node interfaces do not exist unless the owning
application is attached.  This caused a Segmentation fault if IVIndex
change was signaled.

Crash output:

mesh/pb-adv.c:send_adv_segs() size: 01, CRC: 3e
mesh/pb-adv.c:pb_adv_packet() Link closed notification: 00
mesh/net.c:update_iv_ivu_state() iv_upd_state = IV_UPD_NORMAL

Program received signal SIGSEGV, Segmentation fault.
0xb6fbc1dc in strlen () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
(gdb) backtrace
0  0xb6fbc1dc in strlen () from /usr/lib/arm-linux-gnueabihf/libarmmem-v7l.so
1  0x00448488 in l_str_hash (p=0x0) at ell/hashmap.c:168
2  0x00448980 in l_hashmap_lookup (hashmap=0x46b550, key=key@entry=0x0) at ell/hashmap.c:487
3  0x00444704 in _dbus_object_tree_property_changed (dbus=0x469438, path=0x0, interface_name=0x44bb74 "org.bluez.mesh.Node1", property_name=0x44aa18 "IVIndex") at ell/dbus-service.c:1196
4  0x0044545c in l_dbus_property_changed (dbus=<optimized out>, path=<optimized out>, interface=<optimized out>, property=<optimized out>) at ell/dbus-service.c:1804
5  0x0041805c in node_property_changed (node=<optimized out>, property=<optimized out>) at mesh/node.c:2392
6  0x0040c690 in update_iv_ivu_state (ivu=false, iv_index=0, net=0x46e240) at mesh/net.c:2569
7  process_beacon (net_ptr=0x46e240, user_data=0xbefff1e4) at mesh/net.c:2610
8  0x00431edc in l_queue_foreach (queue=<optimized out>, function=0x40c468 <process_beacon>, user_data=user_data@entry=0xbefff1e4) at ell/queue.c:441
9  0x0040a848 in beacon_recv (user_data=<optimized out>, info=<optimized out>, data=<optimized out>, len=<optimized out>) at mesh/net.c:2647
10 0x00431edc in l_queue_foreach (queue=<optimized out>, function=0x408bec <process_rx_callbacks>, function@entry=0x15463acd, user_data=user_data@entry=0xbefff230) at ell/queue.c:441
11 0x00409ec0 in process_rx (len=<optimized out>, data=0xbefff297 "+\001", addr=0xbefff258 "\260\362B", instant=4646248, rssi=-78 '\262', pvt=<optimized out>) at mesh/mesh-io-generic.c:121
12 event_adv_report (io=0x46c3c8, size=<optimized out>, buf=0xbefff255) at mesh/mesh-io-generic.c:159
13 event_callback (buf=<optimized out>, size=<optimized out>, user_data=0x46c3c8) at mesh/mesh-io- generic.c:172
14 0x0042ff58 in queue_foreach (queue=0x46d370, function=0x42f2b0 <process_notify>, user_data=user_data@entry= 0xbefff289) at src/shared/queue.c:219
15 0x0042f674 in process_event (size=<optimized out>, data=0xbefff283, hci=0x46c3d8) at src/shared/hci.c:258
16 io_read_callback (io=<optimized out>, user_data=0x46c3d8) at src/shared/hci.c:286
17 0x00432600 in io_callback (fd=<optimized out>, events=1, user_data=0x46d318) at ell/io.c:126
18 0x0043348c in l_main_iterate (timeout=<optimized out>) at ell/main.c:470
19 0x00433554 in l_main_run () at ell/main.c:520
20 l_main_run () at ell/main.c:502
21 0x004337b4 in l_main_run_with_signal (callback=<optimized out>, user_data=0x0) at ell/main.c:642
22 0x00404e90 in main (argc=<optimized out>, argv=<optimized out>) at mesh/main.c:269
(gdb)

Change-Id: I44b6e5d5176700b1e2ce0eb33b8e28255aef1699
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agotest/test-mesh: Add options to "Models" property
Inga Stotland [Tue, 30 Jun 2020 18:56:17 +0000 (11:56 -0700)]
test/test-mesh: Add options to "Models" property

This adds options dictionary to "Models" property to stay
in sync with mesh-api changes.

Change-Id: I10efee164915dcf1867fb939c4a0fd10558e37dd
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agotools/mesh-cfgclient: Add options to "Models" property
Inga Stotland [Tue, 30 Jun 2020 18:56:16 +0000 (11:56 -0700)]
tools/mesh-cfgclient: Add options to "Models" property

This adds options dictionary to "Models" property to stay
in sync with mesh-api changes.

Change-Id: I3fd2828e3c2ff9ddf32e4f45c1db253168497eca
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Check app model settings of pub/sub support
Inga Stotland [Tue, 30 Jun 2020 18:56:15 +0000 (11:56 -0700)]
mesh: Check app model settings of pub/sub support

This adds handling of new options dictionary included with
"Models" and "VendorModels" properties on org.bluez.mesh.Element1
interface.

Supported (optional) dictionary entries:
"Publish" - indicates whether the model supports publication mechanism.
                If not present, publication is enabled.
"Subscribe" - indicates whether the model supports subscription mechanism.
                If not present, subscriptions are enabled.

If a config message related to subscription state is received for a model
that does not support subscription mechanism, an error code 0x08,
("Not A Subscribe Model") is sent in response.

If a config message related to publication state is received for a model
that does not support publication mechanism, an error code 0x07
("Invalid Publish Parameters") is sent in response.

Change-Id: I6365ee91c74bf79cd4950e000ef865c543224136
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agodoc/mesh-api: Add dictionary to model properties
Inga Stotland [Tue, 30 Jun 2020 18:56:14 +0000 (11:56 -0700)]
doc/mesh-api: Add dictionary to model properties

This changes the signature of "Models" and "VendorModels" properties
on org.bluez.mesh.Element1 interface to contain a dictionary with
model options.

Models: signature change "aq" -> "a(qa{sv})"
VendorModels: signature change "a(qq)" -> "a(qqa{sv})"

Currently, the defined keywords for the options dictionary are
"Publish" - indicates whether the model supports publication mechanism.
            If not present, publication is enabled.
"Subscribe" - indicates whether the model supports subscription mechanism.
            If not present, subscriptions are enabled.

The dictionary allowed to be empty.

Change-Id: I7c4bd0f21c1a6c8c3d889b76433ec61ac6081598
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up config model publication set
Inga Stotland [Fri, 26 Jun 2020 21:59:07 +0000 (14:59 -0700)]
mesh: Clean up config model publication set

No functioal changes. Make code more readable, plus style fixes.

Change-Id: I10e04a4cc446145b59c5acc2c8b4bd5896b2afa5
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix memory leak when queuing OB pkts rapidly
Brian Gix [Mon, 22 Jun 2020 18:00:04 +0000 (11:00 -0700)]
mesh: Fix memory leak when queuing OB pkts rapidly

If a new packet for outbound delivery is queued during the last
transmission of the only other packet being sent, the prior
packet got forgotten and leaked. This fix correctly deletes the prior
packet, but also makes sure it is given the proper oportunity for
transmission.

Change-Id: I1e05a8d55f9a8ee92b049be5bbcd24969a1b10d4
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agotools/mesh-cfgclient: add list of blacklisted addresses
Inga Stotland [Fri, 19 Jun 2020 21:26:55 +0000 (14:26 -0700)]
tools/mesh-cfgclient: add list of blacklisted addresses

This adds a concept of "blacklisted" addresses. that a provisioner is
not allowed to assign to newly added mesh nodes.
An address may be "blacklisted" is a node has been removed from the network
(e.g., after node reset procedure). This ensures that the addresses are not
reused for provisioning new nodes to prevent a potential communication
problem due to saved RPL entries associated with these addresses in the
rest of the mesh network. The address is "cleared", when IV index updates
at least twice.

Change-Id: I672c71cd18d6fc987a8ee3f8d27514b752b925e0
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agotools/mesh-cfgclient: get/set IV index
Inga Stotland [Fri, 19 Jun 2020 21:26:54 +0000 (14:26 -0700)]
tools/mesh-cfgclient: get/set IV index

This adds keeping track of IV index changes.
The updates are detected by observing PropertiesChanged signal
on local node's object path and reading "IvIndex" property

Change-Id: I40996e727f9f638e384a7c64d4a9cd606e00511c
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Emit PropertiesChanged when IV Index changes
Inga Stotland [Fri, 19 Jun 2020 21:26:53 +0000 (14:26 -0700)]
mesh: Emit PropertiesChanged when IV Index changes

This adds emitting of PropertiesChanged signal whenever the
mesh IV index is updated to indicate that the vlaues of "IvIndex"
property has been modified.

Change-Id: I7ce2a982348e7ed92185bccd745c9050f778bc11
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Replace BeaconFlags with just IvUpdate
Michał Lowas-Rzechonek [Wed, 17 Jun 2020 20:26:57 +0000 (22:26 +0200)]
mesh: Replace BeaconFlags with just IvUpdate

To import nodes, applications need just IvIndex and IvUpdate. KeyRefresh
phase in under provisioner's control, so we don't need to expose it.

Moreover, BeaconFlags property dealt just with the primary net key, and
each subnet key is refreshed separately.

Change-Id: Ia0f878b4531932fc32ddd490eb4684fcff1c1b93
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Add deferral of Attach() and Leave() if busy
Brian Gix [Tue, 16 Jun 2020 18:14:36 +0000 (11:14 -0700)]
mesh: Add deferral of Attach() and Leave() if busy

We require the successful return of JoinComplete() method before
handling subsequent Attach() or Leave() method calls. To simplify the
construction of Applications, we will accept one of these calls up to 1
second prior to receiving the final return status of JoinComplete,
which tells us that the Application is ready to use the node.

If the node is still not ready after the deferral, Attach and/or Leave
will fail.

Change-Id: I874b8f8243d17f862fbaa0f7b91b7b1fc627c137
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Rename IVUpdate import flag to IvUpdate
Michał Lowas-Rzechonek [Mon, 15 Jun 2020 12:41:08 +0000 (14:41 +0200)]
mesh: Rename IVUpdate import flag to IvUpdate

Name change for consistency with "IvIndex" property.

Change-Id: I7af9b75553a73cb13feee63614a2501a73074513
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Delete unused structures/functions
Inga Stotland [Thu, 11 Jun 2020 18:30:38 +0000 (11:30 -0700)]
mesh: Delete unused structures/functions

This deletes unused functions and structures in net.c & net.h.
Plus, some style cleanup.

Change-Id: Ic03ac2b38811c404579f904c311aba47dec982a1
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix updating CID, PID, VID & CRPL on node attach
Michał Lowas-Rzechonek [Mon, 15 Jun 2020 11:11:52 +0000 (13:11 +0200)]
mesh: Fix updating CID, PID, VID & CRPL on node attach

In 8a382262125787caf38a1f800ec8956a1bf71d85, we wanted to allow the
application to update certain composition fields. This patch makes it
work.

Change-Id: I4323cf58605b0961cb46aba06d4355603f61d2cf
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Add "node is busy" check for Leave() & Attach()
Inga Stotland [Wed, 10 Jun 2020 17:11:21 +0000 (10:11 -0700)]
mesh: Add "node is busy" check for Leave() & Attach()

This introduces the following behavior change for those methods
on Network interface that specify node token as an input parameter

Leave() method:
If Leave method is called for a node that is being processed as a result
of a Create, Import, Join or Attach method calls in progress, node removal
is not allowed and org.bluez.mesh.Error.Busy error is returned.

Attach() method:
If Attach method is called for a node that is being processed as a result
of a Create, Import or Join method calls in progress, node attachment
is not allowed and org.bluez.mesh.Error.Busy error is returned.

Change-Id: I994d81ef27eb6e7e2423a6504fcf3396ea039a15
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Add timeout to GetManagedObjects call
Inga Stotland [Wed, 10 Jun 2020 17:11:20 +0000 (10:11 -0700)]
mesh: Add timeout to GetManagedObjects call

Switch to using dbus_send_with_timeout when making a request
to get managed objects from an application.

Change-Id: I5c95b22e0cafa36133ffb5bff1e76764fb4cf398
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Add destroy callback to dbus_send_with_timeout()
Inga Stotland [Wed, 10 Jun 2020 17:11:19 +0000 (10:11 -0700)]
mesh: Add destroy callback to dbus_send_with_timeout()

This adds a destroy callback as a function parameter to
dbus_send_with_timeout() to allow automatic release of user data
on either reply or timeout.

Change-Id: Id97ac8108066c58130a2c1ee629d197a8ad8cb67
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Make "Busy" and "InProgress" to be distinct errors
Inga Stotland [Wed, 10 Jun 2020 17:11:18 +0000 (10:11 -0700)]
mesh: Make "Busy" and "InProgress" to be distinct errors

This separates "Busy" and "InProgress" error codes:
MESH_ERROR_IN_PROGRESS maps to org.bluez.mesh.Error.InProgress
MESH_ERROR_BUSY maps to org.bluez.mesh.Error.Busy

Minor API change:
UpdateAppKey() returns "InProgress" error instead of "Busy"

Change-Id: I4d30be4542e6f8c5130dab24a056f6a94877da5c
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Delete unused function
Inga Stotland [Wed, 10 Jun 2020 17:11:17 +0000 (10:11 -0700)]
mesh: Delete unused function

This deletes unused function node_is_provisioned()

Change-Id: I5f5b51e411252137fcfc7e3e01f75b6ab979fb0f
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix clean-up introduced bug
Brian Gix [Mon, 8 Jun 2020 23:07:45 +0000 (16:07 -0700)]
mesh: Fix clean-up introduced bug

Before the clean-up we were making a useless check of an otherwise
unused boolean (net->provisioner) to determine if we should decode with
device keys (which was incorrect). This was replaced by a check the
node type (node->provisioner). However, the check was incorrect in the
first place, and prevents provisioner nodes from decrypting non device
key messages.

Change-Id: Ia6c8a52afbfe03599884a29d71003a60231f71cb
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Remove unused/redundant functions
Inga Stotland [Fri, 5 Jun 2020 21:31:43 +0000 (14:31 -0700)]
mesh: Remove unused/redundant functions

This removes mesh_net_provisioner_mode_set (unused) and
mesh_net_provisioner_mode_get (duplicates node_is_provisioner)

Change-Id: I9fe41d0c30828fa4faa4a9757b0c4a5e81146b43
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Fix FPE in overcommit logic.
Michał Lowas-Rzechonek [Tue, 31 Mar 2020 09:04:00 +0000 (11:04 +0200)]
mesh: Fix FPE in overcommit logic.

During overcommit, mesh_config_save is called in asynchronous mode to
avoid blocking Send() calls. This means that update of cfg->write_time
is scheduled via l_idle_oneshot, so if the next Send() gets scheduled
first, the code may see elapsed time of zero.

If this happens, then the overcommit logic was already executed and the
overcommit is pending, so we can just return.

Change-Id: I13bd46cd94e4a415ebcf2a97cff283bab2d635f4
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Remove unused functions from net.c
Inga Stotland [Sun, 31 May 2020 04:41:28 +0000 (21:41 -0700)]
mesh: Remove unused functions from net.c

The folllowing functionsa are not being used anywhere in the code and
have been removed:
mesh_net_flush()
mesh_net_prov_caps_get()
mesh_net_priv_key_get()
mesh_net_priv_key_set()
mesh_net_prov_rand()
mesh_net_prov_uni()
mesh_net_id_uuid_set()
mesh_net_test_addr()
mesh_net_test_mode()
mesh_net_uni_range_set()
mesh_net_uni_range_get()
mesh_net_set_window_accuracy()

Change-Id: Id8226cd2349d4a8b5dbd2e95ff976b5d2c04a692
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Clean up style in net.c
Inga Stotland [Sun, 31 May 2020 04:41:27 +0000 (21:41 -0700)]
mesh: Clean up style in net.c

Change-Id: Iba040f18c86f7d66cdef68ab455e472ef7d13973
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Remove debug-only related callback for packet send
Inga Stotland [Sun, 31 May 2020 04:41:26 +0000 (21:41 -0700)]
mesh: Remove debug-only related callback for packet send

This removes callback for sending every single access layer packet
since the callback does nothing but print debug satement. This
functionality is mature enough not to require such heavy debugging.

Change-Id: I033c970953b21a1f10701d919bc4b2f8789bf86d
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Debug output clean up
Inga Stotland [Sun, 31 May 2020 04:41:25 +0000 (21:41 -0700)]
mesh: Debug output clean up

This changes l_info() to l_debug() for recurring cases and
removes some excessive debug output.

Change-Id: Ic9ff25a75b549a55c273112fe8aec7830aeb64ff
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Helper packet print should depend on debug setting
Inga Stotland [Sun, 31 May 2020 04:41:24 +0000 (21:41 -0700)]
mesh: Helper packet print should depend on debug setting

This changes the utility function print_packet() to check if
daemon is running in debug mode.

Change-Id: Ib23f995a3e89297ad239a4a3557bb6b7600b47ed
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agomesh: Handle close for Acceptor
Prathyusha N [Tue, 24 Mar 2020 19:27:17 +0000 (00:57 +0530)]
mesh: Handle close for Acceptor

Provision complete callback is handled in provision failure case.
If link closed received abruptly with reason success, triggered
provision complete callback. Removed session timeout and session
free as they are handled in pb_adv_unreg.

Change-Id: Ib1ec9d21b2ed848475f79866f8ff2a9aae92cbc3
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
3 years agoAllow AcquireNotify without CCC 67/245367/1 accepted/tizen/unified/20201029.125002 submit/tizen/20201016.014746 submit/tizen/20201027.003129
Wootak Jung [Thu, 8 Oct 2020 00:57:47 +0000 (09:57 +0900)]
Allow AcquireNotify without CCC

This patch fixes this behavior so that AcquireNotify
immediately registers the callback and returns success for
characteristics with no CCC

Change-Id: I4077ec021b52cb88cd302a94b5ceaedf15ab833d
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
3 years agomain: add missing comma after AlwaysPairable 07/244207/1 accepted/tizen/6.0/unified/20201030.105054 accepted/tizen/6.0/unified/hotfix/20201102.235423 accepted/tizen/unified/20200917.033653 submit/tizen/20200916.225437 submit/tizen_6.0/20201029.205501 submit/tizen_6.0_hotfix/20201102.192901 submit/tizen_6.0_hotfix/20201103.115101 tizen_6.0.m2_release
Michael Nosthoff [Fri, 24 Jul 2020 14:03:06 +0000 (16:03 +0200)]
main: add missing comma after AlwaysPairable

Commit 1880b2990866 ("core: Add AlwaysPairable to main.conf") added a new
key to supported_options but didn't add a comma. This leads to the
following error message on startup if the key 'PairableTimeout' is pesent:

Unknown key PairableTimeout for group General in /etc/bluetooth/main.conf

This probably also leads to ignoring the setting.

Fixes: 1880b2990866 ("core: Add AlwaysPairable to main.conf")

Change-Id: I193e6da4956605a932f08d2f4ec3000e23fc2bb5
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
3 years agoDont remove connected device at discovery cleanup 11/244011/1
Anupam Roy [Mon, 14 Sep 2020 05:24:17 +0000 (10:54 +0530)]
Dont remove connected device at discovery cleanup

It is possible that a device is already connected
as a temporary device, using a BLE random address.
In such situation, adapter should not remove that
device during discovry cleanup action.

This patch skips removing device if device is
already connected.

Change-Id: I93dc0003e0b1a6917c6a3d9ebc93f04c89205346
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
3 years agoset_advertising returns in_progress error even if the restart is scheduled by le... 97/242897/1 accepted/tizen/unified/20200904.035416 submit/tizen/20200902.223427
Deokhyun Kim [Tue, 25 Aug 2020 06:44:37 +0000 (15:44 +0900)]
set_advertising returns in_progress error even if the restart is scheduled by le connection.

le_discovering should be set before remove_watch is called

[Model] 5.5
[BinType] AP
[Customer] OPEN

[Issue#] P200824-01952
[Request] PLM
[Occurrence Version] R825USQE1BTH8

[Problem] set_advertising fails
[Cause & Measure] advertising is already stopped by le connection.
  And the restart is scheduled with 300ms delay.
  set_advertising returns in_progress error even if the restart is scheduled
  by le connection.
[Checking Method] Try to stop advertising right after le is connected.

[Team] Bluetooth
[Developer] Deokhyun Kim
[Solution company] Samsung
[Change Type] Specification change

Change-Id: I7fef2e0b5fba1219dfe8f02b223d870450ccb651
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
3 years agoClear le scan resources when it's stopped by kernel 48/241948/1 accepted/tizen/unified/20200826.133056 submit/tizen/20200825.072855
Deokhyun Kim [Fri, 24 Jul 2020 05:06:43 +0000 (14:06 +0900)]
Clear le scan resources when it's stopped by kernel

Change-Id: I76412a0d5c1fa924027c5e96cd0f812bfbb556a6
Signed-off-by: Deokhyun Kim <dukan.kim@samsung.com>
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
3 years agomesh: Add api to release node dbus resources 97/241897/2 accepted/tizen/unified/20200825.142910 submit/tizen/20200821.002054
Anupam Roy [Thu, 20 Aug 2020 15:34:50 +0000 (21:04 +0530)]
mesh: Add api to release node dbus resources

Currently, there is no way to release the node
and attach it back without disconnection of
dbus client. It is possible that dbus client
is owner of multiple mesh nodes and it intends
to stop using one or multiple nodes & re-attach
them back without disconnecting from dbus.

This patch introduces a Release API through which
dbus client can request to release the node's
dbus resources. dbus client can attach the node
after releasing it at any point of time.

Change-Id: I9ffb2588f1c1dc5d2ccbe45ab5c447ed916c593f
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
3 years agomesh: Update capabilities of bluetooth-mesh 10/241110/1 accepted/tizen/unified/20200819.035939 submit/tizen/20200818.003628
Abhay Agarwal [Fri, 14 Aug 2020 16:19:36 +0000 (21:49 +0530)]
mesh: Update capabilities of bluetooth-mesh

This patch updates bluetooth-mesh capabilities to allow network_fw
user to launch bluetooth-mesh daemon on HCI RAW socket.

Change-Id: I009c7356fb34f748e672d715b831c1967bf6aea2
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
3 years agomesh: Add support for meshd to use RAW channel 61/240761/2 accepted/tizen/unified/20200812.143914 submit/tizen/20200811.230110
Abhay Agarwal [Mon, 15 Jun 2020 08:40:47 +0000 (14:10 +0530)]
mesh: Add support for meshd to use RAW channel

This patch adds an option to launch meshd with HCI RAW
channel instead of HCI user channel.
This will enable simultaneous operation of meshd with
bluetoothd when HCI user channel can not be created due
to non-availability of independent HCI controller.

Change-Id: I484c478208376ad0e1f1bd8a7b648494ae3f71fb
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
3 years agoRemove unnecessary dbus config rules 22/239822/1 accepted/tizen/unified/20200803.122026 submit/tizen/20200731.001830
DoHyun Pyun [Thu, 30 Jul 2020 05:21:09 +0000 (14:21 +0900)]
Remove unnecessary dbus config rules

Change-Id: I3292894c38b24c3a1117320d92f83786f7ec3556
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
3 years agoMerge "Revert dbus rule for mesh with send_destination" into tizen
Pyun DoHyun [Wed, 29 Jul 2020 06:52:13 +0000 (06:52 +0000)]
Merge "Revert dbus rule for mesh with send_destination" into tizen

4 years agoMerge "a2dp: Store Delay Reporting capability" into tizen accepted/tizen/unified/20200701.123254 accepted/tizen/unified/20200710.114130 submit/tizen/20200630.223543 submit/tizen/20200708.225225
Pyun DoHyun [Mon, 29 Jun 2020 22:41:15 +0000 (22:41 +0000)]
Merge "a2dp: Store Delay Reporting capability" into tizen

4 years agoa2dp: Store Delay Reporting capability 86/237186/1
Luiz Augusto von Dentz [Mon, 18 May 2020 20:02:03 +0000 (13:02 -0700)]
a2dp: Store Delay Reporting capability

This stores Delay Reporting capability so it is properly restored when
loading from cache.

Change-Id: Iaa25bb13efb2d64f719e7213e13211daabf5f981
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
4 years agoRemove bluez-devel and libbluetooth rpm 00/237100/1 submit/tizen/20200629.225249
DoHyun Pyun [Thu, 25 Jun 2020 01:10:21 +0000 (10:10 +0900)]
Remove bluez-devel and libbluetooth rpm

Bluez testing tools only use libbluetooth.so. So we
don't need to provide it as the developement package.

Change-Id: I47960e8eb3c4bb8137ea4561458714d47ce6302f
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
4 years agoRevert dbus rule for mesh with send_destination 45/236845/1
DoHyun Pyun [Mon, 22 Jun 2020 23:18:16 +0000 (08:18 +0900)]
Revert dbus rule for mesh with send_destination

When we remove the original rules, some method calls
are rejected by 'AccessDenied' error.

Change-Id: Ifc5f04455c412be9da7d94cb5b9a69e8eb412804
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
4 years agoModify mesh dbus configs 57/236257/1 accepted/tizen/unified/20200616.041024 submit/tizen/20200616.024938
DoHyun Pyun [Tue, 16 Jun 2020 03:31:41 +0000 (12:31 +0900)]
Modify mesh dbus configs

To avoid the dbus check error, remove send interface lines

You mustn't use send_interface without send_destination or
send_destination_prefix, unless you limit the rule to only
signals with send_type="signal"

Change-Id: I5960bf0a9a99d745ad4c1c6a175f93e246f0ab14
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
4 years agoModify the security option for bluetooth-meshd 92/235492/1 accepted/tizen/unified/20200610.015556 submit/tizen/20200608.075218
DoHyun Pyun [Fri, 5 Jun 2020 04:53:20 +0000 (13:53 +0900)]
Modify the security option for bluetooth-meshd

Change-Id: I8452eb5b07daa57c60f6bdbdb251781a6855058a
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
4 years agomesh: Destroy PB-ADV queue when provisioning done 26/235126/1 accepted/tizen/unified/20200605.020515 submit/tizen/20200604.003952
Brian Gix [Fri, 22 May 2020 21:07:52 +0000 (14:07 -0700)]
mesh: Destroy PB-ADV queue when provisioning done

Change-Id: I4468a47480bf7653e90d9396627a63acf16f367f
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix leaked message reference 25/235125/1
Brian Gix [Fri, 22 May 2020 19:50:32 +0000 (12:50 -0700)]
mesh: Fix leaked message reference

Change-Id: I5184625d2b6d443f44e6819c64f0b738bfdfa7ee
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix leaked mesh_net allocation 24/235124/1
Brian Gix [Fri, 22 May 2020 19:50:07 +0000 (12:50 -0700)]
mesh: Fix leaked mesh_net allocation

Change-Id: I0eef7ea2f02e0b3263ffd06c181f6895e6f66bb1
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix using uninitialized bytes 23/235123/1
Brian Gix [Fri, 22 May 2020 18:40:40 +0000 (11:40 -0700)]
mesh: Fix using uninitialized bytes

Fixes two problems found with static analysis

Change-Id: I66cef81aad17068d50f182b241b7acc6f0ff73f4
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Clean up Join() method 22/235122/1
Inga Stotland [Fri, 22 May 2020 00:35:01 +0000 (17:35 -0700)]
mesh: Clean up Join() method

This consolidates various places where a pending response
to Join() is created and makes sure that l_dus_message_unref()
is called correctly.

Change-Id: I494c602d206eaf35c9b1603b8b6444a0c30912f7
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix memory leak in Create, Import & Attach methods 21/235121/1
Inga Stotland [Fri, 22 May 2020 00:35:00 +0000 (17:35 -0700)]
mesh: Fix memory leak in Create, Import & Attach methods

This ensures that every time l_dbus_message_ref() is used to preserve
a message for a pending method reply, there is a matching call to
l_dbus_message_unref().

Change-Id: I5c6846f9ab9ca11d23c7729933af0e2945d015c1
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Clean up Attach() method call 20/235120/1
Inga Stotland [Fri, 22 May 2020 00:34:59 +0000 (17:34 -0700)]
mesh: Clean up Attach() method call

This consolidates error return form one place: off a callback
with unsuccessful status.

Change-Id: I3c39a8bb7e6198f730ce8c1a8f7da97e43f65823
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Clean up Import() method call 19/235119/1
Inga Stotland [Fri, 22 May 2020 00:34:58 +0000 (17:34 -0700)]
mesh: Clean up Import() method call

This removes unnecessary failing conditions in Import() call and
simplifies iterations through "flags" dictionary.

Change-Id: I7388fdffc3ba599b626a3c4f362a0869cd5f55c4
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Create a queue of pending requests in mesh_init() 18/235118/1
Inga Stotland [Fri, 22 May 2020 00:34:57 +0000 (17:34 -0700)]
mesh: Create a queue of pending requests in mesh_init()

This removes unnnecessary checking for queue existence every time
either Attach(), Create() or Import() methods are called.

Change-Id: Icb85c67267594b9fa9f6a11c6f00a35eee8f9fc9
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Remove unused function prototypes from node.h 17/235117/1
Inga Stotland [Fri, 22 May 2020 00:34:56 +0000 (17:34 -0700)]
mesh: Remove unused function prototypes from node.h

Change-Id: I69310c1cf2f0dbbe4624505f8ac2b60598db2693
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Add finalization of a newly created node 16/235116/1
Inga Stotland [Fri, 22 May 2020 00:34:55 +0000 (17:34 -0700)]
mesh: Add finalization of a newly created node

When a new node is created as a result of successful completion
of either Join() or Create() or Import() methods and has been
confirmed via successful token delivery to the application,
clean up node's D-Bus resources (application path, element paths, etc)
that have been gathered during the initial GetMAnagedObjects() call.
Also, remove the agent instance associaed with the new node.

These resources will be re-populated after the Attach() call
verifies the node's integrity.

Change-Id: Icaf8b5f6d747cb82ac6443550393dc00d36af2e2
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Remove agent when freeing node's dynamic resources 15/235115/1
Inga Stotland [Fri, 22 May 2020 00:34:54 +0000 (17:34 -0700)]
mesh: Remove agent when freeing node's dynamic resources

This adds clean up of node's agent instance when node's dynamic
resources are freed.

Change-Id: I588153a99aa27284704b849265b9dcc1ebba3cfa
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Free allocated agent in mesh_remove_agent() 14/235114/1
Inga Stotland [Fri, 22 May 2020 00:34:53 +0000 (17:34 -0700)]
mesh: Free allocated agent in mesh_remove_agent()

This adds previously missing call to free memory allocated
for agent structure.

Change-Id: Ibdb5336c5dfd52ad16b2718efea54692be76c72c
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Remove unused structure member 13/235113/1
Inga Stotland [Fri, 22 May 2020 00:34:52 +0000 (17:34 -0700)]
mesh: Remove unused structure member

This removes unused "agent" member from join_data structure.

Change-Id: I58446ca4058a394f3f1a0b4fac6f01be0c0cb3d0
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix double-free 31/234231/1 accepted/tizen/unified/20200529.124353 submit/tizen/20200527.022320
Brian Gix [Wed, 20 May 2020 22:14:38 +0000 (15:14 -0700)]
mesh: Fix double-free

This fixes a double-free error when destroying the NVM storage of a mesh node.
Cleanly handle two distinct scenarios:

1. When the node is being deleted at runtime.  This causes release of
   both dynamic memory and NVM storage.

2. During shutdown, we release dynamic memory only.

Change-Id: Ib69263c627e08f396d2f5dacbc04b4cfe0aace35
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix segfault caused by re-enabling of HCI controller 30/234230/1
Inga Stotland [Fri, 15 May 2020 17:41:56 +0000 (10:41 -0700)]
mesh: Fix segfault caused by re-enabling of HCI controller

This fixes the crash that occurs when a controller used by bluetooth-meshd
is removed and then added back again.

Also, correctly restart scanning when the controller is re-enabled.

Backtrace:
0x00005618e754d040 in ?? ()
0x00005618e6e12d9a in io_ready_callback () at mesh/mesh.c:174
0x00005618e6e3d2c8 in l_queue_foreach () at ell/queue.c:441
0x00005618e6e37927 in request_complete () at src/shared/mgmt.c:261

Change-Id: I360e9b1e4c39898d8b3c695e58f03cb89cf8076e
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix valgrind memory leak warnings 29/234229/1
Brian Gix [Sat, 16 May 2020 01:22:03 +0000 (18:22 -0700)]
mesh: Fix valgrind memory leak warnings

These warnings are caused by not completely freeing memory allocations
at shutdown, and are not serious, but they make valgrind output cleaner.

Change-Id: Ib08bb727fee9ea6dccd5e484bcd5d2f969b80a19
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix valgrind memory leaks 28/234228/1
Brian Gix [Sat, 16 May 2020 01:22:02 +0000 (18:22 -0700)]
mesh: Fix valgrind memory leaks

These memory leaks are ones that will compound over time with node
creation and deletion.

Change-Id: I67f757af13ea4d90676756ee6e1b786cefddef46
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Remove redundant call to save node configuration 27/234227/1
Inga Stotland [Sat, 9 May 2020 00:00:24 +0000 (17:00 -0700)]
mesh: Remove redundant call to save node configuration

This removes a redundant call to save node configuration in
add_local_node(): there is a number of unconditional calls to
mesh_config_write_<some_node_Setting>() within this function
which would result in the node configuration being saved implicitly.

Change-Id: I6ffb8eea7f627c734c2728940f9a24223ad19e8c
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Allow updating CID, PID, VID & CRPL on node attach 26/234226/1
Inga Stotland [Sat, 9 May 2020 00:00:23 +0000 (17:00 -0700)]
mesh: Allow updating CID, PID, VID & CRPL on node attach

This allows to update settings of the following composition fields
when an existing node (application) attaches to the daemon:
Company ID (CID), Product ID (PID), Versioin ID (VID),
CRPL (replay protection depth)

Change-Id: I674c7f04f4d6c11c7b8feaca08fd6b1ccb9af9c6
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Avoid saving duplicate fields in node config 25/234225/1
Inga Stotland [Sat, 9 May 2020 00:00:22 +0000 (17:00 -0700)]
mesh: Avoid saving duplicate fields in node config

This modifies miscellaneous utility functions in mesh-config-json.c:
when writing a new value to a node configuration file, delete
the existing field containing an old value first.

Change-Id: Iaed77e58eb33bbb3193d366ee909c75306ab40fc
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: On node attach, verify element/model composition only 24/234224/1
Inga Stotland [Sat, 9 May 2020 00:00:21 +0000 (17:00 -0700)]
mesh: On node attach, verify element/model composition only

When attaching an existing node, verify only the "elements" part
of device composition, i.e., skip verification of CID/PID/VID, CRPL
and features.

Change-Id: I0cc22ce1fe0128bdbb93abe2811ef5558807b2c4
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotools/mesh-cfgclient: Save node's composition in config 23/234223/1
Inga Stotland [Fri, 8 May 2020 02:45:48 +0000 (19:45 -0700)]
tools/mesh-cfgclient: Save node's composition in config

Store remote node's composition after successful completion
of "composition-get" command (config menu).
Show model IDs when printing node info for "list-nodes" command
(main menu).

Change-Id: I679efd9c7214f2dc1132988395b312178eddf6ea
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotools/mesh-cfgclient: Fix model app list parsing 22/234222/1
Inga Stotland [Wed, 6 May 2020 21:44:49 +0000 (14:44 -0700)]
tools/mesh-cfgclient: Fix model app list parsing

This fixes parsing of Model AppKey List & Vendor Model Appkey List
messages: taking into account the packt that AppKey indices are parked
two in three octets.

Also, when printing key indices, print in both decimal and hexadecimal
formats.

Change-Id: Iad95817a4f2f0789838f6701045959d7597d00c4
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotools/mesh-cfgclient: Fix saving KR phase to config file 21/234221/1
Inga Stotland [Tue, 5 May 2020 17:43:03 +0000 (10:43 -0700)]
tools/mesh-cfgclient: Fix saving KR phase to config file

This eliminates extra write of KR phase when loading keys
from the configuration file on initialization.

Change-Id: If49adbfa1373be304b2a2396d2736a2727d2e8ce
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix publication setup for vendor models 20/234220/1
Inga Stotland [Wed, 29 Apr 2020 20:20:54 +0000 (13:20 -0700)]
mesh: Fix publication setup for vendor models

This fixes model ID generation when processing Config Pub Set
message. Also, cleanup some debug prints.

Change-Id: Ie92943fdc7e33f55b271d56fc06dfcce30cf92ff
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix adding virtual subscription to a vendor model 19/234219/1
Inga Stotland [Wed, 29 Apr 2020 18:05:41 +0000 (11:05 -0700)]
mesh: Fix adding virtual subscription to a vendor model

This fixes a case when a configuration server receives a virtual
subscription add/overwrite command targeting a vendor model.
Correctly set "vendor" argument before trying to save the updated
subscrition to configuration file.

Change-Id: I7ff5ca02e20819b316ef2f3b62e7ff01092d3070
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotest/mesh: Remove Provisioner interface 18/234218/1
Brian Gix [Tue, 21 Apr 2020 20:08:37 +0000 (13:08 -0700)]
test/mesh: Remove Provisioner interface

This change removes the Provisioner Initiator from the python test
script, along with the menu commands for create, scan and add. This
makes it a cleaner Python3 example of a simple On/Off node, and a
fuller featured Provisioner/Config Client still exists in the tools
subdirectory.

Change-Id: I020fd501df2342eac4f8f9bc46de49ec2497a172
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agotest/mesh: Fix token format to use all 16 digits 17/234217/1
Brian Gix [Tue, 21 Apr 2020 16:09:51 +0000 (09:09 -0700)]
test/mesh: Fix token format to use all 16 digits

Change-Id: I15c592d706056406645bfacc0be31b0b96c557d3
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
4 years agomesh: Fix GCC 10.0 warnings 16/234216/1
Brian Gix [Fri, 17 Apr 2020 18:57:21 +0000 (11:57 -0700)]
mesh: Fix GCC 10.0 warnings

Change-Id: I4cb7bdc28d642357131dacff6457cd0aa752ecac
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>