PHP code example of tuupola / corelocation

1. Go to this page and download the library: Download tuupola/corelocation library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

tuupola / corelocation example snippets




use Tuupola\CoreLocation\Request;

$request = new Request(["aa:aa:aa:aa:aa:aa", "bb:bb:bb:bb:bb:bb"]);
$hex = bin2hex($request->body());
print_r(str_split($hex, 64));

/*
Array
(
    [0] => 00010005656e5f55530013636f6d2e6170706c652e6c6f636174696f6e64000c
    [1] => 382e342e312e313248333231000000010000002c12130a1161613a61613a6161
    [2] => 3a61613a61613a616112130a1162623a62623a62623a62623a62623a62622064
)
*/



use Tuupola\CoreLocation\Response;

$data = file_get_contents("response.bin");
$response = (new Response)->fromString($data);

foreach ($response as $router) {
    print_r($router);
}

/*
Array
(
    [mac] => cc:cc:cc:cc:cc:cc
    [latitude] => 27.98785,
    [longitude] => 86.9228374
    [accuracy] => 42
    [channel] => 10
)
...
*/