자유롭게 질의 및 응답을 할 수 있는 게시판입니다. 개발자 여러분의 답변이 큰 도움이 됩니다. 
  • 제품설치/등록 오류 문의: 설치/등록 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 15759
공지 유용한 관련 사이트 관리자2 2014.03.20 54576
공지 본 게시판은 개발자 여러분들의 질문과 답변을 공유하는 공간입니다. 관리자 2012.01.10 97973
3238 10.4 시드니에서 새로운 프로젝트 시작 오류 [2] file midas 2021.05.25 504
3237 퀵리포트 -> PDF 변환 시 한글 깨짐 현상 질문입니다. [3] 으아앙 2021.06.03 813
3236 ApeSuite 사용법 SSI 2021.06.08 304
3235 Delphi 10.4 버전 맥용으로 컴파일시 오류 발생하는 이유가 궁금합니다. [2] 델포이 2021.06.04 346
3234 mac os 개발 환결 세팅 관련 문의. [2] 델포이 2021.06.03 344
3233 Runtime error 216 at 5005F106 [2] 김동현 2021.05.28 482
3232 Delphi XE10.3의 TLabel이 Transparent가 안되는 문제 질문 [1] DevCK 2021.05.25 4993
3231 firedac 질문입니다 [2] 희망나라 2021.05.19 354
3230 png Image Button에서 Flickering문제 [5] 오늘도좋은하루 2021.05.12 512
3229 10.4 시드니에서 QuickReport Pro 6 이 설치되나요? [23] 왕초보 2020.10.06 2920
3228 Delphi 7 REST Client 개발 문의 [2] DevCK 2021.05.12 817
3227 본사 mypage [1] DHP 2021.05.17 2604
3226 통화목록 관련 [1] 100jk 2021.05.14 7757
3225 XE7에서 bpl 컴포넌트 설치가 안됩니다. [1] 김동현 2021.05.13 450
3224 [마이그레이션] del7 소스를 10.2.3 tokyo prof. 에서 compile 도중 생긴 에러입니다. [2] darwin4078 2021.05.12 317
3223 [BRCC32 Error] "brcc32" exited with code 27. [3] file Dev_기어 2021.05.07 617
3222 IOS 새로고침 드래그시 이슈 delphiman 2021.05.06 232
3221 Android 컴파일 오류 [2] file 초보개발자 2021.04.07 409
3220 FireDAC을 사용한 MySQL관련 입니다. [2] file 오늘도좋은하루 2021.04.28 371