
YLatitude *latitude =
[
Latitude FindLatitude:
@"MyFunction"
]
;
[Latitude FindLatitude]
returns an object which you can then use at will to control the
latitude sensor.
isOnline
The
isOnline
method of the object returned by
[Latitude FindLatitude]
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
YGps.FindGps
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.
10.2. 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.
#import <Foundation/Foundation.h>
#import "yocto_api.h"
static
void
usage
(
const
char
*exe
)
{
NSLog
(
@"usage: %s <serial or logical name> [ON/OFF]
\n
"
, exe
)
;
exit
(
1
)
;
}
int
main
(
int
argc,
const
char
* argv
[])
{
NSError
*error;
@autoreleasepool
{
// Setup the API to use local USB devices
if([
YAPI RegisterHub:
@"usb"
: &error
]
!= YAPI_SUCCESS
)
{
NSLog
(
@"RegisterHub error: %@"
,
[
error localizedDescription
])
;
return
1
;
}
if(
argc <
2
)
usage
(
argv
[
0
])
;
NSString
*serial_or_name =
[
NSString
stringWithUTF8String:argv
[
1
]]
;
// use serial or logical name
YModule *module =
[
YModule FindModule:serial_or_name
]
;
if
([
module isOnline
])
{
if
(
argc >
2
)
{
if
(
strcmp
(
argv
[
2
]
,
"ON"
)
==
0
)
[
module setBeacon:Y_BEACON_ON
]
;
else
[
module setBeacon:Y_BEACON_OFF
]
;
}
NSLog
(
@"serial: %@
\n
"
,
[
module serialNumber
])
;
NSLog
(
@"logical name: %@
\n
"
,
[
module logicalName
])
;
NSLog
(
@"luminosity: %d
\n
"
,
[
module luminosity
])
;
NSLog
(
@"beacon: "
)
;
if
([
module beacon
]
== Y_BEACON_ON
)
NSLog
(
@"ON
\n
"
)
;
else
NSLog
(
@"OFF
\n
"
)
;
NSLog
(
@"upTime: %ld sec
\n
"
,
[
module upTime
]
/
1000
)
;
NSLog
(
@"USB current: %d mA
\n
"
,
[
module usbCurrent
])
;
NSLog
(
@"logs: %@
\n
"
,
[
module get_lastLogs
])
;
}
else
{
NSLog
(
@"%@ not connected (check identification and USB cable)
\n
"
,
serial_or_name
)
;
}
[
YAPI FreeAPI
]
;
}
return
0
;
10. Using Yocto-GPS with Objective-C
www.yoctopuce.com
69
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: ......