Loading ccsrc/Protocols/Json/json_codec_factory_mec046.hh 0 → 100644 +46 −0 Original line number Diff line number Diff line /*! * \file json_codec_factory_mec046.hh * \brief Header file for ITS JSON/IP protocol codec factory. * \author ETSI STF569 / TTF T027 // TTF T043 * \copyright ETSI Copyright Notification * No part may be reproduced except as authorized by written permission. * The copyright and the foregoing restriction extend to reproduction in all media. * All rights reserved. * \version 0.1 */ #pragma once #include "codec_stack_builder.hh" #include "json_codec_mec046.hh" class Record_Type; //! TITAN forward declaration /*! * \class json_codec_factory_mec046 * \brief This class provides a factory class to create an json_codec class instance */ class json_codec_factory_mec046: public codec_factory { static json_codec_factory_mec046 _f; //! Reference to the unique instance of this class public: //! \publicsection /*! * \brief Default constructor * Create a new instance of the json_codec_factory_mec046 class * \remark The HELD/IP codec identifier is HELD */ json_codec_factory_mec046() { // register factory codec_stack_builder::register_codec_factory("json_codec_mec046", this); }; /*! * \fn codec* create_codec(const std::string & type, const std::string & param); * \brief Create the codecs stack based on the provided codecs stack description * \param[in] p_type The provided codecs stack description * \param[in] p_params Optional parameters * \return 0 on success, -1 otherwise * \inline */ inline virtual codec_gen<Record_Type, Record_Type>* create_codec() { return (codec_gen<Record_Type, Record_Type>*)new json_codec_mec046(); }; }; // End of class json_codec_factory_mec046 ccsrc/Protocols/Json/json_codec_mec046.cc 0 → 100644 +113 −0 Original line number Diff line number Diff line #include <stdexcept> #include <regex> #include <string> #include "json_codec_factory_mec046.hh" #include "loggers.hh" #include "LibHttp_JsonMessageBodyTypes.hh" int json_codec_mec046::encode (const LibHttp__JsonMessageBodyTypes::JsonBody& msg, OCTETSTRING& data) { loggers::get_instance().log_msg(">>> json_codec_mec046::encode: ", (const Base_Type&)msg); TTCN_EncDec::clear_error(); TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_Buffer encoding_buffer; if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_sensor__discovery__info)) { const SensorsSharingService__TypesAndValues::SensorDiscoveryInfo& sensor_discovery_info = msg.sensor__discovery__info(); sensor_discovery_info.encode(SensorsSharingService__TypesAndValues::SensorDiscoveryInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"sensorIdentifier\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_sensor__discovery__event__subscription)) { const SensorsSharingService__TypesAndValues::SensorDiscoveryEventSubscription& sensor_discovery_event_subscription = msg.sensor__discovery__event__subscription(); sensor_discovery_event_subscription.encode(SensorsSharingService__TypesAndValues::SensorDiscoveryEventSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"sensorIdentifier\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_sensor__status__subscription)) { const SensorsSharingService__TypesAndValues::SensorStatusSubscription& sensor_status_subscription = msg.sensor__status__subscription(); sensor_status_subscription.encode(SensorsSharingService__TypesAndValues::SensorStatusSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"sensorIdentifier\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_sensor__data__subscription)) { const SensorsSharingService__TypesAndValues::SensorDataSubscription& sensor_data_subscription = msg.sensor__data__subscription(); sensor_data_subscription.encode(SensorsSharingService__TypesAndValues::SensorDataSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"sensorIdentifier\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else { return json_codec::encode(msg, data); } loggers::get_instance().log("<<< json_codec_mec046::encode"); return 0; } int json_codec_mec046::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBodyTypes::JsonBody& msg, params* p_params) { loggers::get_instance().log_msg(">>> json_codec_mec046::decode: p_data=", p_data); // Sanity checks params::const_iterator it; if (p_params == nullptr) { loggers::get_instance().warning("json_codec_mec046::decode: Failed to access p_params (null pointer)"); return -1; // TODO Use p_data instead of return -1 } else { it = p_params->find("decode_str"); if (it == p_params->cend()) { loggers::get_instance().warning("json_codec_mec046::decode: Failed to access p_params item (decode_str)"); return -1; // TODO Use p_data instead of return -1 } loggers::get_instance().log("json_codec_mec046::decode: it->second='%c' / '%s'", it->second.c_str()[0], it->second.c_str()); } // Remove data structure name (if present) ... std::string str; if ((it->second[0] != '[') && (it->second[0] != '{')) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); } else { str = it->second; } // ..and create the decoding buffer TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_EncDec::clear_error(); loggers::get_instance().log("json_codec_mec046::decode: decoding_buffer='%c' / '%s'", str[0], str.c_str()); TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); if (it->second.find("\"sensorIdentifier\"") != std::string::npos) { // Be careful to the order if (it->second[0] == '[') { SensorsSharingService__TypesAndValues::SensorDiscoveryInfos sensor_discovery_infos; sensor_discovery_infos.decode(SensorsSharingService__TypesAndValues::SensorDiscoveryInfos_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.sensor__discovery__infos() = sensor_discovery_infos; } else { SensorsSharingService__TypesAndValues::SensorDiscoveryInfo sensor_discovery_info; sensor_discovery_info.decode(SensorsSharingService__TypesAndValues::SensorDiscoveryInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.sensor__discovery__info() = sensor_discovery_info; } } else if ( (it->second.find("\"_links\"") != std::string::npos) && ((it->second.find("\"subscriptions\"") != std::string::npos) || (it->second.find("\"subscriptionType\"") == std::string::npos)) ) { SensorsSharingService__TypesAndValues::SubscriptionLinkList subscription_link_list; subscription_link_list.decode(SensorsSharingService__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.subscription__link__list__sss() = subscription_link_list; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"SensorDiscoveryEventSubscription\"") != std::string::npos)) { SensorsSharingService__TypesAndValues::SensorDiscoveryEventSubscription sensor_discovery_event_subscription; sensor_discovery_event_subscription.decode(SensorsSharingService__TypesAndValues::SensorDiscoveryEventSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.sensor__discovery__event__subscription() = sensor_discovery_event_subscription; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"SensorStatusSubscription\"") != std::string::npos)) { SensorsSharingService__TypesAndValues::SensorStatusSubscription sensor_status_subscription; sensor_status_subscription.decode(SensorsSharingService__TypesAndValues::SensorStatusSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.sensor__status__subscription() = sensor_status_subscription; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"SensorDataSubscription\"") != std::string::npos)) { SensorsSharingService__TypesAndValues::SensorDataSubscription sensor_data_subscription; sensor_data_subscription.decode(SensorsSharingService__TypesAndValues::SensorDataSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.sensor__data__subscription() = sensor_data_subscription; } else { return json_codec::decode(p_data, msg, p_params); } loggers::get_instance().log_msg("<<< json_codec_mec046::decode: ", (const Base_Type&)msg); return 0; } json_codec_factory_mec046 json_codec_factory_mec046::_f; ccsrc/Protocols/Json/json_codec_mec046.hh 0 → 100644 +25 −0 Original line number Diff line number Diff line #pragma once #include "codec_gen.hh" #include "params.hh" #include "json_codec.hh" class Base_Type; class TTCN_Typedescriptor_t; class TTCN_Buffer; namespace LibHttp__JsonMessageBodyTypes { class JsonBody; } class json_codec_mec046: public json_codec { public: explicit json_codec_mec046() : json_codec() { }; virtual ~json_codec_mec046() { }; int encode (const LibHttp__JsonMessageBodyTypes::JsonBody&, OCTETSTRING& data); int decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBodyTypes::JsonBody&, params* p_params = NULL); }; // End of class json_codec_mec046 ccsrc/Protocols/Json/module.mk +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ sources := \ json_codec_mec028.cc \ json_codec_mec033.cc \ json_codec_mec040.cc \ json_codec_mec046.cc \ includes := . Loading etc/AtsMec_SensorsSharingService/AtsMec_SensorsSharingService.cf_ +10 −8 Original line number Diff line number Diff line Loading @@ -16,10 +16,10 @@ LibHttp_Pics.PICS_USE_TOKEN_HEADER := true LibMec_Pics.PICS_ROOT_API := "/sbxykqjr17/mep1/" # Need to sign in on https://mec-platform.etsi.org/, section 'Try-it from your MEC application' SensorsSharingService_Pixits.PX_SENS_SUB_CALLBACK_URI := "http://clientApp.example.com/location_notifications/123456"; SensorsSharingService_Pixits.PX_SENS_SUB_CALLBACK_URI := "http://yanngarcia.ddns.net/sens/v1/notif" SensorsSharingService_Pixits.PX_SENS_DISCOVERY_TYPE := "" SensorsSharingService_Pixits.PX_SENS_DISCOVERY_PROPERTY_LIST := "" # Could be [], string or [string1 string2] SensorsSharingService_Pixits.PX_SENSOR_IDENTIFIER := "" SensorsSharingService_Pixits.PX_SENS_DISCOVERY_PROPERTY_LIST := "SAREF" # Could be [], string or [string1 string2] SensorsSharingService_Pixits.PX_SENSOR_IDENTIFIER := "CNT" [LOGGING] # In this section you can specify the name of the log file and the classes of events Loading @@ -37,8 +37,8 @@ LogEventTypes:= Yes [TESTPORT_PARAMETERS] # In this section you can specify parameters that are passed to Test Ports. system.httpPort.params := "HTTP(codecs=json:json_codec_mec030)/TCP(debug=1,server=mec-platform.etsi.org,port=443,use_ssl=1,trusted_ca_list=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem,privkey=/home/yann/var/ssl/archive/yanngarcia.ddns.net/privkey1.pem,certificate=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem)" system.httpPort_notif.params := "HTTP(codecs=json:json_codec_mec030)/TCP(debug=1,server_mode=1,local_port=443,use_ssl=1,mutual_auth=1,mutual_tls=1,trusted_ca_list=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem,privkey=/home/yann/var/ssl/archive/yanngarcia.ddns.net/privkey1.pem,certificate=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem)" system.httpPort.params := "HTTP(codecs=json:json_codec_mec046)/TCP(debug=1,server=mec-platform.etsi.org,port=443,use_ssl=1,trusted_ca_list=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem,privkey=/home/yann/var/ssl/archive/yanngarcia.ddns.net/privkey1.pem,certificate=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem)" system.httpPort_notif.params := "HTTP(codecs=json:json_codec_mec046)/TCP(debug=1,server_mode=1,local_port=80,use_ssl=0)" [DEFINE] # In this section you can create macro definitions, Loading Loading @@ -66,7 +66,7 @@ system.httpPort_notif.params := "HTTP(codecs=json:json_codec_mec030)/TCP(debug=1 #AtsMec_SensorsSharingService_TestControl.control # Check that the IUT responds with the list of SensorDiscoveryInfo when queried by a MEC Application AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 # Check that the IUT responds with the list of SensorDiscoveryInfo when queried by a MEC Application - Using type filter #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 # Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application - Invalid filter Loading Loading @@ -98,7 +98,7 @@ AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 # Check that the IUT responds with the list of SensorData when queried by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSLOOKUP_003_OK # Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSLOOKUP_003_BR AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSLOOKUP_003_BR # Check that the IUT responds with an error when the IUT does not have sensor(s) #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSLOOKUP_003_NF # Check that the IUT responds with the list of subscriptions when queried by a MEC Application - No query parameters Loading Loading @@ -131,7 +131,7 @@ AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_001_BR_02 # Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application - Both callbackReference and websockNotifConfig provided #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_001_BR_03 # Check that the IUT acknowledges the creation of SensorDiscoveryEventSubscription request when commanded by a MEC Application # Check that the IUT acknowledges the change of SensorDiscoveryEventSubscription request when commanded by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_002_OK # Check that the IUT responds with an error when a request for an URI that cannot be mapped to a valid resource URI is sent by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_002_NF Loading @@ -143,6 +143,8 @@ AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_004_OK # Check that the IUT provides a test notification when requested by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_004_OK_01 # Check that the IUT provides a notification when requested by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_004_OK_02 # Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application - Invalid subscriptionType Loading Loading
ccsrc/Protocols/Json/json_codec_factory_mec046.hh 0 → 100644 +46 −0 Original line number Diff line number Diff line /*! * \file json_codec_factory_mec046.hh * \brief Header file for ITS JSON/IP protocol codec factory. * \author ETSI STF569 / TTF T027 // TTF T043 * \copyright ETSI Copyright Notification * No part may be reproduced except as authorized by written permission. * The copyright and the foregoing restriction extend to reproduction in all media. * All rights reserved. * \version 0.1 */ #pragma once #include "codec_stack_builder.hh" #include "json_codec_mec046.hh" class Record_Type; //! TITAN forward declaration /*! * \class json_codec_factory_mec046 * \brief This class provides a factory class to create an json_codec class instance */ class json_codec_factory_mec046: public codec_factory { static json_codec_factory_mec046 _f; //! Reference to the unique instance of this class public: //! \publicsection /*! * \brief Default constructor * Create a new instance of the json_codec_factory_mec046 class * \remark The HELD/IP codec identifier is HELD */ json_codec_factory_mec046() { // register factory codec_stack_builder::register_codec_factory("json_codec_mec046", this); }; /*! * \fn codec* create_codec(const std::string & type, const std::string & param); * \brief Create the codecs stack based on the provided codecs stack description * \param[in] p_type The provided codecs stack description * \param[in] p_params Optional parameters * \return 0 on success, -1 otherwise * \inline */ inline virtual codec_gen<Record_Type, Record_Type>* create_codec() { return (codec_gen<Record_Type, Record_Type>*)new json_codec_mec046(); }; }; // End of class json_codec_factory_mec046
ccsrc/Protocols/Json/json_codec_mec046.cc 0 → 100644 +113 −0 Original line number Diff line number Diff line #include <stdexcept> #include <regex> #include <string> #include "json_codec_factory_mec046.hh" #include "loggers.hh" #include "LibHttp_JsonMessageBodyTypes.hh" int json_codec_mec046::encode (const LibHttp__JsonMessageBodyTypes::JsonBody& msg, OCTETSTRING& data) { loggers::get_instance().log_msg(">>> json_codec_mec046::encode: ", (const Base_Type&)msg); TTCN_EncDec::clear_error(); TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_Buffer encoding_buffer; if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_sensor__discovery__info)) { const SensorsSharingService__TypesAndValues::SensorDiscoveryInfo& sensor_discovery_info = msg.sensor__discovery__info(); sensor_discovery_info.encode(SensorsSharingService__TypesAndValues::SensorDiscoveryInfo_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"sensorIdentifier\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_sensor__discovery__event__subscription)) { const SensorsSharingService__TypesAndValues::SensorDiscoveryEventSubscription& sensor_discovery_event_subscription = msg.sensor__discovery__event__subscription(); sensor_discovery_event_subscription.encode(SensorsSharingService__TypesAndValues::SensorDiscoveryEventSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"sensorIdentifier\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_sensor__status__subscription)) { const SensorsSharingService__TypesAndValues::SensorStatusSubscription& sensor_status_subscription = msg.sensor__status__subscription(); sensor_status_subscription.encode(SensorsSharingService__TypesAndValues::SensorStatusSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"sensorIdentifier\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else if (msg.ischosen(LibHttp__JsonMessageBodyTypes::JsonBody::ALT_sensor__data__subscription)) { const SensorsSharingService__TypesAndValues::SensorDataSubscription& sensor_data_subscription = msg.sensor__data__subscription(); sensor_data_subscription.encode(SensorsSharingService__TypesAndValues::SensorDataSubscription_descr_, encoding_buffer, TTCN_EncDec::CT_JSON); data = /*char2oct(CHARSTRING("{\"sensorIdentifier\": ")) + */OCTETSTRING(encoding_buffer.get_len(), encoding_buffer.get_data())/* + char2oct(CHARSTRING("}"))*/; } else { return json_codec::encode(msg, data); } loggers::get_instance().log("<<< json_codec_mec046::encode"); return 0; } int json_codec_mec046::decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBodyTypes::JsonBody& msg, params* p_params) { loggers::get_instance().log_msg(">>> json_codec_mec046::decode: p_data=", p_data); // Sanity checks params::const_iterator it; if (p_params == nullptr) { loggers::get_instance().warning("json_codec_mec046::decode: Failed to access p_params (null pointer)"); return -1; // TODO Use p_data instead of return -1 } else { it = p_params->find("decode_str"); if (it == p_params->cend()) { loggers::get_instance().warning("json_codec_mec046::decode: Failed to access p_params item (decode_str)"); return -1; // TODO Use p_data instead of return -1 } loggers::get_instance().log("json_codec_mec046::decode: it->second='%c' / '%s'", it->second.c_str()[0], it->second.c_str()); } // Remove data structure name (if present) ... std::string str; if ((it->second[0] != '[') && (it->second[0] != '{')) { int idx_begin = it->second.find(":"); int idx_end = it->second.rfind("}") - 1; // Remove the last '}' str = it->second.substr(idx_begin + 1, idx_end - idx_begin); } else { str = it->second; } // ..and create the decoding buffer TTCN_EncDec::set_error_behavior(TTCN_EncDec::ET_ALL, TTCN_EncDec::EB_DEFAULT); TTCN_EncDec::clear_error(); loggers::get_instance().log("json_codec_mec046::decode: decoding_buffer='%c' / '%s'", str[0], str.c_str()); TTCN_Buffer decoding_buffer(OCTETSTRING(str.length(), (const unsigned char*)str.c_str())); if (it->second.find("\"sensorIdentifier\"") != std::string::npos) { // Be careful to the order if (it->second[0] == '[') { SensorsSharingService__TypesAndValues::SensorDiscoveryInfos sensor_discovery_infos; sensor_discovery_infos.decode(SensorsSharingService__TypesAndValues::SensorDiscoveryInfos_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.sensor__discovery__infos() = sensor_discovery_infos; } else { SensorsSharingService__TypesAndValues::SensorDiscoveryInfo sensor_discovery_info; sensor_discovery_info.decode(SensorsSharingService__TypesAndValues::SensorDiscoveryInfo_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.sensor__discovery__info() = sensor_discovery_info; } } else if ( (it->second.find("\"_links\"") != std::string::npos) && ((it->second.find("\"subscriptions\"") != std::string::npos) || (it->second.find("\"subscriptionType\"") == std::string::npos)) ) { SensorsSharingService__TypesAndValues::SubscriptionLinkList subscription_link_list; subscription_link_list.decode(SensorsSharingService__TypesAndValues::SubscriptionLinkList_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.subscription__link__list__sss() = subscription_link_list; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"SensorDiscoveryEventSubscription\"") != std::string::npos)) { SensorsSharingService__TypesAndValues::SensorDiscoveryEventSubscription sensor_discovery_event_subscription; sensor_discovery_event_subscription.decode(SensorsSharingService__TypesAndValues::SensorDiscoveryEventSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.sensor__discovery__event__subscription() = sensor_discovery_event_subscription; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"SensorStatusSubscription\"") != std::string::npos)) { SensorsSharingService__TypesAndValues::SensorStatusSubscription sensor_status_subscription; sensor_status_subscription.decode(SensorsSharingService__TypesAndValues::SensorStatusSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.sensor__status__subscription() = sensor_status_subscription; } else if ((it->second.find("\"subscriptionType\"") != std::string::npos) && (it->second.find("\"SensorDataSubscription\"") != std::string::npos)) { SensorsSharingService__TypesAndValues::SensorDataSubscription sensor_data_subscription; sensor_data_subscription.decode(SensorsSharingService__TypesAndValues::SensorDataSubscription_descr_, decoding_buffer, TTCN_EncDec::CT_JSON); msg.sensor__data__subscription() = sensor_data_subscription; } else { return json_codec::decode(p_data, msg, p_params); } loggers::get_instance().log_msg("<<< json_codec_mec046::decode: ", (const Base_Type&)msg); return 0; } json_codec_factory_mec046 json_codec_factory_mec046::_f;
ccsrc/Protocols/Json/json_codec_mec046.hh 0 → 100644 +25 −0 Original line number Diff line number Diff line #pragma once #include "codec_gen.hh" #include "params.hh" #include "json_codec.hh" class Base_Type; class TTCN_Typedescriptor_t; class TTCN_Buffer; namespace LibHttp__JsonMessageBodyTypes { class JsonBody; } class json_codec_mec046: public json_codec { public: explicit json_codec_mec046() : json_codec() { }; virtual ~json_codec_mec046() { }; int encode (const LibHttp__JsonMessageBodyTypes::JsonBody&, OCTETSTRING& data); int decode (const OCTETSTRING& p_data, LibHttp__JsonMessageBodyTypes::JsonBody&, params* p_params = NULL); }; // End of class json_codec_mec046
ccsrc/Protocols/Json/module.mk +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ sources := \ json_codec_mec028.cc \ json_codec_mec033.cc \ json_codec_mec040.cc \ json_codec_mec046.cc \ includes := . Loading
etc/AtsMec_SensorsSharingService/AtsMec_SensorsSharingService.cf_ +10 −8 Original line number Diff line number Diff line Loading @@ -16,10 +16,10 @@ LibHttp_Pics.PICS_USE_TOKEN_HEADER := true LibMec_Pics.PICS_ROOT_API := "/sbxykqjr17/mep1/" # Need to sign in on https://mec-platform.etsi.org/, section 'Try-it from your MEC application' SensorsSharingService_Pixits.PX_SENS_SUB_CALLBACK_URI := "http://clientApp.example.com/location_notifications/123456"; SensorsSharingService_Pixits.PX_SENS_SUB_CALLBACK_URI := "http://yanngarcia.ddns.net/sens/v1/notif" SensorsSharingService_Pixits.PX_SENS_DISCOVERY_TYPE := "" SensorsSharingService_Pixits.PX_SENS_DISCOVERY_PROPERTY_LIST := "" # Could be [], string or [string1 string2] SensorsSharingService_Pixits.PX_SENSOR_IDENTIFIER := "" SensorsSharingService_Pixits.PX_SENS_DISCOVERY_PROPERTY_LIST := "SAREF" # Could be [], string or [string1 string2] SensorsSharingService_Pixits.PX_SENSOR_IDENTIFIER := "CNT" [LOGGING] # In this section you can specify the name of the log file and the classes of events Loading @@ -37,8 +37,8 @@ LogEventTypes:= Yes [TESTPORT_PARAMETERS] # In this section you can specify parameters that are passed to Test Ports. system.httpPort.params := "HTTP(codecs=json:json_codec_mec030)/TCP(debug=1,server=mec-platform.etsi.org,port=443,use_ssl=1,trusted_ca_list=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem,privkey=/home/yann/var/ssl/archive/yanngarcia.ddns.net/privkey1.pem,certificate=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem)" system.httpPort_notif.params := "HTTP(codecs=json:json_codec_mec030)/TCP(debug=1,server_mode=1,local_port=443,use_ssl=1,mutual_auth=1,mutual_tls=1,trusted_ca_list=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem,privkey=/home/yann/var/ssl/archive/yanngarcia.ddns.net/privkey1.pem,certificate=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem)" system.httpPort.params := "HTTP(codecs=json:json_codec_mec046)/TCP(debug=1,server=mec-platform.etsi.org,port=443,use_ssl=1,trusted_ca_list=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem,privkey=/home/yann/var/ssl/archive/yanngarcia.ddns.net/privkey1.pem,certificate=/home/yann/var/ssl/archive/yanngarcia.ddns.net/fullchain1.pem)" system.httpPort_notif.params := "HTTP(codecs=json:json_codec_mec046)/TCP(debug=1,server_mode=1,local_port=80,use_ssl=0)" [DEFINE] # In this section you can create macro definitions, Loading Loading @@ -66,7 +66,7 @@ system.httpPort_notif.params := "HTTP(codecs=json:json_codec_mec030)/TCP(debug=1 #AtsMec_SensorsSharingService_TestControl.control # Check that the IUT responds with the list of SensorDiscoveryInfo when queried by a MEC Application AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 # Check that the IUT responds with the list of SensorDiscoveryInfo when queried by a MEC Application - Using type filter #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 # Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application - Invalid filter Loading Loading @@ -98,7 +98,7 @@ AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 # Check that the IUT responds with the list of SensorData when queried by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSLOOKUP_003_OK # Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSLOOKUP_003_BR AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSLOOKUP_003_BR # Check that the IUT responds with an error when the IUT does not have sensor(s) #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSLOOKUP_003_NF # Check that the IUT responds with the list of subscriptions when queried by a MEC Application - No query parameters Loading Loading @@ -131,7 +131,7 @@ AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_001_BR_02 # Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application - Both callbackReference and websockNotifConfig provided #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_001_BR_03 # Check that the IUT acknowledges the creation of SensorDiscoveryEventSubscription request when commanded by a MEC Application # Check that the IUT acknowledges the change of SensorDiscoveryEventSubscription request when commanded by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_002_OK # Check that the IUT responds with an error when a request for an URI that cannot be mapped to a valid resource URI is sent by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_002_NF Loading @@ -143,6 +143,8 @@ AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSDISCOVERY_001_OK_01 #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_004_OK # Check that the IUT provides a test notification when requested by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_004_OK_01 # Check that the IUT provides a notification when requested by a MEC Application #AtsMec_SensorsSharingService_TestCases.TC_MEC_MEC046_SRV_SENSSUBNOT_SUB_NOT_004_OK_02 # Check that the IUT responds with an error when a request with incorrect parameters is sent by a MEC Application - Invalid subscriptionType Loading