...
 
Commits (6)
......@@ -122,7 +122,8 @@ oc_delete_link(oc_link_t *link)
oc_memb_free(&oc_params_s, p);
p = (oc_link_params_t *)oc_list_pop(link->params);
}
if (link->resource) {
if (oc_ri_is_app_resource_valid(link->resource) ||
oc_check_if_collection(link->resource)) {
link->resource->num_links--;
}
oc_free_string_array(&(link->rel));
......
......@@ -142,6 +142,19 @@ oc_ri_get_app_resources(void)
{
return oc_list_head(app_resources);
}
bool
oc_ri_is_app_resource_valid(oc_resource_t *resource)
{
oc_resource_t *res = oc_ri_get_app_resources();
while (res) {
if (res == resource) {
return true;
}
res = res->next;
}
return false;
}
#endif
int
......
......@@ -126,10 +126,10 @@ display_menu(void)
PRINT("[8] Start OBSERVE resource TCP\n");
PRINT("[9] Stop OBSERVE resource TCP\n");
PRINT("-----------------------------------------------\n");
#ifdef OC_CLOUD
#ifdef OC_TCP
PRINT("[20] Send ping message\n");
PRINT("-----------------------------------------------\n");
#endif /* OC_CLOUD */
#endif /* OC_TCP */
PRINT("[99] Exit\n");
PRINT("################################################\n");
PRINT("\nSelect option: \n");
......@@ -276,7 +276,7 @@ GET_handler(oc_client_response_t *data)
display_menu();
}
#ifdef OC_CLOUD
#ifdef OC_TCP
static void
ping_handler(oc_client_response_t *data)
{
......@@ -310,7 +310,7 @@ cloud_send_ping(void)
pthread_mutex_unlock(&app_sync_lock);
signal_event_loop();
}
#endif /* OC_CLOUD */
#endif /* OC_TCP */
static void
get_resource(bool tcp, bool observe)
......@@ -688,11 +688,11 @@ main(void)
case 9:
stop_observe_resource(true);
break;
#ifdef OC_CLOUD
#ifdef OC_TCP
case 20:
cloud_send_ping();
break;
#endif /* OC_CLOUD */
#endif /* OC_TCP */
case 99:
handle_signal(0);
break;
......
......@@ -7,6 +7,48 @@
"application/json"
],
"paths":{
"/oc/con": {
"get": {
"description": "Resource that allows for Device specific information to be configured.\n",
"parameters": [
{
"$ref": "#/parameters/interface-all"
}
],
"responses": {
"200": {
"description" : "",
"schema": {
"$ref": "#/definitions/Configuration"
}
}
}
},
"post": {
"description": "Update the information about the Device\n",
"parameters": [
{
"$ref": "#/parameters/interface-rw"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ConfigurationUpdate"
}
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/ConfigurationUpdate"
}
}
}
}
},
"/oic/p":{
"get":{
"responses":{
......@@ -324,6 +366,57 @@
}
},
"type":"object"
},
"Configuration": {
"properties": {
"rt": {
"description": "Resource Type of the Resource",
"items": {
"enum": ["oic.wk.con"],
"type": "string",
"maxLength": 64
},
"minItems": 1,
"uniqueItems": true,
"readOnly": true,
"type": "array",
"default": ["oic.wk.con"]
},
"n": {
"type": "string",
"readOnly": true,
"maxLength": 64,
"description": ""
},
"if" : {
"description": "The OCF Interfaces supported by this Resource",
"items": {
"enum": [
"oic.if.baseline",
"oic.if.rw"
],
"type": "string",
"maxLength": 64
},
"minItems": 1,
"uniqueItems": true,
"readOnly": true,
"type": "array"
}
},
"type" : "object",
"required": ["n"]
},
"ConfigurationUpdate" : {
"properties": {
"n": {
"description": "The human friendly name to be set on the Resource, this is also reflected in the same Property in oic.wk.d",
"maxLength": 64,
"type": "string"
}
},
"required": ["n"],
"type" : "object"
}
},
"info":{
......
......@@ -7,6 +7,48 @@
"application/json"
],
"paths":{
"/oc/con": {
"get": {
"description": "",
"parameters": [
{
"$ref": "#/parameters/interface-rw"
}
],
"responses": {
"200": {
"description" : "",
"schema": {
"$ref": "#/definitions/Configuration"
}
}
}
},
"post": {
"description": "",
"parameters": [
{
"$ref": "#/parameters/interface-rw"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ConfigurationUpdate"
}
}
],
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/ConfigurationUpdate"
}
}
}
}
},
"/platform?if=oic.if.ll":{
"get":{
"responses":{
......@@ -142,7 +184,7 @@
},
"parameters":[
{
"$ref":"#/parameters/interface-update"
"$ref":"#/parameters/interface-all40"
},
{
"schema":{
......@@ -232,7 +274,7 @@
},
"parameters":[
{
"$ref":"#/parameters/interface-all"
"$ref":"#/parameters/interface-rw"
}
],
"description":""
......@@ -250,7 +292,7 @@
},
"parameters":[
{
"$ref":"#/parameters/interface-update"
"$ref":"#/parameters/interface-all40"
},
{
"schema":{
......@@ -350,7 +392,7 @@
"description":""
},
"tag-pos-desc":{
"description":"Descriptive relative position of the Resource",
"description":"",
"type":"string",
"enum":[
"unknown",
......@@ -378,7 +420,7 @@
"tag-pos-rel":{
"type":"array",
"readOnly":true,
"description":"Relative position; against a known [0,0,0] point.",
"description":"",
"minItems":3,
"maxItems":3,
"items":{
......@@ -430,7 +472,7 @@
"items":{
"properties":{
"tag-pos-desc":{
"description":"Descriptive relative position of the Resource",
"description":"",
"type":"string",
"enum":[
"unknown",
......@@ -690,7 +732,7 @@
"description":""
},
"tag-pos-desc":{
"description":"Descriptive relative position of the Resource",
"description":"",
"type":"string",
"enum":[
"unknown",
......@@ -869,7 +911,7 @@
"items":{
"properties":{
"tag-pos-desc":{
"description":"Descriptive relative position of the Resource",
"description":"",
"type":"string",
"enum":[
"unknown",
......@@ -1195,7 +1237,7 @@
"oic.oic-link":{
"properties":{
"tag-pos-desc":{
"description":"Descriptive relative position of the Resource",
"description":"",
"type":"string",
"enum":[
"unknown",
......@@ -1335,7 +1377,7 @@
"description":""
},
"di":{
"type":"string",
"type":"string",
"pattern":"^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$",
"description":""
},
......@@ -1350,16 +1392,67 @@
"if"
],
"type":"object"
}
},
"Configuration": {
"properties": {
"rt": {
"description": "",
"items": {
"enum": ["oic.wk.con"],
"type": "string",
"maxLength": 64
},
"minItems": 1,
"uniqueItems": true,
"readOnly": true,
"type": "array",
"default": ["oic.wk.con"]
},
"n": {
"type": "string",
"readOnly": true,
"maxLength": 64,
"description": ""
},
"if" : {
"description": "",
"items": {
"enum": [
"oic.if.baseline",
"oic.if.rw"
],
"type": "string",
"maxLength": 64
},
"minItems": 1,
"uniqueItems": true,
"readOnly": true,
"type": "array"
}
},
"type" : "object",
"required": ["n"]
},
"ConfigurationUpdate" : {
"properties": {
"n": {
"description": "",
"maxLength": 64,
"type": "string"
}
},
"required": ["n"],
"type" : "object"
}
},
"info":{
"version":"20190215",
"title":"serverlite24521",
"termsOfService":"https://openconnectivityfoundation.github.io/core/DISCLAIMER.md",
"title":"serverlite",
"termsOfService":"",
"license":{
"x-copyright":"copyright 2016-2017, 2019 Open Connectivity Foundation, Inc. All rights reserved.",
"url":"https://github.com/openconnectivityfoundation/core/blob/e28a9e0a92e17042ba3e83661e4c0fbce8bdc4ba/LICENSE.md",
"name":"OCF Data Model License"
"x-copyright":"",
"url":"",
"name":""
}
},
"parameters":{
......@@ -1371,7 +1464,6 @@
],
"in":"query",
"name":"units",
"x-queryexample":"/TemperatureResURI?units=C",
"description":"",
"type":"string"
},
......@@ -1384,17 +1476,6 @@
"in":"query",
"name":"if"
},
"interface-update":{
"enum":[
"oic.if.ll",
"oic.if.create",
"oic.if.b",
"oic.if.baseline"
],
"type":"string",
"in":"query",
"name":"if"
},
"interface30":{
"enum":[
"oic.if.r",
......@@ -1425,7 +1506,7 @@
},
"interface-all40":{
"enum":[
"oic.if.ll",
"oic.if.ll",
"oic.if.create",
"oic.if.b",
"oic.if.baseline"
......@@ -1434,15 +1515,6 @@
"in":"query",
"name":"if"
},
"interface-all":{
"enum":[
"oic.if.rw",
"oic.if.baseline"
],
"type":"string",
"in":"query",
"name":"if"
},
"platforminterface-all":{
"enum":[
"oic.if.baseline"
......
......@@ -269,6 +269,8 @@ int oc_ri_get_query_value(const char *query, size_t query_len, const char *key,
oc_interface_mask_t oc_ri_get_interface_mask(char *iface, size_t if_len);
bool oc_ri_is_app_resource_valid(oc_resource_t *resource);
#ifdef __cplusplus
}
#endif
......
......@@ -675,7 +675,7 @@ coap_receive(oc_message_t *msg)
message->token, message->token_len);
}
}
if (response_buffer) {
if (!error_response && response_buffer) {
OC_DBG("got response buffer for uri %s",
oc_string(response_buffer->href));
client_cb = (oc_client_cb_t *)response_buffer->client_cb;
......