![Yoctopuce Yocto-GPS User Manual Download Page 58](http://html1.mh-extra.com/html/yoctopuce/yocto-gps/yocto-gps_user-manual_3415557058.webp)
// Check if a specified module is available online
$module = yFindModule
(
"
$serial
"
)
;
if
(
!$module->
isOnline
())
{
die
(
"Module not connected (check serial and USB cable)"
)
;
}
}
else
{
// or use any connected module suitable for the demo
$module = yFirstModule
()
;
if(
$module
)
{
// skip VirtualHub
$module = $module->
nextModule
()
;
}
if(
is_null
(
$module
))
{
die
(
"No module connected (check USB cable)"
)
;
}
else
{
$serial = $module->
get_serialnumber
()
;
}
}
Print(
"Module to use: <input name='serial' value='
$serial
'><br>"
)
;
if
(
isset
(
$_GET
[
'beacon'
]))
{
if
(
$_GET
[
'beacon'
]
==
'ON'
)
$module->
set_beacon
(
Y_BEACON_ON
)
;
else
$module->
set_beacon
(
Y_BEACON_OFF
)
;
}
printf
(
'serial: %s<br>'
,$module->
get_serialNumber
())
;
printf
(
'logical name: %s<br>'
,$module->
get_logicalName
())
;
printf
(
'luminosity: %s<br>'
,$module->
get_luminosity
())
;
print(
'beacon: '
)
;
if(
$module->
get_beacon
()
== Y_BEACON_ON
)
{
printf
(
"<input type='radio' name='beacon' value='ON' checked>ON "
)
;
printf
(
"<input type='radio' name='beacon' value='OFF'>OFF<br>"
)
;
}
else
{
printf
(
"<input type='radio' name='beacon' value='ON'>ON "
)
;
printf
(
"<input type='radio' name='beacon' value='OFF' checked>OFF<br>"
)
;
}
printf
(
'upTime: %s sec<br>'
,
intVal
(
$module->
get_upTime
()
/
1000
))
;
printf
(
'USB current: %smA<br>'
,$module->
get_usbCurrent
())
;
printf
(
'logs:<br><pre>%s</pre>'
,$module->
get_lastLogs
())
;
yFreeAPI
()
;
?>
<input type='submit' value='refresh'>
</FORM>
</BODY>
</HTML>
Each property
xxx
of the module can be read thanks to a method of type
get_xxxx()
, and
properties which are not read-only can be modified with the help of the
set_xxx()
method. For
more details regarding the used functions, refer to the API chapters.
Changing the module settings
When you want to modify the settings of a module, you only need to call the corresponding
set_xxx()
function. However, this modification is performed only in the random access memory
(RAM) of the module: if the module is restarted, the modifications are lost. To memorize them
persistently, it is necessary to ask the module to save its current configuration in its permanent
memory. To do so, use the
saveToFlash()
method. Inversely, it is possible to force the module to
forget its current settings by using the
revertFromFlash()
method. The short example below
allows you to modify the logical name of a module.
<HTML>
<HEAD>
<TITLE>save settings</TITLE>
<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"
)
;
8. Using Yocto-GPS with PHP
52
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: ......