자유롭게 질의 및 응답을 할 수 있는 게시판입니다. 개발자 여러분의 답변이 큰 도움이 됩니다. 
  • 제품설치/등록 오류 문의: 설치/등록 Q&A 이용 (제품 구매 고객 한정)

본 게시판은 개발자들이 자유롭게 질문과 답변을 공유하는 게시판입니다.
* 따라서 최대한 정중하게 질문을 올려 주세요.
* 질문을 상세히 작성해 주실 수록 좋은 답변이 올라 옵니다.
* 다른 분들도 참고할 수 있도록 결과 댓글 필수(또는 감사 댓글)
(결과 댓글을 달지 않는 경우 다음 질문에 대한 답변이 달리지 않는 불이익이 있을 수 있습니다.)
-----------------------------------------------------------------------------------------------
 

위험지역 경보 시스템 #1 - 비콘을 이용해 위험지역 진입 경보앱 만들기

 

위험지역 경보시스템 비콘을 이용해서 위험지역 진입시 경보음이 울리는 앱을 만들었는데

안드로이드 핸드폰에 어플을 배포하고 실행했으나

비콘 제조업체에서 제공한 어플로 비콘의 UUID를 찾았지만

만든 앱에서는 비콘이 인식되지 않는것 같습니다. 

이럴때에는 어떻게 해결해야하는거일까요?

 

unit MainForm4;

 

interface

 

uses

  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,

  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.Ani,

  FMX.Layouts, System.Beacon, System.Beacon.Components, FMX.Media,

  FMX.Objects, FMX.StdCtrls, FMX.Controls.Presentation, System.IOUtils,

  System.Bluetooth;

 

type

  TForm1 = class(TForm)

    ToolBar1: TToolBar;

    Label1: TLabel;

    Switch1: TSwitch;

    Image1: TImage;

    StatusBar1: TStatusBar;

    Label2: TLabel;

    Rectangle1: TRectangle;

    Layout1: TLayout;

    Label3: TLabel;

    lblDistance: TLabel;

    MediaPlayer1: TMediaPlayer;

    FloatAnimation1: TFloatAnimation;

    Beacon1: TBeacon;

    Timer1: TTimer;

    procedure Beacon1BeaconEnter(const Sender: TObject; const ABeacon: IBeacon;

      const CurrentBeaconList: TBeaconList);

    procedure Beacon1BeaconExit(const Sender: TObject; const ABeacon: IBeacon;

      const CurrentBeaconList: TBeaconList);

    procedure Switch1Switch(Sender: TObject);

    procedure Timer1Timer(Sender: TObject);

  private

    { Private declarations }

    FIsWarning: Boolean;

// 경고 중인가?

    FDangerAreaStaySecs,

// 위험지역에 머무른 시간(초)

    FDangerAreaOutSecs: Integer;

// 위험지역에서 벗어난 시간(초)

    FBeacon: IBeacon;

  procedure StartWarning;

// 위험지역 진입 경고 시작

  procedure StopWarning;

// 위험지역 진입 경고 중지

 

  procedure StartSiren;

// 사이렌 시작

  procedure StopSiren;

// 사이렌 중지

  public

    { Public declarations }

  end;

 

var

  Form1: TForm1;

 

implementation

 

{$R *.fmx}

 

{ TForm1 }

 

procedure TForm1.Beacon1BeaconEnter(const Sender: TObject;

  const ABeacon: IBeacon; const CurrentBeaconList: TBeaconList);

begin

  FBeacon := ABeacon;

end;

 

procedure TForm1.Beacon1BeaconExit(const Sender: TObject;

  const ABeacon: IBeacon; const CurrentBeaconList: TBeaconList);

begin

  FBeacon := nil;

end;

 

procedure TForm1.StartSiren;

begin

  MediaPlayer1.FileName := TPath.Combine(TPath.GetDocumentsPath, 'alert.mp3');

  MediaPlayer1.Play;

end;

 

procedure TForm1.StopSiren;

begin

  MediaPlayer1.Stop;

end;

 

procedure TForm1.StartWarning;

begin

  Rectangle1.Visible := True;

  FloatAnimation1.Enabled := True;

 

  StartSiren;

end;

 

procedure TForm1.StopWarning;

begin

  Rectangle1.Visible := False;

  FloatAnimation1.Enabled := False;

 

  StopSiren;

end;

 

procedure TForm1.Switch1Switch(Sender: TObject);

begin

  Beacon1.Enabled := Switch1.IsChecked;

end;

 

procedure TForm1.Timer1Timer(Sender: TObject);

var

  InDangerArea: Boolean;

// 위험지역에 있는가?(비콘과의 거리가 1m 이내인가?)

begin

   if Assigned(FBeacon) then

  begin

    InDangerArea := FBeacon.Distance <= 1;

 

 

// 경고 중 아님

 

// 위험지역에 3초간 머무른 경우 경고 시작

    if not FIsWarning then

    begin

      if InDangerArea then

        Inc(FDangerAreaStaySecs)

      else

        FDangerAreaStaySecs := 0

      ;

 

      if FDangerAreaStaySecs >= 3 then

      begin

        FIsWarning := True;

        StartWarning;

        FDangerAreaStaySecs := 0

      end;

    end

 

// 경고 중

 

// 위험지역을 3초 이상 벗어난 경우 경고 중단

    else if FIsWarning then

    begin

      if not InDangerArea then

        Inc(FDangerAreaOutSecs)

      else

        FDangerAreaOutSecs := 0;

 

      if FDangerAreaOutSecs >= 3 then

      begin

        FIsWarning := False;

        StopWarning;

        FDangerAreaOutSecs := 0;

       end;

    end;

 

 

// 위험지역과의 거리를 표시

    lblDistance.Text := FBeacon.Distance.ToString;

    Label3.Text := '주면에 노약자와의 거리: ' + FBeacon.Distance.ToString + ' m';

  end;

end;

 

end.

번호 제목 글쓴이 날짜 조회 수
공지 [프로그래밍 강의] 2021.6~2021.12 관리자 2015.01.22 17160
공지 유용한 관련 사이트 관리자2 2014.03.20 56027
공지 본 게시판은 개발자 여러분들의 질문과 답변을 공유하는 공간입니다. 관리자 2012.01.10 99459
1719 Delphi 10.2.1 Update후 MSSQL 2000 연결시 오류가 납니다. 불나방 2017.12.18 352
1718 서브폼 Close시 메인폼 활성화문제 라운지 2015.09.16 352
1717 Delphi 10.4 버전 맥용으로 컴파일시 오류 발생하는 이유가 궁금합니다. [2] 델포이 2021.06.04 352
1716 XE8 REST JSON 데이터 서비스 문제문의 [1] file 디알H 2015.07.11 353
1715 Troubleshooting cannot deploy an application for android에러 [2] file 김태윤 2016.05.23 353
1714 델파이에서 데이터베이스 연결 시 TCPIP 방법으로도 가능한가요? [1] 손보라 2017.04.11 353
1713 답변이 없으셔서 다시 문의 합니다.(Rest 컴포넌트 관련) [3] 제트콜 2017.09.15 353
1712 모바일에서 이미지 로딩시, 사진 방향이 바뀌는 이유 [3] delphiman 2021.01.26 353
1711 IOS 화면 가로 고정으로 배포 오류 문의 [4] 2an 2021.08.04 354
1710 아이폰 상태바에 내용이 안보이고 그만큼 잘리는 현상입니다. [1] gildata 2017.10.19 354
1709 안드로이드 API Level 26 문제 [1] 토끼왕 2018.10.06 354
1708 링크드리스트 구현 질문입니다. 델리아끼 2015.11.04 354
» RAD Studio 10.3 비콘관련 문의드립니다. [3] 정은은은 2019.05.14 355
1706 stringgrid에 넣은 Image 클릭 이벤트 발생을 어떻게 해야 하나요? [1] 초보델팡이 2019.06.11 355
1705 IBLite 연결 질문~ [2] file 아놀드 2016.01.11 355
1704 안드로이드 개발시 TComboBox 폰트 적용을 어떻게 하나요? [4] 광땡 2015.10.28 355
1703 문장안에 숨어있는 아스키값을 표시할순 없을까요? [1] file 라빌레나 2020.07.29 355
1702 TWebBrowser를 통한 JS에서 FMX앱의 Function, Procedure 실행 문의 [1] 나즈나 2017.11.10 356
1701 [XE8 출시세미나] 파이어몽키 앱에서 안드로이드 라이브러리에 포함된 화면(Activity)를 연동하려면 어떻게 하나요? [1] Humphery 2015.04.30 356
1700 TIdHTTP로 웹서버에 배열로 호출을 할 수 있나요? [1] 데브기어 2017.01.20 356