Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: C027 C12832 EthernetInterface StatusReporter LM75B MQTT-ansond endpoint_core endpoint_mqtt mbed-rtos mbed
Diff: EmulatedResourceFactory.cpp
- Revision:
- 148:b09187a0fa77
- Parent:
- 122:91a0d3114287
- Child:
- 149:6da931b7944d
--- a/EmulatedResourceFactory.cpp Wed Mar 19 21:37:52 2014 +0000
+++ b/EmulatedResourceFactory.cpp Wed Mar 19 22:09:43 2014 +0000
@@ -56,12 +56,24 @@
// default constructor
EmulatedResourceFactory::EmulatedResourceFactory(ErrorHandler *error_handler,void *endpoint) : ResourceFactory(error_handler,endpoint) {
+ this->initGPSCoords();
}
// default destructor
EmulatedResourceFactory::~EmulatedResourceFactory() {
}
+ // initialize our GPS coords
+ void EmulatedResourceFactory::initGPSCoords() {
+ memset(this->m_gps_coords,0,PREFERENCE_VALUE_LEN+1);
+ MBEDEndpoint *endpoint = (MBEDEndpoint *)this->logger()->getEndpoint();
+ endpoint->preferences()->getPreference("coords",this->m_gps_coords,PREFERENCE_VALUE_LEN,ENDPOINT_GPS_COORDS);
+ for(int i=0;i<strlen(this->m_gps_coords);++i) if (this->m_gps_coords[i] == ',') this->m_gps_coords[i] = ' ';
+ }
+
+ // get our GPS coords from preferences
+ char *EmulatedResourceFactory::getGPSCoords() { return this->m_gps_coords; }
+
// create resources
void EmulatedResourceFactory::createResources(char *endpoint_name) {
// create all of the resources we expect for this endpoint
@@ -87,7 +99,7 @@
this->createResource("/dev/t","10.0C",(void *)&init_temperature,NULL);
this->createResource("/sen/V","5.0V",(void *)&init_voltage,NULL);
this->createResource("/dev/V","5.0V",(void *)&init_voltage,NULL);
- this->createResource("/gps/loc",ENDPOINT_GPS_COORDS,(void *)&init_gps,NULL);
+ this->createResource("/gps/loc",this->getGPSCoords(),(void *)&init_gps,NULL);
//this->createResource("/res/int","1");
//this->createResource("/res/systime","1010101");