<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<BODY>
<?php
include(
'yocto_api.php'
)
;
include(
'yocto_gps.php'
)
;
// Use explicit error handling rather than exceptions
//yDisableExceptions();
// Setup the API to use the VirtualHub on local machine
if(
yRegisterHub
(
'http://127.0.0.1:4444/'
,$errmsg
)
!= YAPI_SUCCESS
)
{
die
(
"Cannot contact VirtualHub on 127.0.0.1"
)
;
}
@$serial = $_GET
[
'serial'
]
;
if
(
$serial !=
''
)
{
// Check if a specified module is available online
$gps = yFindGps
(
"
$serial
.gps"
)
;
if
(
!$gps->
isOnline
())
{
die
(
"Module not connected (check serial and USB cable)"
)
;
}
}
else
{
// or use any connected module suitable for the demo
$gps = yFirstGps
()
;
if(
is_null
(
$gps
))
{
die
(
"No module connected (check USB cable)"
)
;
}
else
{
$serial = $gps->
module
()
->
get_serialnumber
()
;
}
}
Print(
"Module to use: <input name='serial' value='
$serial
'><br>"
)
;
if
(
$gps->
get_isFixed
()
!=Y_ISFIXED_TRUE
)
Print(
"Gps : fixing...<br>"
)
;
else
Printf
(
"Gps :
%s
%s
<br>"
, $gps->
get_latitude
()
, $gps->
get_longitude
())
;
yFreeAPI
()
;
// trigger auto-refresh after one second
Print(
"<script language='javascript1.5' type='text/JavaScript'>
\n
"
)
;
Print(
"setTimeout('window.location.reload()',1000);"
)
;
Print(
"</script>
\n
"
)
;
?>
</BODY>
</HTML>
8.3. Control of the module part
Each module can be controlled in a similar manner, you can find below a simple sample program
displaying the main parameters of the module and enabling you to activate the localization beacon.
<HTML>
<HEAD>
<TITLE>Module Control</TITLE>
</HEAD>
<BODY>
<FORM method='get'>
<?php
include(
'yocto_api.php'
)
;
// Use explicit error handling rather than exceptions
yDisableExceptions
()
;
// Setup the API to use the VirtualHub on local machine
if(
yRegisterHub
(
'http://127.0.0.1:4444/'
,$errmsg
)
!= YAPI_SUCCESS
)
{
die
(
"Cannot contact VirtualHub on 127.0.0.1 : "
.$errmsg
)
;
}
@$serial = $_GET
[
'serial'
]
;
if
(
$serial !=
''
)
{
8. Using Yocto-GPS with PHP
www.yoctopuce.com
51
Summary of Contents for Yocto-GPS
Page 1: ...Yocto GPS User s guide...
Page 2: ......
Page 6: ...22 Characteristics 557 Blueprint 559 Index 561...
Page 10: ...4 www yoctopuce com...
Page 14: ...8 www yoctopuce com...
Page 18: ...12 www yoctopuce com...
Page 22: ...16 www yoctopuce com...
Page 38: ...32 www yoctopuce com...
Page 42: ...36 www yoctopuce com...
Page 54: ...48 www yoctopuce com...
Page 72: ...66 www yoctopuce com...
Page 92: ...86 www yoctopuce com...
Page 122: ...116 www yoctopuce com...
Page 132: ...126 www yoctopuce com...
Page 564: ...22 Characteristics 558 www yoctopuce com...
Page 565: ......
Page 566: ......