Class: TimexDatalinkClient::Protocol4::Eeprom

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, Helpers::CpacketPaginator, Helpers::CrcPacketsWrapper
Defined in:
lib/timex_datalink_client/protocol_4/eeprom.rb,
lib/timex_datalink_client/protocol_4/eeprom/list.rb,
lib/timex_datalink_client/protocol_4/eeprom/anniversary.rb,
lib/timex_datalink_client/protocol_4/eeprom/appointment.rb,
lib/timex_datalink_client/protocol_4/eeprom/phone_number.rb

Defined Under Namespace

Classes: Anniversary, Appointment, List, PhoneNumber

Constant Summary collapse

CPACKET_CLEAR =
[0x93, 0x01]
CPACKET_SECT =
[0x90, 0x01]
CPACKET_DATA =
[0x91, 0x01]
CPACKET_END =
[0x92, 0x01]
CPACKET_DATA_LENGTH =
32
START_ADDRESS =
0x0236
APPOINTMENT_NO_NOTIFICATION =
0xff
APPOINTMENT_NOTIFICATION_VALID_MINUTES =
(0..30).step(5)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::CpacketPaginator

#paginate_cpackets

Constructor Details

#initialize(appointments: [], anniversaries: [], phone_numbers: [], lists: [], appointment_notification_minutes: nil) ⇒ Eeprom

Create an Eeprom instance.

Parameters:

  • appointments (Array<Appointment>) (defaults to: [])

    Appointments to be added to EEPROM data.

  • anniversaries (Array<Anniversary>) (defaults to: [])

    Anniversaries to be added to EEPROM data.

  • phone_numbers (Array<PhoneNumber>) (defaults to: [])

    Phone numbers to be added to EEPROM data.

  • lists (Array<List>) (defaults to: [])

    Lists to be added to EEPROM data.

  • appointment_notification_minutes (Integer, nil) (defaults to: nil)

    Appointment notification in minutes.



42
43
44
45
46
47
48
49
50
# File 'lib/timex_datalink_client/protocol_4/eeprom.rb', line 42

def initialize(
  appointments: [], anniversaries: [], phone_numbers: [], lists: [], appointment_notification_minutes: nil
)
  @appointments = appointments
  @anniversaries = anniversaries
  @phone_numbers = phone_numbers
  @lists = lists
  @appointment_notification_minutes = appointment_notification_minutes
end

Instance Attribute Details

#anniversariesObject

Returns the value of attribute anniversaries.



25
26
27
# File 'lib/timex_datalink_client/protocol_4/eeprom.rb', line 25

def anniversaries
  @anniversaries
end

#appointment_notification_minutesObject

Returns the value of attribute appointment_notification_minutes.



25
26
27
# File 'lib/timex_datalink_client/protocol_4/eeprom.rb', line 25

def appointment_notification_minutes
  @appointment_notification_minutes
end

#appointmentsObject

Returns the value of attribute appointments.



25
26
27
# File 'lib/timex_datalink_client/protocol_4/eeprom.rb', line 25

def appointments
  @appointments
end

#listsObject

Returns the value of attribute lists.



25
26
27
# File 'lib/timex_datalink_client/protocol_4/eeprom.rb', line 25

def lists
  @lists
end

#phone_numbersObject

Returns the value of attribute phone_numbers.



25
26
27
# File 'lib/timex_datalink_client/protocol_4/eeprom.rb', line 25

def phone_numbers
  @phone_numbers
end

Instance Method Details

#packetsArray<Array<Integer>>

Compile packets for EEPROM data.

Returns:

  • (Array<Array<Integer>>)

    Two-dimensional array of integers that represent bytes.

Raises:

  • (ActiveModel::ValidationError)

    One or more model values are invalid.



56
57
58
59
60
# File 'lib/timex_datalink_client/protocol_4/eeprom.rb', line 56

def packets
  validate!

  [CPACKET_CLEAR, header] + payloads + [CPACKET_END]
end