INCLUDE rtcu.inc
VAR_INPUT
END_VAR;
VAR_OUTPUT
END_VAR;
VAR
END_VAR;
FUNCTION CALLBACK cbAdvName;
VAR_INPUT
mac : STRING;
ev_type : UINT;
adv_type : USINT;
data : PTR;
len : INT;
rssi : SINT;
arg : DINT;
END_VAR;
VAR
str : STRING;
END_VAR;
str:=strFromMemory(src:=data, len:=len);
DebugFmt(message:=mac+" (\1): "+str, v1:=rssi);
END_FUNCTION;
PROGRAM ex_scan;
VAR
rc : INT;
END_VAR;
rc := blePower(power:=ON);
DebugFmt(message:="blePower: \1", v1:=rc);
rc := bleRegisterAdvData(cb_Adv:=@cbAdvName, adv_type := 16#09);
DebugFmt(message:="BleRegisterAdvData: \1", v1:=rc);
rc := bleObserverStart(
scan_type:=1,
filter_policy := 0
);
DebugFmt(message:="bleObserverStart: \1", v1:=rc);
BEGIN
Sleep(delay:=10000);
END;
END_PROGRAM;
|