Skip to content

Commit

Permalink
Add successful triggering of DiGuRaL API
Browse files Browse the repository at this point in the history
  • Loading branch information
muthenberg committed Aug 14, 2023
1 parent 4fc676a commit de6340e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion camera_service
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ExternalCameraController(private val deviceId: String) : ParcelableCapturi
// A possible solution would be to store this in Room/Sql, as this supports multi-process.
val address = CustomPreferences(context).getDiguralUrl()
DiguralApi.baseUrl = address
Log.d(TAG, "###########Setting digural address to: $address")
Log.d(TAG, "Setting digural address to: $address")
}

override fun onCameraAccessLost() {}
Expand All @@ -67,6 +67,13 @@ class ExternalCameraController(private val deviceId: String) : ParcelableCapturi
override fun onCameraError(reason: String) {}
override fun onAboutToCapture(measurementId: Long, location: Location?) {
Log.d(TAG, "On About to Capture $location")

val targetUrl = DiguralApi
.baseUrl
.toURI()
.resolve("PanAiCam/Trigger")
.toURL()

if (location == null) {
return
}
Expand All @@ -91,10 +98,9 @@ class ExternalCameraController(private val deviceId: String) : ParcelableCapturi
/* Begin Classic Variant */
thread {
Log.d(TAG, "Sending Payload ${payload.toJson()}")
with(URL("http://192.168.113.154:5000/PanAiCam/Trigger").openConnection() as HttpURLConnection) {
with(targetUrl.openConnection() as HttpURLConnection) {
try {
requestMethod = "POST"
setRequestProperty("Accept", "*/*")
setRequestProperty("Content-Type", "application/json")
doOutput = true

Expand Down

0 comments on commit de6340e

Please sign in to comment.