Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iotivity-lite
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
41
Issues
41
List
Boards
Labels
Service Desk
Milestones
Merge Requests
10
Merge Requests
10
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
IoTivity
iotivity-lite
Commits
e47f40d0
Commit
e47f40d0
authored
Feb 06, 2020
by
Kishen Maloor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle default if/if query in Collection Observes
Signed-off-by:
Kishen Maloor
<
kishen.maloor@intel.com
>
parent
caaf9b2b
Pipeline
#277
passed with stage
in 49 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
12 deletions
+50
-12
api/oc_ri.c
api/oc_ri.c
+8
-7
messaging/coap/observe.c
messaging/coap/observe.c
+42
-5
No files found.
api/oc_ri.c
View file @
e47f40d0
...
...
@@ -682,7 +682,7 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
request_obj
.
origin
=
endpoint
;
/* Initialize OCF interface selector. */
oc_interface_mask_t
iface_mask
=
0
;
oc_interface_mask_t
iface_
query
=
0
,
iface_
mask
=
0
;
/* Obtain request uri from the CoAP packet. */
const
char
*
uri_path
;
...
...
@@ -701,7 +701,7 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
int
if_len
=
oc_ri_get_query_value
(
uri_query
,
(
int
)
uri_query_len
,
"if"
,
&
iface
);
if
(
if_len
!=
-
1
)
{
iface_
mask
|=
oc_ri_get_interface_mask
(
iface
,
(
size_t
)
if_len
);
iface_
query
|=
oc_ri_get_interface_mask
(
iface
,
(
size_t
)
if_len
);
}
}
...
...
@@ -792,6 +792,7 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
if
(
cur_resource
)
{
/* If there was no interface selection, pick the "default interface". */
iface_mask
=
iface_query
;
if
(
iface_mask
==
0
)
iface_mask
=
cur_resource
->
default_interface
;
...
...
@@ -949,10 +950,10 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
if
(
observe
==
0
)
{
#ifdef OC_BLOCK_WISE
if
(
coap_observe_handler
(
request
,
response
,
cur_resource
,
block2_size
,
endpoint
,
iface_
mask
)
>=
0
)
{
endpoint
,
iface_
query
)
>=
0
)
{
#else
/* OC_BLOCK_WISE */
if
(
coap_observe_handler
(
request
,
response
,
cur_resource
,
endpoint
,
iface_
mask
)
>=
0
)
{
iface_
query
)
>=
0
)
{
#endif
/* !OC_BLOCK_WISE */
/* If the resource is marked as periodic observable it means
* it must be polled internally for updates (which would lead to
...
...
@@ -983,7 +984,7 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
}
#endif
/* OC_SECURITY */
if
(
set_observe_option
)
{
if
(
iface_
mask
==
OC_IF_B
)
{
if
(
iface_
query
==
OC_IF_B
)
{
links
=
(
oc_link_t
*
)
oc_list_head
(
collection
->
links
);
while
(
links
)
{
if
(
links
->
resource
&&
...
...
@@ -1011,10 +1012,10 @@ oc_ri_invoke_coap_entity_handler(void *request, void *response, uint8_t *buffer,
else
if
(
observe
==
1
)
{
#ifdef OC_BLOCK_WISE
if
(
coap_observe_handler
(
request
,
response
,
cur_resource
,
block2_size
,
endpoint
,
iface_
mask
)
>
0
)
{
endpoint
,
iface_
query
)
>
0
)
{
#else
/* OC_BLOCK_WISE */
if
(
coap_observe_handler
(
request
,
response
,
cur_resource
,
endpoint
,
iface_
mask
)
>
0
)
{
iface_
query
)
>
0
)
{
#endif
/* !OC_BLOCK_WISE */
if
(
cur_resource
->
properties
&
OC_PERIODIC
)
{
remove_periodic_observe_callback
(
cur_resource
);
...
...
messaging/coap/observe.c
View file @
e47f40d0
...
...
@@ -153,6 +153,32 @@ add_observer(oc_resource_t *resource, oc_endpoint_t *endpoint,
/*---------------------------------------------------------------------------*/
/*- Removal -----------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
static
const
char
*
get_iface_query
(
oc_interface_mask_t
iface_mask
)
{
switch
(
iface_mask
)
{
case
OC_IF_BASELINE
:
return
"if=oic.if.baseline"
;
case
OC_IF_LL
:
return
"if=oic.if.ll"
;
case
OC_IF_B
:
return
"if=oic.if.b"
;
case
OC_IF_R
:
return
"if=oic.if.r"
;
case
OC_IF_RW
:
return
"if=oic.if.rw"
;
case
OC_IF_A
:
return
"if=oic.if.a"
;
case
OC_IF_S
:
return
"if=oic.if.s"
;
case
OC_IF_CREATE
:
return
"if=oic.if.create"
;
default:
break
;
}
return
NULL
;
}
void
coap_remove_observer
(
coap_observer_t
*
o
)
{
...
...
@@ -160,9 +186,11 @@ coap_remove_observer(coap_observer_t *o)
o
->
token
[
0
],
o
->
token
[
1
]);
#ifdef OC_BLOCK_WISE
const
char
*
query
=
get_iface_query
(
o
->
iface_mask
);
oc_blockwise_state_t
*
response_state
=
oc_blockwise_find_response_buffer
(
oc_string
(
o
->
resource
->
uri
)
+
1
,
oc_string_len
(
o
->
resource
->
uri
)
-
1
,
&
o
->
endpoint
,
OC_GET
,
NULL
,
0
,
OC_BLOCKWISE_SERVER
);
&
o
->
endpoint
,
OC_GET
,
query
,
(
query
)
?
strlen
(
query
)
:
0
,
OC_BLOCKWISE_SERVER
);
if
(
response_state
)
{
response_state
->
ref_count
=
0
;
}
...
...
@@ -285,10 +313,15 @@ coap_notify_collection_observers(oc_resource_t *resource,
/* iterate over observers */
for
(
obs
=
(
coap_observer_t
*
)
oc_list_head
(
observers_list
);
obs
;
obs
=
obs
->
next
)
{
if
(
obs
->
resource
!=
resource
||
obs
->
iface_mask
!=
iface_mask
)
{
if
(
obs
->
resource
!=
resource
)
{
continue
;
}
OC_DBG
(
"coap_notify_collections: notifying observer"
);
if
(
obs
->
iface_mask
!=
iface_mask
)
{
if
((
obs
->
iface_mask
|
iface_mask
)
!=
OC_IF_LL
)
{
continue
;
}
}
OC_DBG
(
"coap_notify_collection_observers: notifying observer"
);
coap_transaction_t
*
transaction
=
NULL
;
coap_packet_t
notification
[
1
];
...
...
@@ -309,10 +342,11 @@ coap_notify_collection_observers(oc_resource_t *resource,
if
(
response_buf
->
response_length
>
obs
->
block2_size
)
{
#endif
/* !OC_TCP */
notification
->
type
=
COAP_TYPE_CON
;
const
char
*
query
=
get_iface_query
(
obs
->
iface_mask
);
response_state
=
oc_blockwise_find_response_buffer
(
oc_string
(
obs
->
resource
->
uri
)
+
1
,
oc_string_len
(
obs
->
resource
->
uri
)
-
1
,
&
obs
->
endpoint
,
OC_GET
,
NULL
,
0
,
OC_BLOCKWISE_SERVER
);
oc_string_len
(
obs
->
resource
->
uri
)
-
1
,
&
obs
->
endpoint
,
OC_GET
,
query
,
(
query
)
?
strlen
(
query
)
:
0
,
OC_BLOCKWISE_SERVER
);
if
(
response_state
)
{
if
(
response_state
->
payload_size
==
response_state
->
next_block_offset
)
{
oc_blockwise_free_response_buffer
(
response_state
);
...
...
@@ -330,6 +364,9 @@ coap_notify_collection_observers(oc_resource_t *resource,
goto
leave_notify_collections
;
}
if
(
query
)
{
oc_new_string
(
&
response_state
->
uri_query
,
query
,
strlen
(
query
));
}
memcpy
(
response_state
->
buffer
,
response_buf
->
buffer
,
response_buf
->
response_length
);
response_state
->
payload_size
=
response_buf
->
response_length
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment