@echo off
REM * Copyright 2013 Broadcom Corporation -- http://www.broadcom.com
REM * This program is the proprietary software of Broadcom Corporation and/or
REM * its licensors, and may only be used, duplicated, modified or distributed
REM * pursuant to the terms and conditions of a separate, written license
REM * agreement executed between you and Broadcom (an "Authorized License").
REM * Except as set forth in an Authorized License, Broadcom grants no license
REM * (express or implied), right to use, or waiver of any kind with respect to
REM * the Software, and Broadcom expressly reserves all rights in and to the
REM * Software and all intellectual property rights therein. IF YOU HAVE NO
REM * AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY
REM * WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE ALL USE OF
REM * THE SOFTWARE.

REM Enable "trace configuration" for Location driver and GNSS engine
reg import "%~dp0..\LogTrace.reg"

REM Disable location driver
"%~dp0..\..\Tools\devcon.exe" disable "Sensors\BcmGnssLocationSensor*" 

REM Start trace
tracelog.exe -start Location -guid "%~dp0TraceGuid.txt" -f "%~dp0Location.etl" -flag 0xFFFF -level 0xFFFFFFFFFFFFFFFF || goto USER_ERROR

REM Enable location driver for "trace configuration" to take effect
"%~dp0..\..\Tools\devcon.exe" enable "Sensors\BcmGnssLocationSensor*" 

REM Configure the pdb files for running TraceOut.bat in future
call "%~dp0TracePdb.bat"

goto FINISH

:USER_ERROR
echo.
@echo  
echo ======================== SUGGESTIONS ========================
echo Ensure tracelog.exe from Windows Kits is copied to %SystemRoot%\
echo Run as administrator might also help
echo Otherwise, the trace session was already started
echo ======================== SUGGESTIONS ========================
pause
:FINISH

