Skip to content

Add location and battery / media status feature#13

Draft
Mat931 wants to merge 2 commits intoStaacks:mainfrom
Mat931:feature_location_and_battery_media_status
Draft

Add location and battery / media status feature#13
Mat931 wants to merge 2 commits intoStaacks:mainfrom
Mat931:feature_location_and_battery_media_status

Conversation

@Mat931
Copy link
Copy Markdown

@Mat931 Mat931 commented Apr 28, 2025

This is still work in progress and not ready to be released

CameraBLE.kt

  • Added new BLE services camera and location, renamed existing characteristics to include the word remote
  • Initial read of the media status always fails with 144, but notifications work and the initial read of the battery status works
  • Added parsers for the media status and battery status
  • Added code to serialize the location + time + timezone. I changed it to send the current time instead of the location timestamp to avoid sending an obsolete timestamp to the camera. The a6700 appears to use the first timestamp it receives after turning on to set its clock.
  • If the camera is not ready yet, the location is stored for later and sent as soon as possible.
  • Don't send the location to the camera before the location enabled characteristic is written, this will make all writes fail and require a restart of the camera (locationInitDone is set to true when the camera is ready)

CameraState.kt

  • I added mediaStatus and batteryStatus to CameraStateReady, this should be changed in the future because a camera with disabled remote function can still send its media and battery status

AlphaRemoteService.kt

  • Location updates are started as soon as the camera connects to minimize the delay until the first position is sent.
  • We should check if the location feature is supported by the camera and enabled before starting location updates to avoid draining the battery. This information would need to be stored somewhere.
  • Location updates are still 30 seconds apart despite setting 10 seconds.

CompanionDeviceHelper.kt

  • Added comment about detecting if remote control is enabled on the a6700

Testing

  • During testing, the location feature went "missing" once after restarting my phone, not sure if it's a coding error or Android reset the app to a previous version
  • The location feature is usually reliable even with the phone screen turned off
  • sometimes it takes longer to connect and send the location if the camera wasn't used in a while

ToDo

  • Location permission must be granted in the settings (Allow all the time, Use precise location), in the future the app should request this permission
  • There should be a switch to enable and disable the location feature in the settings, this should write to the location lock and location enable characteristics
  • There should be switches for the time correction and area adjustment characteristics in the settings (only visible if the location feature is enabled)
  • Hide the remote buttons if the remote feature is disabled on the camera to avoid a disconnect when pressing a button
  • Reading the camera name always fails and is "unknown", maybe store the name permanently or read from a different characteristic (0xcc0b) if the first read fails
  • Maybe display the battery and pictures remaining in the notification
  • Emojis are used for showing the battery and media status, maybe use icons in the future

fixes #8

@wise86-android
Copy link
Copy Markdown

Hi Mat, Sebastian

Thanks for your work!
I have a a6600 and I'm looking to the location service too.

I notice that:

  • the a6600 do not have the lock, area an time correction characteristics.
  • the camera doesn't permit to enable the BLE location info if the BLE remote control is on. ( I did not check if writing anyway in the characteristics works, but I don't have a lot of hope)

I'm also refactoring the BLE code, splitting the characteristics code in different file, because the CameraBLE file is becoming huge.. but I still don't like the result..

you can see the WIP here: https://github.com/wise86-android/alpharemote/tree/splitBleImplementation

@Staacks
Copy link
Copy Markdown
Owner

Staacks commented Aug 10, 2025

Yeah, I am having the same problem. So, a little update from my side:

I found some time to work on the app during my vacation. Mostly minor bugs that I noticed while using the app myself and a few new features (see current beta release which will become version 1.1 in a few days/weeks). I only found time to look over this PR and think a bit about it and unfortunately, the problem will be (like with some other features) that I cannot test this on my camera.

My a6400 has the following services/charcteristics:

  • 0x1800 (BLE Standard, Generic Access)
    • 0x2a00 [R] (Device Name)
    • 0x2a01 [R] (Appearance)
    • 0x2a04 [R] (Connection Parameters)
  • 0x1801 (BLE Standard, Generic Attribute)
    • 0x2a05 [I] (Service Changed)
  • 0xdd00 (Location/geotagging service)
    • 0xdd01 [N] (Location Notification)
    • 0xdd11 [W] (Location Receiver)
    • 0xdd21 [R] (Location Data)
  • 0xee00 (Not really sure, tbh)
    • 0xee01 [W]
  • 0xff00 (BLE Remote Control Service)
    • 0xff01 [W] (BLE Remote Command)
    • 0xff02 [N] (BLE Remote Status)

(The non-standard UUIDs are of course based on 8000xxxx-xxxx-ffff-ffff-ffffffffffff. The brackets show if a characteristic can be read, written and/or supports indication or notification)

So, unless you (Mat) want to maintain these features (which might become quite frustrating as I suspect that things will be interefering with other models), I cannot really implement anything from the 0xcc00 service until I get a new camera (which I did not plan for anytime soon).

Next time I find some time for this, I want to implement the location service, though. Unfortunately, there are also a few differences as I do not have characteristics 0xdd30 (location lock), 0xdd31 (location enabled), 0xdd32 (time correction), 0xdd33 (area adjustment). From your code it seems like I can ignore the latter two, but what about the other two? Do you have to write them for your camera to accept location updates? What if you do not write one of them or is this a method to switch between BLE remote and BLE location service? (My a6400 can only do either and you have to switch manually in the menu.)

My plan would be to write these characteristics if they exists and ignore them otherwise. Would that work?

And one more thing: You write that reading the camera name always fails. Do you mean that on your camera 0x2a00 does not provide the camera name? Love it when manufactures have better ideas than using the standard...

Any idea what the cheapest camera with the newer interface might be? Maybe I could get a broken camera that has become unusable for photography but that could be used for BLE testing. But those are probably still too expensive just for that as they have a value for their spare parts...

@Mat931
Copy link
Copy Markdown
Author

Mat931 commented Aug 26, 2025

Hi,

I can of course help with testing code with my camera and fixing bugs. My Android dev experience is still limited, especially when it comes to UI stuff.

Location lock

For the 0xdd30 - 0xdd33 characteristics (location lock etc) there should be 3 toggle switches in the settings that only appear when the camera has the location service. I didn't know how to implement that yet. I think this is important if the user wants to use more than one phone with the camera without unpairing.
The first switch controls if location is enabled (0xdd30 and 0xdd31), the other two control the time correction and area adjustment.

Reading the camera name

This only fails with this PR, maybe I somehow broke it. I just tested it with 1.00 and it shows the camera name.

Cheapest camera with new features

You can try the ZV-1F or the ZV-1 II. They are both compatible with the official app but it's hard to say if they have the location service.

Testing results

I've been testing this PR over the past months and it works great and doesn't drain the phone battery. I don't use the remote feature very often. A few more things I noticed:

  • When the app is running in the background (notification visible) I sometimes need to keep the maps app open for location to work. Maybe because I didn't turn off battery optimization for the app. Or maybe the maps app needs to request GPS location when no wifi networks are around for google location services.
  • Currently the app doesn't check how accurate the GPS location is, and a few photos have a location that is kilometers away. Maybe we should only send accurate locations to the camera.
  • When remote control is disabled on the camera and I accidentally press a remote button in the app, it disconnects. Maybe this behavior should be changed for users who don't need remote control.

New firmware

There is a firmware update available for my camera (1.03 -> 2.00) which also requires a new version of the official app. I didn't update yet so I don't know if it will break anything related to the location service.

@Saschl
Copy link
Copy Markdown

Saschl commented Aug 26, 2025

Next time I find some time for this, I want to implement the location service, though. Unfortunately, there are also a few differences as I do not have characteristics 0xdd30 (location lock), 0xdd31 (location enabled), 0xdd32 (time correction), 0xdd33 (area adjustment). From your code it seems like I can ignore the latter two, but what about the other two? Do you have to write them for your camera to accept location updates? What if you do not write one of them or is this a method to switch between BLE remote and BLE location service? (My a6400 can only do either and you have to switch manually in the menu.)

I think you should be able to read the characteristics and write the flags depending on if the camera support it (https://github.com/Saschl/camera-gps/blob/main/app/src/main/java/com/saschl/cameragps/service/LocationSenderService.kt#L126 and following lines). I'm developing an app that focuses on the location part (and just stumbled upon your app now, could have saved myself some work :D ). The code is quite messy unfortunately, but I think the idea should be there.

  1. Read the characteristics
  2. If it contains the enable gps commands (dd30 dd31), send the unlock command
  3. After that has been written, send the lock command (https://github.com/Saschl/camera-gps/blob/main/app/src/main/java/com/saschl/cameragps/service/LocationSenderService.kt#L171)

If it does not contain them, just ignore and continue.

I could confirm that works with a user that has a ZV-E10 and some A7 which both use the creators' app as I also only own the 6400.

@andrewharvey
Copy link
Copy Markdown

andrewharvey commented Sep 15, 2025

I tested this on my ILCE-7RM5 (Sony A7RV) with firmware version 3.01. I built and ran this PR but found that it could connect and trigger photos but the location wasn't being applied. If I get time I'll try to dig further.

EDIT: it worked once, but not reliably.

@Mat931
Copy link
Copy Markdown
Author

Mat931 commented Sep 21, 2025

Hi @andrewharvey

Thanks for testing the PR. Here are a few things you can try:

  • Go to the app settings and grant the location permission. It must be set to "Allow all the time" and "Use precise location". After changing the permission, turn the camera off and on again.
  • Disable battery optimization for the app for better results when the app is not in the foreground. ("Allow background usage" and "Unrestricted")
  • If you have a recent Android version you should see a green dot appear in the top right of the screen when the app receives a location from Android. How often does that appear?
  • On the camera there should be a map icon if the camera has received the location from the phone.
  • Is location turned on on your phone and does it work in other apps?
  • Opening the Maps app might improve results when you're outdoors without WiFi networks around. This is something I have to fix in the future by requesting the GPS location when the Google location is not available.
  • If the camera was paired to another Bluetooth device you need to unpair it first

@andrewharvey
Copy link
Copy Markdown

Go to the app settings and grant the location permission. It must be set to "Allow all the time" and "Use precise location". After changing the permission, turn the camera off and on again.
Disable battery optimization for the app for better results when the app is not in the foreground. ("Allow background usage" and "Unrestricted")

Yeah I did these both already.

If you have a recent Android version you should see a green dot appear in the top right of the screen when the app receives a location from Android. How often does that appear?

I'll try again to do more thorough testing to see.

On the camera there should be a map icon if the camera has received the location from the phone.

Yes that's what I look out for (and also then after taking a photo on the review screen it'll show the coordinates if it's geotagged), I found it was unreliable, sometimes it got the location other times not.

Is location turned on on your phone and does it work in other apps?

Yes

Opening the Maps app might improve results when you're outdoors without WiFi networks around. This is something I have to fix in the future by requesting the GPS location when the Google location is not available.

Yes I generally always run a GPS tracker app in the background to ensure that location updates are current and have the best accuracy.

If the camera was paired to another Bluetooth device you need to unpair it first

I don't think I had my camera paid to any other device.

I also tested a similar app https://github.com/mlapaglia/AlphaSync to provide location updates, but encountered an issue that makes it unusable mlapaglia/AlphaSync#2. After using it the camera won't turn on again after being turned off, only taking the battery out resolves it.

@kalicyh
Copy link
Copy Markdown

kalicyh commented Nov 29, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request : GPS location

6 participants