TBeacon を使ったコード断片

iBeacon や AltBeacon を Delphi の TBeacon で受けてボタンの色を変えたりTMemo(複数行テキスト)に行挿入したりするコード断片。
TBeacon において、Major や Minor を -1 に設定すると、指定の UUID のものすべてを受信するようになります。

procedure TForm1.DisplayBeacon(const ABeacon: IBeacon);
var
  Msg: string;
begin
  case ABeacon.Proximity of
    TBeaconProximity.Immediate:
      begin
        Msg := 'Proximity: Imme: (' + IntToStr(ABeacon.Major) + ',' +
          IntToStr(ABeacon.Minor) + '): ' +
          Format('%f', [ABeacon.Distance]) + 'm';
        ColorButton1.Color := TAlphaColorRec.Green;
      end;
    TBeaconProximity.Near:
      begin
        Msg := 'Proximity: Near: (' + IntToStr(ABeacon.Major) + ',' +
          IntToStr(ABeacon.Minor) + '): ' +
          Format('%f', [ABeacon.Distance]) + 'm';
        ColorButton1.Color := TAlphaColorRec.Yellow;
      end;
    TBeaconProximity.Far:
      begin
        Msg := 'Proximity: Far: (' + IntToStr(ABeacon.Major) + ',' +
          IntToStr(ABeacon.Minor) + '): ' +
          Format('%f', [ABeacon.Distance]) + 'm';
        ColorButton1.Color := TAlphaColorRec.Purple;
      end;
    TBeaconProximity.Away:
      begin
        Msg := 'Proximity: Away: (' + IntToStr(ABeacon.Major) + ',' +
          IntToStr(ABeacon.Minor) + ')';
        ColorButton1.Color := TAlphaColorRec.White;
      end;
  end;
  Memo1.Lines.Insert(0, Msg);
end;