Skip to content

Commit

Permalink
Merge pull request #7 from p-goudet/master
Browse files Browse the repository at this point in the history
Update to the latest source (1.0.13)
  • Loading branch information
p-goudet authored Jul 1, 2018
2 parents b119ff1 + 3aebc76 commit afdb57a
Show file tree
Hide file tree
Showing 26 changed files with 549 additions and 430 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@

*.gem
*.log
.DS_Store
104 changes: 42 additions & 62 deletions lib/paho-mqtt.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,39 @@
#
# Contributors:
# Pierre Goudet - initial committer
# And Others.

require "paho_mqtt/version"
require "paho_mqtt/client"
require "paho_mqtt/exception"
require "paho_mqtt/packet"
require 'logger'

module PahoMqtt
extend self

attr_accessor :logger

MAX_PACKET_ID = 65535

# Default connection setup
DEFAULT_SSL_PORT = 8883
DEFAULT_PORT = 1883
SELECT_TIMEOUT = 0
LOOP_TEMPO = 0.005
RECONNECT_RETRY_TIME = 3
RECONNECT_RETRY_TEMPO = 5
DEFAULT_SSL_PORT = 8883
DEFAULT_PORT = 1883
SELECT_TIMEOUT = 0.002

# MAX size of queue
MAX_READ = 10
MAX_PUBACK = 20
MAX_PUBREC = 20
MAX_PUBREL = 20
MAX_PUBCOMP = 20
MAX_WRITING = MAX_PUBACK + MAX_PUBREC + MAX_PUBREL + MAX_PUBCOMP
MAX_SUBACK = 10
MAX_UNSUBACK = 10
MAX_PUBLISH = 1000
MAX_QUEUE = 1000

# Connection states values
MQTT_CS_NEW = 0
MQTT_CS_CONNECTED = 1
MQTT_CS_NEW = 0
MQTT_CS_CONNECTED = 1
MQTT_CS_DISCONNECT = 2

# Error values
MQTT_ERR_SUCCESS = 0
MQTT_ERR_FAIL = 1
MQTT_ERR_FAIL = 1

PACKET_TYPES = [
nil,
Expand Down Expand Up @@ -74,40 +72,40 @@ module PahoMqtt
}

CLIENT_ATTR_DEFAULTS = {
:host => "",
:port => nil,
:mqtt_version => '3.1.1',
:host => "",
:port => nil,
:mqtt_version => '3.1.1',
:clean_session => true,
:persistent => false,
:blocking => false,
:client_id => nil,
:username => nil,
:password => nil,
:ssl => false,
:will_topic => nil,
:will_payload => nil,
:will_qos => 0,
:will_retain => false,
:keep_alive => 60,
:ack_timeout => 5,
:on_connack => nil,
:on_suback => nil,
:on_unsuback => nil,
:on_puback => nil,
:on_pubrel => nil,
:on_pubrec => nil,
:on_pubcomp => nil,
:on_message => nil,
:persistent => false,
:blocking => false,
:client_id => nil,
:username => nil,
:password => nil,
:ssl => false,
:will_topic => nil,
:will_payload => nil,
:will_qos => 0,
:will_retain => false,
:keep_alive => 60,
:ack_timeout => 5,
:on_connack => nil,
:on_suback => nil,
:on_unsuback => nil,
:on_puback => nil,
:on_pubrel => nil,
:on_pubrec => nil,
:on_pubcomp => nil,
:on_message => nil,
}

Thread.abort_on_exception = true

def logger=(logger_path)
file = File.open(logger_path, "a+")
file.sync = true
log_file = Logger.new(file)
file = File.open(logger_path, "a+")
file.sync = true
log_file = Logger.new(file)
log_file.level = Logger::DEBUG
@logger = log_file
@logger = log_file
end

def logger
Expand Down Expand Up @@ -162,22 +160,4 @@ def check_topics(topics, filters)
raise ArgumentError
end
end

class Exception < ::Exception
end

class ProtocolViolation < PahoMqtt::Exception
end

class WritingException < PahoMqtt::Exception
end

class ReadingException < PahoMqtt::Exception
end

class PacketException < PahoMqtt::Exception
end

class LowVersionException < PahoMqtt::Exception
end
end
Loading

0 comments on commit afdb57a

Please sign in to comment.