| /////////////////////////////////////////////////////////////////////////////// |
| // |
| // Copyright (c) 2000-2018 Ericsson Telecom AB |
| // |
| // All rights reserved. This program and the accompanying materials |
| // are made available under the terms of the Eclipse Public License v2.0 |
| // which accompanies this distribution, and is available at |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html |
| /////////////////////////////////////////////////////////////////////////////// |
| // File: EPTF_MQTT_LGen_Definitions.ttcn |
| // Description: |
| // Rev: R1A |
| // Prodnr: CNL 113 860 |
| // Updated: 2017-09-01 |
| // Contact: http://ttcn.ericsson.se |
| /////////////////////////////////////////////////////////////////////////////// |
| module EPTF_MQTT_LGen_Definitions |
| { |
| import from EPTF_MQTT_Transport_Definitions all; |
| import from EPTF_CLL_LGenBase_Definitions all; |
| import from EPTF_CLL_Logging_Definitions all; |
| import from EPTF_CLL_FBQ_Definitions all; |
| import from EPTF_CLL_Common_Definitions all; |
| import from Socket_API_Definitions all; |
| import from MQTT_v3_1_1_Types all; |
| |
| modulepar boolean tsp_EPTF_MQTT_LGen_debug := false; |
| modulepar boolean tsp_EPTF_MQTT_LGen_debugVerbose := false; |
| modulepar integer tsp_EPTF_MQTT_LGen_maxBindableCtx := -1; |
| |
| modulepar MQTT_Template_List tsp_EPTF_MQTT_LGen_templates := {}; |
| |
| modulepar float tsp_EPTF_MQTT_PUBLISH_responseWatchdog := 0.0; |
| |
| const integer c_MQTT_LGen_Logging_WARNING := 0; |
| const integer c_MQTT_LGen_Logging_DEBUG := 1; |
| const integer c_MQTT_LGen_Logging_DEBUGV := 2; |
| const integer c_MQTT_LGen_Logging_ERROR := 3; |
| |
| const charstring c_MQTT_behaviorType := "MQTT Behavior"; |
| |
| type record MQTT_Template |
| { |
| charstring id, |
| MQTT_v3_1_1_ReqResp msg |
| } |
| |
| type record of MQTT_Template MQTT_Template_List; |
| |
| type record MQTT_Template_DB |
| { |
| MQTT_Template_List data, |
| integer hashRef |
| } |
| |
| type record MQTT_Session |
| { |
| integer eIdx, |
| integer fsmIdx, |
| integer localAddrIdx, |
| integer remoteAddrIdx, |
| charstring clientId, |
| float keepAliveTime, |
| integer nextPacketId, |
| EPTF_IntegerList subscriptionRefs, |
| EPTF_IntegerList publishRefs, |
| integer keepaliveTimer, |
| boolean reportPingResponse, |
| boolean reportPublishResponse, |
| MQTT_Session_State state |
| } |
| |
| type enumerated MQTT_Session_State { |
| DISCONNECTED, |
| CONNECTING, |
| CONNECTED, |
| REMOVING |
| } |
| |
| const MQTT_Session c_MQTT_Session_init := |
| { |
| eIdx := -1, |
| fsmIdx := -1, |
| localAddrIdx := -1, |
| remoteAddrIdx := -1, |
| clientId := "", |
| keepAliveTime := 0.0, |
| nextPacketId := 0, |
| subscriptionRefs := {}, |
| publishRefs := {}, |
| keepaliveTimer := -1, |
| reportPingResponse := false, |
| reportPublishResponse := false, |
| state := DISCONNECTED |
| } |
| |
| type record of MQTT_Session MQTT_Session_List; |
| |
| type record MQTT_Session_DB |
| { |
| EPTF_FreeBusyQueue queue, |
| MQTT_Session_List data, |
| integer hashRef |
| } |
| |
| // TODO: Currently only one topic per subscription is handled only! |
| type record MQTT_Subscription |
| { |
| integer sessionIdx, |
| MQTT_v3_1_1_Subscribe request optional, |
| MQTT_Subscription_State state |
| } |
| |
| type enumerated MQTT_Subscription_State { |
| UNSUBSCRIBED, |
| SUBSCRIBING, |
| SUBSCRIBED, |
| UNSUBSCRIBING, |
| REMOVING |
| } |
| |
| const MQTT_Subscription c_MQTT_Subscription_init := |
| { |
| sessionIdx := -1, |
| request := omit, |
| state := UNSUBSCRIBED |
| } |
| |
| type record of MQTT_Subscription MQTT_Subscription_List; |
| |
| type record MQTT_Subscription_DB |
| { |
| EPTF_FreeBusyQueue queue, |
| MQTT_Subscription_List data, |
| integer hashRef // sessionIdx+packetId or sessionIdx+topicName |
| } |
| |
| type record MQTT_Publish |
| { |
| integer sessionIdx, |
| integer packetId, |
| //MQTT_v3_1_1_Publish request optional, |
| integer watchdogTimer, |
| MQTT_Publish_Side side, |
| MQTT_Publish_State state |
| } |
| |
| const MQTT_Publish c_MQTT_Publish_init := |
| { |
| sessionIdx := -1, |
| packetId := -1, |
| //request := omit, |
| watchdogTimer := -1, |
| side := ORIG, |
| state := { created := true } |
| } |
| |
| type enumerated MQTT_Publish_Side |
| { |
| ORIG, |
| TERM |
| } |
| |
| type union MQTT_Publish_State |
| { |
| MQTT_PublishQos1_State qos1, |
| MQTT_PublishQos2_State qos2, |
| boolean created, |
| boolean removing |
| } |
| |
| type enumerated MQTT_PublishQos1_State |
| { |
| CREATED, |
| PUBLISHED, |
| ACKNOWLEDGED |
| } |
| |
| type enumerated MQTT_PublishQos2_State |
| { |
| CREATED, |
| PUBLISHED, |
| RECEIVED, |
| RELEASED, |
| COMPLETE |
| } |
| |
| type record of MQTT_Publish MQTT_Publish_List; |
| |
| type record MQTT_Publish_DB |
| { |
| EPTF_FreeBusyQueue queue, |
| MQTT_Publish_List data, |
| integer hashRef // sessionIdx+packetId |
| } |
| |
| type record MQTT_StepCtx |
| { |
| integer eIdx, |
| integer fsmIdx, |
| integer sessionIdx |
| } |
| |
| const MQTT_StepCtx c_MQTT_StepCtx_empty := |
| { |
| eIdx := -1, |
| fsmIdx := -1, |
| sessionIdx := -1 |
| } |
| |
| type record of Socket MQTT_Address_List; |
| |
| type record MQTT_Address_DB |
| { |
| EPTF_FreeBusyQueue queue, |
| MQTT_Address_List data, |
| integer hashRef |
| } |
| |
| type function fcb_EPTF_MQTT_messageReceived(in EPTF_MQTT_PDU pl_message) runs on self; |
| |
| type component EPTF_MQTT_LGen_CT extends EPTF_MQTT_Transport_User_CT, EPTF_LGenBase_CT, EPTF_Logging_CT |
| { |
| var boolean v_MQTT_initialized := false; |
| |
| var integer v_MQTT_bIdx; |
| |
| var integer v_MQTT_loggingMaskId := -1; |
| |
| var MQTT_Address_DB v_MQTT_addressDB; |
| var MQTT_Template_DB v_MQTT_templateDB; |
| var MQTT_Session_DB v_MQTT_sessionDB; |
| var MQTT_Subscription_DB v_MQTT_subscriptionDB; |
| var MQTT_Publish_DB v_MQTT_publishDB; |
| |
| var MQTT_StepCtx v_MQTT_ctx := c_MQTT_StepCtx_empty; |
| var MQTT_Session v_MQTT_session := c_MQTT_Session_init; |
| var MQTT_Subscription v_MQTT_subscription := c_MQTT_Subscription_init; |
| var MQTT_Publish v_MQTT_publish := c_MQTT_Publish_init; |
| |
| var EPTF_MQTT_PDU v_MQTT_msgToProcess; |
| var EPTF_MQTT_PDU v_MQTT_msgToSend; |
| |
| var fcb_EPTF_MQTT_messageReceived vf_MQTT_msgReceived := null; |
| } |
| |
| const integer c_MQTT_AppData_sessionIdx := 0; |
| |
| // Events |
| |
| const integer c_MQTT_eventIdx_transportSucc := 0; |
| const charstring c_MQTT_eventName_transportSucc := "MQTT transport: succ rsp"; |
| |
| const integer c_MQTT_eventIdx_transportFail := 1; |
| const charstring c_MQTT_eventName_transportFail := "MQTT transport: fail rsp"; |
| |
| const integer c_MQTT_eventIdx_transportClosed := 2; |
| const charstring c_MQTT_eventName_transportClosed := "MQTT transport: connection closed"; |
| |
| const integer c_MQTT_eventIdx_CONNACK_Accepted := 3; |
| const charstring c_MQTT_eventName_CONNACK_Accepted := "MQTT rsp: CONNACK Accepted"; |
| |
| const integer c_MQTT_eventIdx_CONNACK_Refused := 4; |
| const charstring c_MQTT_eventName_CONNACK_Refused := "MQTT rsp: CONNACK Refused"; |
| |
| const integer c_MQTT_eventIdx_SUBACK_Accepted := 5; |
| const charstring c_MQTT_eventName_SUBACK_Accepted := "MQTT rsp: SUBACK Accepted"; |
| |
| const integer c_MQTT_eventIdx_SUBACK_Refused := 6; |
| const charstring c_MQTT_eventName_SUBACK_Refused := "MQTT rsp: SUBACK Refused"; |
| |
| const integer c_MQTT_eventIdx_UNSUBACK := 7; |
| const charstring c_MQTT_eventName_UNSUBACK := "MQTT rsp: UNSUBACK"; |
| |
| const integer c_MQTT_eventIdx_PUBLISH := 8; |
| const charstring c_MQTT_eventName_PUBLISH := "MQTT req: PUBLISH"; |
| |
| const integer c_MQTT_eventIdx_PING_Request := 9; |
| const charstring c_MQTT_eventName_PING_Request := "MQTT req: PING"; |
| |
| const integer c_MQTT_eventIdx_PING_Response := 10; |
| const charstring c_MQTT_eventName_PING_Response := "MQTT rsp: PING"; |
| |
| const integer c_MQTT_eventIdx_PUBACK := 11; |
| const charstring c_MQTT_eventName_PUBACK := "MQTT rsp: PUBACK"; |
| |
| const integer c_MQTT_eventIdx_PUBREC := 12; |
| const charstring c_MQTT_eventName_PUBREC := "MQTT rsp: PUBREC"; |
| |
| const integer c_MQTT_eventIdx_PUBREL := 13; |
| const charstring c_MQTT_eventName_PUBREL := "MQTT req: PUBREL"; |
| |
| const integer c_MQTT_eventIdx_PUBCOMP := 14; |
| const charstring c_MQTT_eventName_PUBCOMP := "MQTT rsp: PUBCOMP"; |
| |
| const integer c_MQTT_eventIdx_PUBLISH_Timeout := 15; |
| const charstring c_MQTT_eventName_PUBLISH_Timeout := "MQTT timeout: PUBLISH Timeout"; |
| |
| |
| // Steps |
| |
| const integer c_MQTT_stepIdx_init := 0; |
| const charstring c_MQTT_stepName_init := "MQTT Applib: init"; |
| |
| const integer c_MQTT_stepIdx_cleanUp := 1; |
| const charstring c_MQTT_stepName_cleanUp := "MQTT Applib: cleanUp"; |
| |
| const integer c_MQTT_stepIdx_setLocalAddress_byVars := 2; |
| const charstring c_MQTT_stepName_setLocalAddress_byVars := "MQTT Applib: setLocalAddress_byVars"; |
| |
| const integer c_MQTT_stepIdx_setRemoteAddress_byVars := 3; |
| const charstring c_MQTT_stepName_setRemoteAddress_byVars := "MQTT Applib: setRemoteAddress_byVars"; |
| |
| const integer c_MQTT_stepIdx_transportConnect := 4; |
| const charstring c_MQTT_stepName_transportConnect := "MQTT Applib: transportConnect"; |
| |
| const integer c_MQTT_stepIdx_transportClose := 5; |
| const charstring c_MQTT_stepName_transportClose := "MQTT Applib: transportClose"; |
| |
| const integer c_MQTT_stepIdx_startListening := 6; |
| const charstring c_MQTT_stepName_startListening := "MQTT Applib: startListening"; |
| |
| const integer c_MQTT_stepIdx_loadTemplate_byIntIdx := 7; |
| const charstring c_MQTT_stepName_loadTemplate_byIntIdx := "MQTT Applib: loadTemplate_byIntIdx"; |
| |
| const integer c_MQTT_stepIdx_loadTemplate_byStringId := 8; |
| const charstring c_MQTT_stepName_loadTemplate_byStringId := "MQTT Applib: loadTemplate_byStringId"; |
| |
| const integer c_MQTT_stepIdx_send := 9; |
| const charstring c_MQTT_stepName_send := "MQTT Applib: send"; |
| |
| const integer c_MQTT_stepIdx_setTopic_stringParam := 10; |
| const charstring c_MQTT_stepName_setTopic_stringParam := "MQTT Applib: setTopic_stringParam"; |
| |
| const integer c_MQTT_stepIdx_setTopic_add_stringParam := 11; |
| const charstring c_MQTT_stepName_setTopic_add_stringParam := "MQTT Applib: setTopic_add_stringParam"; |
| |
| const integer c_MQTT_stepIdx_setTopic_add_varParams := 12; |
| const charstring c_MQTT_stepName_setTopic_add_varParams := "MQTT Applib: setTopic_add_varParams"; |
| |
| const integer c_MQTT_stepIdx_setTopic_add_clientId := 13; |
| const charstring c_MQTT_stepName_setTopic_add_clientId := "MQTT Applib: setTopic_add_clientId"; |
| |
| const integer c_MQTT_stepIdx_setQos_intParam := 14; |
| const charstring c_MQTT_stepName_setQos_intParam := "MQTT Applib: setQos_intParam"; |
| |
| const integer c_MQTT_stepIdx_setPublishMessage_stringParam := 15; |
| const charstring c_MQTT_stepName_setPublishMessage_stringParam := "MQTT Applib: setPublishMessage_stringParam"; |
| |
| const integer c_MQTT_stepIdx_setPublishMessage_add_stringParam := 16; |
| const charstring c_MQTT_stepName_setPublishMessage_add_stringParam := "MQTT Applib: setPublishMessage_add_stringParam"; |
| |
| const integer c_MQTT_stepIdx_setPublishMessage_add_varParams := 17; |
| const charstring c_MQTT_stepName_setPublishMessage_add_varParams := "MQTT Applib: setPublishMessage_add_varParams"; |
| |
| const integer c_MQTT_stepIdx_setPublishMessage_add_clientId := 18; |
| const charstring c_MQTT_stepName_setPublishMessage_add_clientId := "MQTT Applib: setPublishMessage_add_clientId"; |
| |
| const integer c_MQTT_stepIdx_reportPingResponse := 19; |
| const charstring c_MQTT_stepName_reportPingResponse := "MQTT Applib: reportPingResponse"; |
| |
| const integer c_MQTT_stepIdx_reportPublishResponse := 20; |
| const charstring c_MQTT_stepName_reportPublishResponse := "MQTT Applib: reportPublishResponse"; |
| } |