Skip to content

Commit

Permalink
Merge pull request #20 from reedu-reengineering-education/deployment/ios
Browse files Browse the repository at this point in the history
feat: ios deployment
  • Loading branch information
felixerdy authored Oct 27, 2023
2 parents 0035c01 + bbb2cbf commit 88166fa
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 84 deletions.
59 changes: 32 additions & 27 deletions ios/App/App.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
504EC30F1FED79650016851F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 504EC30E1FED79650016851F /* Assets.xcassets */; };
504EC3121FED79650016851F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 504EC3101FED79650016851F /* LaunchScreen.storyboard */; };
50B271D11FEDC1A000F3C39B /* public in Resources */ = {isa = PBXBuildFile; fileRef = 50B271D01FEDC1A000F3C39B /* public */; };
A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */; };
DB837AFCFB579D5EF32B767D /* Pods_App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B55C2D81B6DE253CADF9E984 /* Pods_App.framework */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
2E5E47F632E4A2346969DF23 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = "<group>"; };
2FAD9762203C412B000D30F8 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = config.xml; sourceTree = "<group>"; };
50379B222058CBB4000EE86E /* capacitor.config.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = capacitor.config.json; sourceTree = "<group>"; };
504EC3041FED79650016851F /* App.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand All @@ -27,38 +28,39 @@
504EC3111FED79650016851F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
504EC3131FED79650016851F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
50B271D01FEDC1A000F3C39B /* public */ = {isa = PBXFileReference; lastKnownFileType = folder; path = public; sourceTree = "<group>"; };
AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.release.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.release.xcconfig"; sourceTree = "<group>"; };
FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Pods/Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = "<group>"; };
B55C2D81B6DE253CADF9E984 /* Pods_App.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App.framework; sourceTree = BUILT_PRODUCTS_DIR; };
E31F94C6D55731F1094B211B /* Pods-App.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App.debug.xcconfig"; path = "Target Support Files/Pods-App/Pods-App.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
504EC3011FED79650016851F /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
A084ECDBA7D38E1E42DFC39D /* Pods_App.framework in Frameworks */,
DB837AFCFB579D5EF32B767D /* Pods_App.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
27E2DDA53C4D2A4D1A88CE4A /* Frameworks */ = {
47CAF83C7FFCA428F6BFD8F4 /* Pods */ = {
isa = PBXGroup;
children = (
AF277DCFFFF123FFC6DF26C7 /* Pods_App.framework */,
E31F94C6D55731F1094B211B /* Pods-App.debug.xcconfig */,
2E5E47F632E4A2346969DF23 /* Pods-App.release.xcconfig */,
);
name = Frameworks;
name = Pods;
path = Pods;
sourceTree = "<group>";
};
504EC2FB1FED79650016851F = {
isa = PBXGroup;
children = (
504EC3061FED79650016851F /* App */,
504EC3051FED79650016851F /* Products */,
7F8756D8B27F46E3366F6CEA /* Pods */,
27E2DDA53C4D2A4D1A88CE4A /* Frameworks */,
47CAF83C7FFCA428F6BFD8F4 /* Pods */,
BB651A3CDC87929342E2F3EA /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -85,13 +87,12 @@
path = App;
sourceTree = "<group>";
};
7F8756D8B27F46E3366F6CEA /* Pods */ = {
BB651A3CDC87929342E2F3EA /* Frameworks */ = {
isa = PBXGroup;
children = (
FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */,
AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */,
B55C2D81B6DE253CADF9E984 /* Pods_App.framework */,
);
name = Pods;
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
Expand All @@ -101,11 +102,11 @@
isa = PBXNativeTarget;
buildConfigurationList = 504EC3161FED79650016851F /* Build configuration list for PBXNativeTarget "App" */;
buildPhases = (
6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */,
A8152DDDEEBA631AB4282E94 /* [CP] Check Pods Manifest.lock */,
504EC3001FED79650016851F /* Sources */,
504EC3011FED79650016851F /* Frameworks */,
504EC3021FED79650016851F /* Resources */,
9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */,
3C147EBD1C93D6377B44C635 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -167,37 +168,41 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
6634F4EFEBD30273BCE97C65 /* [CP] Check Pods Manifest.lock */ = {
3C147EBD1C93D6377B44C635 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-App-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App/Pods-App-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
9592DBEFFC6D2A0C8D5DEB22 /* [CP] Embed Pods Frameworks */ = {
A8152DDDEEBA631AB4282E94 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-App-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-App/Pods-App-frameworks.sh\"\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -342,7 +347,7 @@
};
504EC3171FED79650016851F /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = FC68EB0AF532CFC21C3344DD /* Pods-App.debug.xcconfig */;
baseConfigurationReference = E31F94C6D55731F1094B211B /* Pods-App.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
Expand All @@ -363,7 +368,7 @@
};
504EC3181FED79650016851F /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = AF51FD2D460BCFE21FA515B2 /* Pods-App.release.xcconfig */;
baseConfigurationReference = 2E5E47F632E4A2346969DF23 /* Pods-App.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_STYLE = Automatic;
Expand Down
4 changes: 1 addition & 3 deletions ios/App/App/capacitor.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@
"appId": "de.reedu.senseboxbike",
"appName": "senseBox:Bike",
"webDir": "out",
"server": {
"url": "http://192.168.0.220:3000"
}
"server": {}
}
2 changes: 1 addition & 1 deletion ios/App/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: f2e3708e22e094f8a9b03f2e5f0e3688df829e58

COCOAPODS: 1.11.3
COCOAPODS: 1.14.0
24 changes: 9 additions & 15 deletions src/components/Device/SettingsDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,11 @@ import { Switch } from '../ui/switch'
import { useSettingsStore } from '@/lib/store/useSettingsStore'
import { Button } from '../ui/button'
import { DialogClose } from '@radix-ui/react-dialog'
import useSenseBox from '@/lib/useSenseBox'
import useSenseBox, { BackgroundGeolocation } from '@/lib/useSenseBox'
import { numbersToDataView } from '@capacitor-community/bluetooth-le'
import { registerPlugin } from '@capacitor/core'
import { BackgroundGeolocationPlugin } from '@felixerdy/background-geolocation'
import { Drawer } from 'vaul'
import { useEffect, useState } from 'react'

const BackgroundGeolocation = registerPlugin<BackgroundGeolocationPlugin>(
'BackgroundGeolocation',
)

const formSchema = z.object({
uploadInterval: z.number().min(1).max(60),
switchUseDeviceGPS: z.boolean(),
Expand All @@ -62,14 +56,14 @@ export default function SettingsDrawer() {
})

const handleSubmit = (values: z.infer<typeof formSchema>) => {
send(
'29BD0A85-51E4-4D3C-914E-126541EB2A5E',
'60B1D5CE-3539-44D2-BB35-FF2DAABE17FF',
numbersToDataView([
values.uploadInterval,
values.switchUseDeviceGPS ? 1 : 0,
]),
)
// send(
// '29BD0A85-51E4-4D3C-914E-126541EB2A5E',
// '60B1D5CE-3539-44D2-BB35-FF2DAABE17FF',
// numbersToDataView([
// values.uploadInterval,
// values.switchUseDeviceGPS ? 1 : 0,
// ]),
// )
useSettingsStore.setState({
uploadInterval: values.uploadInterval,
useSenseBoxGPS: values.switchUseDeviceGPS,
Expand Down
57 changes: 25 additions & 32 deletions src/lib/SenseBoxDataParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import {
senseBoxDataRecord,
useSenseBoxValuesStore,
} from './store/useSenseBoxValuesStore'
import { BackgroundGeolocationPlugin } from '@felixerdy/background-geolocation'

const BackgroundGeolocation = registerPlugin<BackgroundGeolocationPlugin>(
'BackgroundGeolocation',
)

export class SenseBoxDataParser {
private static instance: SenseBoxDataParser
Expand Down Expand Up @@ -83,31 +78,31 @@ export class SenseBoxDataParser {
b.distance_l !== undefined,
)

const bucketsProcessedLocation = await Promise.all(
buckets.map(async b => {
const processedLocation = await BackgroundGeolocation.processLocation({
location: {
latitude: b.gps_lat!,
longitude: b.gps_lng!,
speed: b.gps_spd!,
accuracy: 0,
simulated: false,
altitude: null,
bearing: null,
altitudeAccuracy: null,
time: b.timestamp.getTime(),
},
})
return {
...b,
gps_lat: processedLocation.latitude,
gps_lng: processedLocation.longitude,
gps_spd: processedLocation.speed,
} as senseBoxDataRecord
}),
)

useSenseBoxValuesStore.getState().addValues(bucketsProcessedLocation)
// const bucketsProcessedLocation = await Promise.all(
// buckets.map(async b => {
// const processedLocation = await BackgroundGeolocation.processLocation({
// location: {
// latitude: b.gps_lat!,
// longitude: b.gps_lng!,
// speed: b.gps_spd!,
// accuracy: 0,
// simulated: false,
// altitude: null,
// bearing: null,
// altitudeAccuracy: null,
// time: b.timestamp.getTime(),
// },
// })
// return {
// ...b,
// gps_lat: processedLocation.latitude ?? 0,
// gps_lng: processedLocation.longitude ?? 0,
// gps_spd: processedLocation.speed ?? 0,
// } as senseBoxDataRecord
// }),
// )

useSenseBoxValuesStore.getState().addValues(buckets)

const completeTimestamps = buckets.map(b => b.timestamp)

Expand All @@ -120,8 +115,6 @@ export class SenseBoxDataParser {
this.timestampInterval,
),
)

console.log(this.dataBuffer.length)
}

pushData(data: Omit<senseBoxDataRecord, 'timestamp'>) {
Expand Down
4 changes: 1 addition & 3 deletions src/lib/store/useSenseBoxValuesStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export const useSenseBoxValuesStore = create<senseBoxValuesStore>(set => ({
setValues: values => set({ values }),
addValues: values =>
set(state => ({
values: [...state.values, ...values].sort(
(a, b) => a.timestamp.getTime() - b.timestamp.getTime(),
),
values: [...state.values, ...values],
})),
}))
5 changes: 2 additions & 3 deletions src/lib/useSenseBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ const BLE_DISTANCE_CHARACTERISTIC = 'B3491B60-C0F3-4306-A30D-49C91F37A62B'
const BLE_CONFIG_SERVICE = '29BD0A85-51E4-4D3C-914E-126541EB2A5E'
const BLE_CONFIG_CHARACTERISTIC = '60B1D5CE-3539-44D2-BB35-FF2DAABE17FF'

const BackgroundGeolocation = registerPlugin<BackgroundGeolocationPlugin>(
'BackgroundGeolocation',
)
export const BackgroundGeolocation =
registerPlugin<BackgroundGeolocationPlugin>('BackgroundGeolocation')

/**
* Parses the data received from the SenseBox and returns an array of values.
Expand Down

0 comments on commit 88166fa

Please sign in to comment.