Skip to content

Commit

Permalink
Refactor Fujifilm geotag handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
gkoh committed Jul 4, 2024
1 parent 743d8a4 commit 1032294
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
31 changes: 14 additions & 17 deletions lib/furble/Fujifilm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,40 +241,37 @@ void Fujifilm::focusRelease(void) {
shutterRelease();
}

void Fujifilm::sendGeoData(void) {
void Fujifilm::sendGeoData(gps_t &gps, timesync_t &timesync) {
NimBLERemoteService *pSvc = m_Client->getService(FUJIFILM_SVC_GEOTAG_UUID);
NimBLERemoteCharacteristic *pChr = pSvc->getCharacteristic(FUJIFILM_CHR_GEOTAG_UUID);

geotag_t geotag = {.latitude = (int32_t)(m_GPS.latitude * 10000000),
.longitude = (int32_t)(m_GPS.longitude * 10000000),
.altitude = (int32_t)m_GPS.altitude,
geotag_t geotag = {.latitude = (int32_t)(gps.latitude * 10000000),
.longitude = (int32_t)(gps.longitude * 10000000),
.altitude = (int32_t)gps.altitude,
.pad = {0},
.gps_time = {
.year = (uint16_t)m_TimeSync.year,
.day = (uint8_t)m_TimeSync.day,
.month = (uint8_t)m_TimeSync.month,
.hour = (uint8_t)m_TimeSync.hour,
.minute = (uint8_t)m_TimeSync.minute,
.second = (uint8_t)m_TimeSync.second,
.year = (uint16_t)timesync.year,
.day = (uint8_t)timesync.day,
.month = (uint8_t)timesync.month,
.hour = (uint8_t)timesync.hour,
.minute = (uint8_t)timesync.minute,
.second = (uint8_t)timesync.second,
}};

if (pChr->canWrite()) {
Serial.printf("Sending geotag data (%u bytes) to 0x%04x\r\n", sizeof(geotag),
pChr->getHandle());
Serial.printf(" lat: %f, %d\r\n", m_GPS.latitude, geotag.latitude);
Serial.printf(" lon: %f, %d\r\n", m_GPS.longitude, geotag.longitude);
Serial.printf(" alt: %f, %d\r\n", m_GPS.altitude, geotag.altitude);
Serial.printf(" lat: %f, %d\r\n", gps.latitude, geotag.latitude);
Serial.printf(" lon: %f, %d\r\n", gps.longitude, geotag.longitude);
Serial.printf(" alt: %f, %d\r\n", gps.altitude, geotag.altitude);

pChr->writeValue((uint8_t *)&geotag, sizeof(geotag), true);
}
}

void Fujifilm::updateGeoData(gps_t &gps, timesync_t &timesync) {
m_GPS = gps;
m_TimeSync = timesync;

if (m_GeoRequested) {
sendGeoData();
sendGeoData(gps, timesync);
m_GeoRequested = false;
}
}
Expand Down
5 changes: 1 addition & 4 deletions lib/furble/Fujifilm.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,12 @@ class Fujifilm: public Camera {
size_t getSerialisedBytes(void);
bool serialise(void *buffer, size_t bytes);
void notify(NimBLERemoteCharacteristic *, uint8_t *, size_t, bool);
void sendGeoData();
void sendGeoData(gps_t &gps, timesync_t &timesync);

uint8_t m_Token[FUJIFILM_TOKEN_LEN] = {0};

bool m_Configured = false;

gps_t m_GPS = {0};
timesync_t m_TimeSync = {0};

volatile bool m_GeoRequested = false;
};

Expand Down

0 comments on commit 1032294

Please sign in to comment.