Thursday, February 25, 2016

Location Finder using Navilock GPS module



   GPS Driver installation Steps

 

 

 

OSGI Service to read the GPS coordinates (Latitude and Longitude)


<?xml version="1.0" encoding="UTF-8"?>
                <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate"         deactivate="deactivate" immediate="true" name="com.iot.sample">
                                <implementation class="com.iot.internal.sample.Component"/>
                                                <reference bind="setPositionService" cardinality="1..1" interface="org.eclipse.kura.position.PositionService" name="PositionService" policy="static" unbind="unsetPositionService"/>
   </scr:component>
  
    public class Component {

                                private PositionService m_positionService;

                                private final Logger logger = LoggerFactory.getLogger(Component.class);
                               
                                public void activate(ComponentContext componentContext, Map<String, Object> properties) {
                                                //no-op
                                }

                                public void deactivate(ComponentContext componentContext) {
                                                //no-op
                                }
                                public void setPositionService(PositionService positionService) {
                                                m_positionService = positionService;
                                                GPSDevice gpsDevice=new GPSDevice(m_positionService.getNmeaPosition());
                                                logger.info("latitude -------------------->" + gpsDevice.getLatitude());
                                                logger.info("longitude-------------------->" + gpsDevice.getLongitude());
                                }

                                public void unsetPositionService(PositionService positionService) {
                                                m_positionService = null;
                                }
   }

                public class GPSDevice {
                                private final NmeaPosition nmeaPosition;

                                public GPSDevice(final NmeaPosition nmeaPosition) {
                                                this.nmeaPosition=nmeaPosition;
                                }


                                public double getLatitude() {
                                                return nmeaPosition.getLatitude();
                                }
                                public double getLongitude() {
                                                return nmeaPosition.getLongitude();
                                }              }

 

GPS coordinates reading using Kura PositionService

 



1 comment:

  1. Agilestorelocator.com is the professional in wordpress plugin and store locator wordpress. Here is also options available for the Location finder WordPress.

    ReplyDelete