forked from Path-Check/safeplaces-dct-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from tripleblindmarket/develop
Merge
- Loading branch information
Showing
17 changed files
with
860 additions
and
514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
{ | ||
"overlap_para_1":"This map shows where your private location trail overlaps with public data from a variety of sources, including official reports from WHO, Ministries of Health, and Chinese local, provincial, and national health authorities. If additional data are available from reliable online reports, they are included.", | ||
"show_overlap": "SHOW ME TRACE OVERLAP", | ||
} | ||
"overlap_title": "Check Overlap", | ||
"overlap_para_1": "Green circles are clusters of your locations, click to zoom. Red markers are your recorded locations.\n\nPress the button to download public information of confirmed cases, shown as faint purple circles.", | ||
"show_overlap": "Check Public Data", | ||
"loading_public_data": "loading data...", | ||
"overlap_no_results_button_label": "Public Data Loaded", | ||
"overlap_found_button_label": "Public Data Loaded", | ||
"nCoV2019_url_info": "For more information on the dataset for this map", | ||
"nCoV2019_url": "github.com/beoutbreakprepared/nCoV2019" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
import { | ||
GetStoreData, | ||
SetStoreData | ||
} from '../helpers/General'; | ||
|
||
import BackgroundTimer from 'react-native-background-timer'; | ||
import UUIDGenerator from 'react-native-uuid-generator'; | ||
import Moment from 'moment'; | ||
|
||
import AndroidBLEAdvertiserModule from 'react-native-ble-advertiser' | ||
|
||
var currentUUID = null; | ||
|
||
function saveContact(contact) { | ||
// Persist this contact data in our local storage of time/lat/lon values | ||
|
||
GetStoreData('CONTACT_DATA') | ||
.then(contactArrayString => { | ||
|
||
var contactArray; | ||
if (contactArrayString !== null) { | ||
contactArray = JSON.parse(contactArrayString); | ||
} else { | ||
contactArray = []; | ||
} | ||
|
||
// Always work in UTC, not the local time in the contactData | ||
var nowUTC = new Date().toISOString(); | ||
var unixtimeUTC = Date.parse(nowUTC); | ||
var unixtimeUTC_28daysAgo = unixtimeUTC - (60 * 60 * 24 * 1000 * 28); | ||
|
||
// Save the contact using the current lat-lon and the | ||
// calculated UTC time (maybe a few milliseconds off from | ||
// when the GPS data was collected, but that's unimportant | ||
// for what we are doing.) | ||
console.log('[GPS] Saving point:', contactArray.length); | ||
var lat_lon_time = { | ||
"uuid": contact["uuid"], | ||
"time": unixtimeUTC | ||
}; | ||
contactArray.push(lat_lon_time); | ||
|
||
SetStoreData('CONTACT_DATA', contactArray); | ||
}); | ||
} | ||
|
||
function saveMyUUID(me) { | ||
// Persist this contact data in our local storage of time/lat/lon values | ||
|
||
GetStoreData('MY_UUIDs') | ||
.then(myUUIDArrayString => { | ||
var myUUIDArray; | ||
if (myUUIDArrayString !== null) { | ||
myUUIDArray = JSON.parse(myUUIDArrayString); | ||
} else { | ||
myUUIDArray = []; | ||
} | ||
|
||
// Always work in UTC, not the local time in the contactData | ||
var nowUTC = new Date().toISOString(); | ||
var unixtimeUTC = Date.parse(nowUTC); | ||
var unixtimeUTC_28daysAgo = unixtimeUTC - (60 * 60 * 24 * 1000 * 28); | ||
|
||
var uuid_time = { | ||
"uuid": me["uuid"], | ||
"time": unixtimeUTC | ||
}; | ||
console.log('[GPS] Saving myUUID:', Moment(unixtimeUTC).format('MMM Do, H:mma'), me["uuid"], myUUIDArray.length); | ||
myUUIDArray.push(uuid_time); | ||
|
||
SetStoreData('MY_UUIDs', myUUIDArray); | ||
}); | ||
} | ||
|
||
function loadLastUUIDAndBroadcast() { | ||
GetStoreData('MY_UUIDs') | ||
.then(myUUIDArrayString => { | ||
var myUUIDArray; | ||
if (myUUIDArrayString !== null) { | ||
myUUIDArray = JSON.parse(myUUIDArrayString); | ||
console.log("Loading last uuid ", myUUIDArray[myUUIDArray.length-1].uuid); | ||
currentUUID = myUUIDArray[myUUIDArray.length-1].uuid; | ||
broadcast(); | ||
} else { | ||
generateNewUUIDAndBroadcast(); | ||
} | ||
}); | ||
} | ||
|
||
function broadcast() { | ||
// Do not run on iOS for now. | ||
if (Platform.OS === 'android') { | ||
console.log("Broadcasting: ", currentUUID); | ||
AndroidBLEAdvertiserModule.setCompanyId(0xFF); | ||
AndroidBLEAdvertiserModule.broadcastPacket(currentUUID, [12,23,56]) | ||
.then((sucess) => { | ||
console.log("Broadcasting Sucessful", sucess); | ||
}).catch(error => console.log("Broadcasting Error", error)); | ||
} | ||
} | ||
|
||
function generateNewUUIDAndBroadcast() { | ||
UUIDGenerator.getRandomUUID((uuid) => { | ||
currentUUID = uuid; | ||
saveMyUUID({'uuid':uuid}); | ||
broadcast(); | ||
}); | ||
} | ||
|
||
export default class BroadcastingServices { | ||
static start() { | ||
loadLastUUIDAndBroadcast(); | ||
|
||
BackgroundTimer.runBackgroundTimer(() => { | ||
generateNewUUIDAndBroadcast(); | ||
}, 1000 * 60 * 60); // Every hour, change UUID | ||
|
||
console.log("Starting Bluetooth"); | ||
} | ||
|
||
static stop(nav) { | ||
console.log("Stopping Bluetooth"); | ||
BackgroundTimer.stopBackgroundTimer(); | ||
} | ||
} |
Oops, something went wrong.