Commit 3ab31510 authored by LIly's avatar LIly
Browse files

editing time to be from scan result

parent 69d59bd2
...@@ -98,17 +98,18 @@ JNIEXPORT void JNICALL Java_org_mpisws_encounters_encounterformation_SDDR_1Nativ ...@@ -98,17 +98,18 @@ JNIEXPORT void JNICALL Java_org_mpisws_encounters_encounterformation_SDDR_1Nativ
* Signature: ([BI[B)V * Signature: ([BI[B)V
*/ */
JNIEXPORT jlong JNICALL Java_org_mpisws_encounters_encounterformation_SDDR_1Native_c_1processScanResult JNIEXPORT jlong JNICALL Java_org_mpisws_encounters_encounterformation_SDDR_1Native_c_1processScanResult
(JNIEnv *env, jobject obj, jint jrssi, jbyteArray jadvert) { (JNIEnv *env, jobject obj, jint jrssi, jbyteArray jadvert, jlong jscantime) {
SDDRRadio* radioPtr = getRadioPtr(env, obj); SDDRRadio* radioPtr = getRadioPtr(env, obj);
if (jadvert != NULL) { if (jadvert != NULL) {
int advert_len = env->GetArrayLength(jadvert); int advert_len = env->GetArrayLength(jadvert);
char* advert = new char[advert_len]; char* advert = new char[advert_len];
env->GetByteArrayRegion(jadvert, 0, advert_len, reinterpret_cast<jbyte*>(advert)); env->GetByteArrayRegion(jadvert, 0, advert_len, reinterpret_cast<jbyte*>(advert));
return radioPtr->processScanResponse((int)jrssi, std::string(advert, SHA_DIGEST_LENGTH)); return radioPtr->processScanResponse((int)jrssi, std::string(advert, SHA_DIGEST_LENGTH),
(long) jscantime);
} else { } else {
// we're confirming an encounter via BLE // we're confirming an encounter via BLE
return radioPtr->processScanResponse((int)jrssi, std::string("")); return radioPtr->processScanResponse((int)jrssi, std::string(""), (long) jscantime);
} }
} }
......
...@@ -106,7 +106,7 @@ JNIEXPORT void JNICALL Java_org_mpisws_encounters_encounterformation_SDDR_1Nativ ...@@ -106,7 +106,7 @@ JNIEXPORT void JNICALL Java_org_mpisws_encounters_encounterformation_SDDR_1Nativ
* Signature: ([BI[B)V * Signature: ([BI[B)V
*/ */
JNIEXPORT jlong JNICALL Java_org_mpisws_encounters_encounterformation_SDDR_1Native_c_1processScanResult JNIEXPORT jlong JNICALL Java_org_mpisws_encounters_encounterformation_SDDR_1Native_c_1processScanResult
(JNIEnv *, jobject, jint, jbyteArray); (JNIEnv *, jobject, jint, jbyteArray, jlong);
/* /*
* Class: org_mpisws_encounters_encounterformation_SDDR_1Native * Class: org_mpisws_encounters_encounterformation_SDDR_1Native
......
...@@ -106,7 +106,7 @@ public: // to be called via JNI ...@@ -106,7 +106,7 @@ public: // to be called via JNI
void preDiscovery(); void preDiscovery();
std::vector<std::string> postDiscoveryGetEncounters(); std::vector<std::string> postDiscoveryGetEncounters();
void changeEpoch(); void changeEpoch();
long processScanResponse(int8_t rssi, std::string advert); long processScanResponse(int8_t rssi, std::string advert, long scantime);
std::string computeSecretKey(std::string myDHKey, std::string sha1OtherDHKey, std::string otherDHKey); std::string computeSecretKey(std::string myDHKey, std::string sha1OtherDHKey, std::string otherDHKey);
ActionInfo getNextAction(); ActionInfo getNextAction();
void changeMessagingDHKey(); void changeMessagingDHKey();
......
...@@ -48,11 +48,11 @@ void SDDRRadio::preDiscovery() ...@@ -48,11 +48,11 @@ void SDDRRadio::preDiscovery()
discovered_.clear(); discovered_.clear();
} }
long SDDRRadio::processScanResponse(int8_t rssi, std::string advert) long SDDRRadio::processScanResponse(int8_t rssi, std::string advert, long scanTime)
{ {
LOG_P(TAG, "Processing scan response with rssi %d, and data %s", rssi, advert.c_str()); LOG_P(TAG, "Processing scan response with rssi %d, and data %s", rssi, advert.c_str());
uint64_t scanTime = getTimeMS(); //uint64_t scanTime = getTimeMS();
EbNDevice *device = deviceMap_.get(advert); EbNDevice *device = deviceMap_.get(advert);
if(device == NULL) if(device == NULL)
{ {
...@@ -91,7 +91,7 @@ std::vector<std::string> SDDRRadio::postDiscoveryGetEncounters() ...@@ -91,7 +91,7 @@ std::vector<std::string> SDDRRadio::postDiscoveryGetEncounters()
for(auto discIt = discovered_.begin(); discIt != discovered_.end(); discIt++) for(auto discIt = discovered_.begin(); discIt != discovered_.end(); discIt++)
{ {
EncounterEvent event(getTimeMS()); EncounterEvent event(discIt->time);
if(getDeviceEvent(event, discIt->id, rssiReportInterval_)) if(getDeviceEvent(event, discIt->id, rssiReportInterval_))
{ {
encounters.push_back(event); encounters.push_back(event);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment