anchor.diff:      handle_ping(State);
   handle_info({publish, Topic, Payload}, State) ->
       handle_consume(Topic, Payload, State);
  -handle_info({'EXIT', C, {shutdown, {connack_error, 'CONNACK_PROTO_VER'}}}, State=#state{cargs=CArgs, ver=4}) ->
  +handle_info({'EXIT', C, {shutdown, _Error}}, State=#state{cargs=CArgs, phase=connect311}) ->
       % downgrade to MQTT 3.1
       {ok, C} = emqttc:start_link([{proto_ver, 3} | CArgs]),
  -    {noreply, State#state{ver=3, mqttc=C}};
  +    {noreply, State#state{phase=connect31, mqttc=C}};
   handle_info({'EXIT', C, {shutdown, Error}}, State=#state{mqttc=C, ping_timer=Timer}) ->
       maybe_cancel_timer(Timer),
       {stop, {shutdown, Error}, State};
  
positive.code: 
  
  handle_connect(#state{subscribe=undefined}=State) ->
      {noreply, State};
  handle_connect(#state{mqttc=C, subscribe=Topic}=State) ->
      emqttc:subscribe(C, Topic, 1),
      Timer = schedule_refresh(),
      {noreply, State#state{ping_timer=Timer}}.
  
  handle_ping(State=#state{mqttc=C}) ->
      pong = emqttc:ping(C),
  
negative.code: 
  -include("lorawan.hrl").
  
  -record(state, {cargs, phase, mqttc, ping_timer, subscribe, published, consumed}).
  
  start_link(ConnUri, Conn) ->
      gen_server:start_link(?MODULE, [ConnUri, Conn], []).
  