@echo off
SET PATH=c:\tizen-studio\tools;%PATH%

sdb root on

sdb shell mkdir -p /tmp/patchtmp
sdb shell mount -o remount,rw /
timeout /t 1 /nobreak
sdb shell mount -o remount.rw /hal

FOR /F %%g IN ('sdb shell uname -m') do SET ARCH=%%g
ECHO %ARCH%

ECHO ---- Install drvier (sdb push) ----
sdb shell rpm -e --nodeps wlandrv-plugin-tizen

sdb push ./noarch/connectivity/wifi-mesh/* /usr/lib/firmware/

IF %ARCH% == aarch64 ( CALL :install_64bit_plugins ) ELSE (
	IF %ARCH% == armv7l ( CALL :install_32bit_plugins) ELSE (
		ECHO Unknown Arch : %ARCH%
		ECHO Failed to install plugins
		EXIT /B -1
	)
)

sdb shell rpm -Uvh --force --nodeps /tmp/patchtmp/wlandrv-plugin-tizen*.rpm
sdb shell rm -rf /tmp/patchtmp

ECHO ----- Sync and reboot -----
sdb shell sync
sdb shell reboot

EXIT /B 0

:install_64bit_plugins
ECHO ----- install 64bit plugins -----
sdb push ./64bit/connectivity/wlandrv-plugin-tizen*.rpm /tmp/patchtmp
EXIT /B 0

:install_32bit_plugins
ECHO ----- install 32bit plugins -----
sdb push ./32bit/connectivity/wlandrv-plugin-tizen*.rpm /tmp/patchtmp
EXIT /B 0
