anchor.diff:          [L] ->
               case fcnt_gap(L#link.fcntup, FCnt) of
                   N when N < ?MAX_FCNT_GAP ->
  -                    mnesia:dirty_write(links, L#link{fcntup=FCnt}),
  +                    NewFCnt = (L#link.fcntup + N) band 16#FFFFFFFF,
  +                    mnesia:dirty_write(links, L#link{fcntup = NewFCnt}),
                       {ok, L};
                   BigN ->
                       {error, {fcnt_gap_too_large, BigN}}
  
positive.code:     end.
  
  fcnt_gap(A, B) ->
      if
          A =< B -> B - A;
          A > B -> 16#FFFF - A + B
      end.
  
  store_rxpk(MAC, RxQ, RF, DevAddr, FCnt, Data) ->
  
negative.code: txpk(Time, RF, DevAddr, FPort, Data) ->
      {atomic, L} = mnesia:transaction(fun() ->
          [D] = mnesia:read(links, DevAddr, write),
          FCnt =  (D#link.fcntdown + 1) band 16#FFFFFFFF,
          NewD = D#link{fcntdown=FCnt},
          mnesia:write(links, NewD, write),
          NewD
  