<%
@analog_pins = get_pins(@analog_inputs, "A")
@output_pins = get_pins(@digital_outputs, "O")
@output_hash = {}
@digital_outputs.each do |o|
  @output_hash[o.id] = o.id
end
-%>
YAHMS
A:<%=@analog_pins.join(",")%>
O:<%=@output_pins.join(",")%>
<%
if @base_station.xbee_rx_pin and @base_station.xbee_tx_pin
-%>
X:<%=@base_station.xbee_rx_pin%>,<%=@base_station.xbee_tx_pin%>
<%
end
-%>
<%
@control_blocks.each do |cb|
  # Check that the output hasn't been deactivated
  if @output_hash[cb.digital_output_id]
-%>
<%=cb.to_api%>
<%
  end
end

if @base_station.timezone and @base_station.timezone != ""
  tz = TZInfo::Timezone.get(@base_station.timezone)
  now = Time.now.utc
  local = tz.utc_to_local(now)
  offset = ( local.to_i - now.to_i ) / 60
-%>
S:<%=offset%>,<%=@base_station.config_updated_at.to_i%>
<%
end
-%>

<%
@analog_pins = get_pins(@analog_inputs, "A")
@output_pins = get_pins(@digital_outputs, "O")
@output_hash = {}
@digital_outputs.each do |o|
  @output_hash[o.id] = o.id
end
-%>
YAHMS
A:<%=@analog_pins.join(",")%>
O:<%=@output_pins.join(",")%>
<%
if @base_station.xbee_rx_pin and @base_station.xbee_tx_pin
-%>
X:<%=@base_station.xbee_rx_pin%>,<%=@base_station.xbee_tx_pin%>
<%
end
-%>
<%
@control_blocks.each do |cb|
  # Check that the output hasn't been deactivated
  if @output_hash[cb.digital_output_id]
-%>
<%=cb.to_api%>
<%
  end
end

if @base_station.timezone and @base_station.timezone != ""
  tz = TZInfo::Timezone.get(@base_station.timezone)
  now = Time.now.utc
  local = tz.utc_to_local(now)
  offset = ( local.to_i - now.to_i ) / 60
-%>
S:<%=offset%>
<%
end
-%>
T:<%=@base_station.config_updated_at.to_i%>,<%=Time.now.utc.to_i%>
!

Send time of config in response, and EOF char.
Send time of config in response, and EOF char.