자유롭게 질의 및 응답을 할 수 있는 게시판입니다. 개발자 여러분의 답변이 큰 도움이 됩니다. 
  • 제품설치/등록 오류 문의: 설치/등록 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 19434
공지 유용한 관련 사이트 관리자2 2014.03.20 58347
공지 본 게시판은 개발자 여러분들의 질문과 답변을 공유하는 공간입니다. 관리자 2012.01.10 101853
1699 MDI Child Dll [2] 라시드 2015.10.26 372
1698 firedac 질문입니다 [2] 희망나라 2021.05.19 372
1697 IOS 화면 가로 고정으로 배포 오류 문의 [4] 2an 2021.08.04 373
1696 Troubleshooting cannot deploy an application for android에러 [2] file 김태윤 2016.05.23 373
1695 시애틀 업데이트팩 1설치후 컴파일 불가 [2] KayKim 2017.04.05 374
1694 cap파일 배포시 인증 문제에 대한 자문을 요청드립니다. [1] 데브기어 2017.11.15 374
1693 PageControl 컴포넌트에서...? [2] 헨씀히포 2019.12.06 374
1692 델파이 10.1 - 안드로이드 서비스 개발시 'activity not found, maybe you are in a service' 에러 [3] 봄이아빠 2017.03.30 374
1691 스마트폰에서 폼 종료 방법을 알려주세요. [1] 거북이 2015.11.03 374
1690 XE8 OS 32bit에서는 FireDAC CreateDB가 잘 되는데 64bit로 빌더를 바꿔서 하면 에라가 발생? 바람돌이 2016.07.12 375
1689 데이터스냅 콜백 오류 문의 [3] file 회원 2016.10.14 375
1688 [XE8 출시세미나] 기존에 유니코드가 아니라 ANSI를 사용하고 있습니다. 델파이 2009 버전 이상에서는 무조건 유니코드를 써야하나요? 업그레이드 하더라도 ANSI를 계속 사용하려면 어떻게 하나요? [1] 관리자 2015.04.30 376
1687 DataSnap ClientDataSet 연결문의드립니다. [1] 블랙 2021.04.06 376
1686 C/C#으로 만들어진 SDK 델파이에서 사용방법. [3] 엔달 2018.04.25 377
1685 delphi 베를린 android database 에러 질문합니다. [4] devdev 2018.10.05 377
1684 오라클-FireDAC 배포시 cannot initialize oci environment 오류 발생 문의 드립니다. [3] agallee 2020.10.28 377
1683 [질문] DataSnap과 Mobile 연결 [2] 오는새벽 2021.02.25 377
1682 모바일 앱 개발 시 구글음성 입력 기능을 호출하는 샘플이 있나요? [1] 손보라 2017.04.14 378
1681 Android에서 TImage 의 크기가 왜 변하나요? [2] file 쿠리 2017.07.05 378
1680 디버깅 시 tList<t>.List w.a.t.c.h. 이상 작동 [9] 신재국 2020.02.25 378