#@fileName #@brief - # #Revision Log: # v1.0.1 : Aug 4, 2016 INITIAL OF PROGRAMMER - REVISION DETAIL_1 <- THIS IS THE LATEST REVISION #Description: #YalgaarInitModule contents methods and variables and enum.. # #@bug Known Issues: # 1. ISSUE NAME - NONE # WORKAROUND - NONE #@details Notes: NONE #SLS MAKES NO REPRESENTATION, WARRANTY, OR CONDITION OF #ANY KIND, EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE OR IN #ANY COMMUNICATION WITH YOU, INCLUDING, BUT NOT LIMITED TO, #ANY IMPLIED WARRANTIES OF MERCHANTABILITY, SATISFACTORY #QUALITY, FITNESS FOR ANY PARTICULAR PURPOSE, #NONINFRINGEMENT, AND THEIR EQUIVALENTS. #SLS Propritery and Confidential #@copyright (C) 2016 SLS Corporation, All Rights Reserved. #!/usr/bin/env ruby $LOAD_PATH << '.' require_relative 'YalgaarInitModule' # Namespace module for YalgaarConnect default variables... module YalgaarConnect #~ include YalgaarApis #~ include YalgaarInit include MQTT include YalgaarInit include YalgaarApis #yalgaarConnect(*args,lamda); #@brief - #@param : #DESCRIPTION: #@bug Known Issues: #1. e #~ pubACK(e.message) #~ lamda.call(e.message) #~ exit(0) end else @@client = MQTT::Client.new @@client.keep_alive=@@keepalive @@client.ack_timeout=@@connectTimeout @@client.host = @@host @@client.port = DEFAULT_SSL_PORT @@client.client_id = @@clientKey+'/'+@@uuid @@client.ssl = true @@client.cert_file = "#{Dir.pwd}""/SSLcomDVCA_2.crt" begin @@client.connect() rescue Exception => e #~ lamda.call(e.message) #~ pubACK(e.message) #~ exit(0) end end th = Thread.new do |client| @@client.get do |topic,message| messageParsing(topic,message,isEncrpt) end end when THREEARGV isEncrpt=0 @@clientKey=args[0] @@isSecure=args[1] @@uuid=args[2] if @@uuid == 0 @@uuid=generateUUID(3) end if @@isSecure==0 @@client = MQTT::Client.new @@client.keep_alive=@@keepalive @@client.ack_timeout=@@connectTimeout @@client.host = @@host @@client.port = DEFAULT_PORT @@client.client_id = @@clientKey+'/'+@@uuid begin ret =@@client.connect() puts ret rescue Exception => e #~ lamda.call(e.message) #~ pubACK(e.message) #~ exit(0) end else @@client = MQTT::Client.new @@client.keep_alive=@@keepalive @@client.ack_timeout=@@connectTimeout @@client.host = @@host @@client.port = DEFAULT_SSL_PORT @@client.client_id = @@clientKey+'/'+@@uuid @@client.ssl = true @@client.cert_file = "#{Dir.pwd}""/SSLcomDVCA_2.crt" begin ret =@@client.connect() puts ret rescue Exception => e #~ lamda.call(e.message) #~ pubACK(e.message) #~ exit(0) end end th = Thread.new do |client| @@client.get do |topic,message| #~ puts "#{topic}: #{message}" messageParsing(topic,message,isEncrpt) end end when FOURARGV isEncrpt=1 @@clientKey=args[0] @@isSecure=args[1] @@uuid=generateUUID(3) @@aesSecretKey=args[2] if args[3]==YALGAR_AES_128 @@aesType='AES-128-ECB' elsif args[3]==YALGAR_AES_192 @@aesType='AES-192-ECB' elsif args[3]==YALGAR_AES_256 @@aesType='AES-256-ECB' else errmesg=showErrCode(YALGAAR_INVALID_AES_TYPE) @@lErrorConnectionCallback.call(errmesg) return end if @@isSecure==0 @@client = MQTT::Client.new @@client.keep_alive=@@keepalive @@client.ack_timeout=@@connectTimeout @@client.host = @@host @@client.port = DEFAULT_PORT @@client.client_id = @@clientKey+'/'+@@uuid begin @@client.connect() rescue Exception => e #~ lamda.call(e.message) #~ pubACK(e.message) #~ exit(0) end else @@client = MQTT::Client.new @@client.keep_alive=@@keepalive @@client.ack_timeout=@@connectTimeout @@client.host = @@host @@client.port = DEFAULT_SSL_PORT @@client.client_id = @@clientKey+'/'+@@uuid @@client.ssl = true @@client.cert_file = "#{Dir.pwd}""/SSLcomDVCA_2.crt" begin @@client.connect() rescue Exception => e #~ lamda.call(e.message) #~ pubACK(e.message) #~ exit(0) end end th = Thread.new do |client| @@client.get do |topic,message| messageParsing(topic,message,isEncrpt) end end when FIVEARGV isEncrpt=1 @@clientKey=args[0] @@isSecure=args[1] @@uuid=args[2] if @@uuid==0 @@uuid=generateUUID(3) end @@aesSecretKey=args[3] if args[4]==YALGAR_AES_128 @@aesType='AES-128-ECB' elsif args[4]==YALGAR_AES_192 @@aesType='AES-192-ECB' elsif args[4]==YALGAR_AES_256 @@aesType='AES-256-ECB' else errmesg=showErrCode(YALGAAR_INVALID_AES_TYPE) @@lErrorConnectionCallback.call(errmesg) return end if @@isSecure==0 @@client = MQTT::Client.new @@client.keep_alive=@@keepalive @@client.ack_timeout=@@connectTimeout @@client.host = @@host @@client.port = DEFAULT_PORT @@client.client_id = @@clientKey+'/'+@@uuid begin @@client.connect() rescue Exception => e #~ lamda.call(e.message) #~ pubACK(e.message) #~ exit(0) end else @@client = MQTT::Client.new @@client.keep_alive=@@keepalive @@client.ack_timeout=@@connectTimeout @@client.host = @@host @@client.port = DEFAULT_SSL_PORT @@client.client_id = @@clientKey+'/'+@@uuid @@client.ssl = true @@client.cert_file = "#{Dir.pwd}""/SSLcomDVCA_2.crt" begin @@client.connect() rescue Exception => e #~ lamda.call(e.message) #~ pubACK(e.message) #~ exit(0) end end th = Thread.new do |client| @@client.get do |topic,message| #puts "#{topic}: #{message}" messageParsing(topic,message,isEncrpt) end end else puts 'Invalid Arguments' end end def yalgaarDisconnect(lamda) begin ret =@@client.disconnect(true) rescue Exception => e #~ lamda.call(e.message) #~ exit(0) end errmesg=showErrCode(YALGAAR_DISCONNECT_SUCCESS) lamda.call(errmesg) #~ lamda.call("Disconnect success") end end