Class: Sim800c::Client

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/sim800c/client.rb

Instance Method Summary collapse

Methods included from Helpers

#at_cmd, #parse_cmgl_response, #read_response, #return_or_raise_error!

Constructor Details

#initialize(port_path, baud: 9600) ⇒ Client

Returns a new instance of Client.



15
16
17
18
# File 'lib/sim800c/client.rb', line 15

def initialize(port_path, baud: 9600)
  require 'rubyserial'
  @serial = Serial.new(port_path, baud)
end

Instance Method Details

#delete_messageObject

Methods: .by_index, .all_read, .all_read_and_sent, .all_read_sent_and_unsent



41
42
43
# File 'lib/sim800c/client.rb', line 41

def delete_message
  Commands::DeleteMessage.new(@serial)
end

#deviceObject

Methods: .battery_info



51
52
53
# File 'lib/sim800c/client.rb', line 51

def device
  Commands::Device.new(@serial)
end

#list_messagesObject

Methods: .all, .unread, .read, .unsent, .sent (Hash)



31
32
33
# File 'lib/sim800c/client.rb', line 31

def list_messages
  Commands::ListMessages.new(@serial)
end

#save_and_send_message(phone_number, message) ⇒ Object

Store and send (AT+CMGW = store, AT+CMSS = send)



26
27
28
# File 'lib/sim800c/client.rb', line 26

def save_and_send_message(phone_number, message)
  Commands::SendMessage.new(@serial).save_and_send(phone_number, message)
end

#send_message(phone_number, message) ⇒ Object

Sends message immediately (does not store sent messages)



21
22
23
# File 'lib/sim800c/client.rb', line 21

def send_message(phone_number, message)
  Commands::SendMessage.new(@serial).send_immediate(phone_number, message)
end

#signal_qualityObject

Methods: .info (Hash), .rssi (Integer)



36
37
38
# File 'lib/sim800c/client.rb', line 36

def signal_quality
  Commands::SignalQuality.new(@serial)
end

#storage_infoObject

Checks storage info



46
47
48
# File 'lib/sim800c/client.rb', line 46

def storage_info
  Commands::StorageInfo.new(@serial).call
end