// Get access to your device, through the VirtualHub running locally
yRegisterHub
(
'http://127.0.0.1:4444/'
,$errmsg
)
;
$latitude = yFindLatitude
(
"YGNSSMK1-123456.latitude"
)
;
// Check that the module is online to handle hot-plug
if(
latitude->
isOnline
())
{
// Use latitude->get_currentValue(), ...
}
Let's look at these lines in more details.
yocto_api.php and yocto_latitude.php
These two PHP includes provides access to the functions allowing you to manage Yoctopuce
modules.
yocto_api.php
must always be included,
yocto_latitude.php
is necessary to
manage modules containing a latitude sensor, such as Yocto-GPS.
yRegisterHub
The
yRegisterHub
function allows you to indicate on which machine the Yoctopuce modules are
located, more precisely on which machine the VirtualHub software is running. In our case, the
127.0.0.1:4444
address indicates the local machine, port
4444
(the standard port used by
Yoctopuce). You can very well modify this address, and enter the address of another machine on
which the VirtualHub software is running.
yFindLatitude
The
yFindLatitude
function allows you to find a latitude sensor from the serial number of the
module on which it resides and from its function name. You can use logical names as well, as long
as you have initialized them. Let us imagine a Yocto-GPS module with serial number
YGNSSMK1-123456
which you have named "
MyModule
", and for which you have given the
latitude
function the name "
MyFunction
". The following five calls are strictly equivalent, as long as
"
MyFunction
" is defined only once.
$latitude = yFindLatitude
(
"YGNSSMK1-123456.latitude"
)
;
$latitude = yFindLatitude
(
"YGNSSMK1-123456.MyFunction"
)
;
$latitude = yFindLatitude
(
"MyModule.latitude"
)
;
$latitude = yFindLatitude
(
"MyModule.MyFunction"
)
;
$latitude = yFindLatitude
(
"MyFunction"
)
;
yFindLatitude
returns an object which you can then use at will to control the latitude sensor.
isOnline
The
isOnline()
method of the object returned by
yFindLatitude
allows you to know if the
corresponding module is present and in working order.
get_latitude
The
get_latitude()
method of the object returned by
yFindGps
provides the latitude currently
measured by the Yocto-GPS. The value returned is a string, the format will vary according to the
Yocto-GPS configuration. To get a floating point value, no matter the configuartion, use the YLatitude
Class.
A real example
Open your preferred text editor
4
, copy the code sample below, save it with the Yoctopuce library files
in a location which is accessible to you web server, then use your preferred web browser to access
this page. The code is also provided in the directory
Examples/Doc-GettingStarted-Yocto-GPS
of
the Yoctopuce library.
In this example, you will recognize the functions explained above, but this time used with all side
materials needed to make it work nicely as a small demo.
4
If you do not have a text editor, use Notepad rather than Microsoft Word.
8. Using Yocto-GPS with PHP
50
www.yoctopuce.com
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: ......