-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocalizer.js
More file actions
36 lines (30 loc) · 983 Bytes
/
localizer.js
File metadata and controls
36 lines (30 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var mediator = require('./mediator'),
Environment = require('./environment'),
logger = require('./logger'),
Guide = require('./guide');
var x = null,
y = null,
name = null,
environ = null;
mediator.pubsub.on('strongestBeaconChange',function(msg){
var beacon = Environment.getStrongestBeacon();
logger.log("data","[STRONGEST BEACON] "+beacon.btName+" RSSI "+beacon.currentRSSI+" TRIGGER "+beacon.rssiAtAssociationRange);
if(beacon.isHot()){
if(x!=beacon.x||y!=beacon.y){
x = beacon.x;
y = beacon.y;
name = beacon.btName;
//Guide.speak("Position updated. Scan for direction.");
logger.log("announce","[NEW POSITION] ("+x+","+y+")");
mediator.pubsub.emit('newLocation');
}
}
})
function getLocationName(){
return name;
}
function setEnvironment(e){
environ = e;
}
module.exports.setEnvironment = setEnvironment;
module.exports.getLocationName = getLocationName;