Class: Dovado::Router

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/dovado/router.rb,
lib/dovado/router/sms.rb,
lib/dovado/router/info.rb,
lib/dovado/router/traffic.rb,
lib/dovado/router/internet.rb,
lib/dovado/router/services.rb,
lib/dovado/router/info/signal.rb,
lib/dovado/router/sms/message.rb,
lib/dovado/router/sms/messages.rb,
lib/dovado/router/info/operator.rb,
lib/dovado/router/traffic/amount.rb,
lib/dovado/router/info/operator/telia.rb

Overview

A Dovado Router.

Since:

  • 1.0.0

Defined Under Namespace

Classes: Info, Internet, Services, Sms, Traffic

Instance Method Summary collapse

Constructor Details

#initialize(args = nil) ⇒ Router

Create a new Dovado::Router object representing an actual Dovado router on the local network.

The default router options are:

  • Address: 192.168.0.1

  • Port: 6435

  • User: admin

  • Password: password

Parameters:

  • args (Hash) (defaults to: nil)

    optional arguments.

Options Hash (args):

  • :address (String)

    IP address or DNS name

  • :port (Integer)

    Port which the router is listening on

  • :user (String)

    User name

  • :password (String)

    Password

Since:

  • 1.0.0



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/dovado/router.rb', line 22

def initialize(args=nil)
  @address    = '192.168.0.1' # Default address
  @port       = 6435
  @user        = "admin"       # Default username
  @password    = "password"    # Default password
  @connected  = false
  unless args.nil?
    @address  = args[:address]  if args.has_key? :address
    @port     = args[:port]     if args.has_key? :port
    @user      = args[:user]     if args.has_key? :user
    @password  = args[:password] if args.has_key? :password
  end

  supervise_client
end

Instance Method Details

#infoInfo

Fetch information from the router.

Returns:

See Also:

  • {Info}

Since:

  • 1.0.0



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/dovado/router.rb', line 84

def info
  Info.setup_supervision!
  client = Actor[:client]
  router_info = Actor[:router_info]
  router_info.update! unless router_info.valid?

  services
  router_info
rescue ConnectionError => ex
  Actor[:client].terminate
  supervise_client
  supervise_info
  raise ex
end

#internetInternet

Get the Internet Connection object.

Returns:

  • (Internet)

    the Internet Connection object.

See Also:

  • {Internet}

Since:

  • 1.0.2



66
67
68
69
# File 'lib/dovado/router.rb', line 66

def internet
  Internet.setup_supervision!
  Actor[:internet]
end

#servicesServices

Fetch services information from the router.

Returns:

See Also:

  • {Services}

Since:

  • 1.0.0



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/dovado/router.rb', line 42

def services
  Services.setup_supervision!
  client = Actor[:client]
  router_services = Actor[:router_services]

  router_services.update! unless router_services.valid?

  if router_services[:sms] == 'enabled'
    
    Sms.setup_supervision!
    sms.enabled = true
  end
  router_services
rescue ConnectionError => ex
  Actor[:client].terminate
  supervise_client
  supervise_services
  raise ex
end

#smsSms

Fetch text messages from the router.

Returns:

See Also:

  • {Sms}

Since:

  • 1.0.0



103
104
105
106
# File 'lib/dovado/router.rb', line 103

def sms
  Sms.supervise as: :sms, size: 1 unless Actor[:sms]
  Actor[:sms]
end

#trafficTraffic

Get the Data Traffic object.

Returns:

  • (Traffic)

    the Data Traffic object

See Also:

  • {Traffic}

Since:

  • 1.0.2



75
76
77
78
# File 'lib/dovado/router.rb', line 75

def traffic
  Traffic.setup_supervision!
  Actor[:traffic]
end