Class: Cwmp::Cpe

Inherits:
Object
  • Object
show all
Defined in:
lib/cwmp/cpe.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(acs_url, periodic, h = {}) ⇒ Cpe

Returns a new instance of Cpe.



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/cwmp/cpe.rb', line 12

def initialize (acs_url, periodic, h = {})
    @acs_url = acs_url
    @serial = h[:serial] || "23434ds"
    @oui = h[:oui] || "006754"
    @software_version = h[:software_version] || Cwmp::VERSION
    @manufacturer = h[:manufacturer] || "ruby-cwmp"
    @state = 'off'
    @periodic = Thread.new { periodic periodic } if periodic > 0
    @conn_req = Thread.new { connection_request }
    @xmpp_req = Thread.new { xmpp_connection_request }
    @factory = true
end

Instance Attribute Details

#acs_urlObject

Returns the value of attribute acs_url.



10
11
12
# File 'lib/cwmp/cpe.rb', line 10

def acs_url
  @acs_url
end

#manufacturerObject

Returns the value of attribute manufacturer.



10
11
12
# File 'lib/cwmp/cpe.rb', line 10

def manufacturer
  @manufacturer
end

#ouiObject

Returns the value of attribute oui.



10
11
12
# File 'lib/cwmp/cpe.rb', line 10

def oui
  @oui
end

#serialObject

Returns the value of attribute serial.



10
11
12
# File 'lib/cwmp/cpe.rb', line 10

def serial
  @serial
end

#software_versionObject

Returns the value of attribute software_version.



10
11
12
# File 'lib/cwmp/cpe.rb', line 10

def software_version
  @software_version
end

#stateObject

Returns the value of attribute state.



10
11
12
# File 'lib/cwmp/cpe.rb', line 10

def state
  @state
end

Instance Method Details

#loopObject



52
53
54
55
# File 'lib/cwmp/cpe.rb', line 52

def loop
    @xmpp_req.join
    @conn_req.join
end

#poweroffObject



35
36
37
# File 'lib/cwmp/cpe.rb', line 35

def poweroff
    @state = 'off'
end

#poweronObject



25
26
27
28
29
30
31
32
33
# File 'lib/cwmp/cpe.rb', line 25

def poweron
    @state = 'on'
    if @factory
        do_connection '0 BOOTSTRAP'
    else
        do_connection '1 BOOT'
    end
    @factory = false
end

#rebootObject



39
40
41
42
43
44
# File 'lib/cwmp/cpe.rb', line 39

def reboot
    @state = 'off'
    sleep 2
    @state = 'on'
    do_connection '1 BOOT'
end

#resetObject



46
47
48
49
50
# File 'lib/cwmp/cpe.rb', line 46

def reset
    poweroff
    @factory = true
    poweron
end