summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@gray.(none)>2012-06-28 20:48:25 +0100
committerTim Redfern <tim@gray.(none)>2012-06-28 20:48:25 +0100
commit74b9797991ceaabf98613a70a10a4b329a254c93 (patch)
tree79811007505744d9ccebd6fb9401ae61d6b561f9
parent5fb03da0c11eb42d425974a145ffa4cf3edc82a7 (diff)
drawing calls and sms
-rwxr-xr-xeventStreamer/eventStreamer.py16
-rw-r--r--openBTSviz.cbp6
-rw-r--r--openBTSviz.layout12
-rw-r--r--src/main.cpp2
-rw-r--r--src/obtsDevice.cpp96
-rw-r--r--src/obtsDevice.h60
-rw-r--r--src/testApp.cpp126
-rw-r--r--src/testApp.h6
8 files changed, 268 insertions, 56 deletions
diff --git a/eventStreamer/eventStreamer.py b/eventStreamer/eventStreamer.py
index c6f9f1f..ca64542 100755
--- a/eventStreamer/eventStreamer.py
+++ b/eventStreamer/eventStreamer.py
@@ -1,4 +1,11 @@
#!/usr/bin/python
+#
+#Translates openBTS logs into UDP event packets.
+#
+#http://openhere.data.ie/
+#
+#TJR June 2012
+#
import MySQLdb,datetime,string,time,socket
import config
@@ -18,8 +25,9 @@ outsock = socket.socket( socket.AF_INET,socket.SOCK_DGRAM )
devices={}
def sendevent(e):
- print str(e[3]),str(e[1]),devices[e[3]]['IMSI']
- outsock.sendto( devices[e[3]]['IMSI']+","+str(e[1]), (config.viz_ip, config.viz_port) )
+ #send all data in each event to avoid translation script having a state
+ print str(e[3]),devices[e[3]]['IMSI'],devices[e[3]]['IMEI'],devices[e[3]]['number'],str(e[1])
+ outsock.sendto( devices[e[3]]['IMSI']+","+devices[e[3]]['IMEI']+","+devices[e[3]]['number']+","+str(e[1]), (config.viz_ip, config.viz_port) )
def main():
@@ -53,8 +61,8 @@ def main():
for row in results:
d={}
d['IMSI']=row[1]
- d['number']=row[2]
- d['ts']=row[3]
+ d['IMEI']=row[2]
+ d['number']=row[3]
devices[row[0]]=d
except:
print "Error: unable to fetch handset list"
diff --git a/openBTSviz.cbp b/openBTSviz.cbp
index 35145bd..dd13611 100644
--- a/openBTSviz.cbp
+++ b/openBTSviz.cbp
@@ -39,6 +39,12 @@
<Unit filename="src/main.cpp">
<Option virtualFolder="src/" />
</Unit>
+ <Unit filename="src/obtsDevice.cpp">
+ <Option virtualFolder="src/" />
+ </Unit>
+ <Unit filename="src/obtsDevice.h">
+ <Option virtualFolder="src/" />
+ </Unit>
<Unit filename="src/testApp.cpp">
<Option virtualFolder="src/" />
</Unit>
diff --git a/openBTSviz.layout b/openBTSviz.layout
index c86aac8..3a0aa18 100644
--- a/openBTSviz.layout
+++ b/openBTSviz.layout
@@ -11,10 +11,16 @@
<Cursor position="328" topLine="0" />
</File>
<File name="src/main.cpp" open="1" top="0" tabpos="5">
- <Cursor position="219" topLine="0" />
+ <Cursor position="215" topLine="0" />
</File>
- <File name="src/testApp.cpp" open="1" top="1" tabpos="6">
- <Cursor position="3314" topLine="0" />
+ <File name="src/obtsDevice.cpp" open="1" top="1" tabpos="7">
+ <Cursor position="1320" topLine="30" />
+ </File>
+ <File name="src/obtsDevice.h" open="1" top="0" tabpos="8">
+ <Cursor position="1726" topLine="37" />
+ </File>
+ <File name="src/testApp.cpp" open="1" top="0" tabpos="6">
+ <Cursor position="5636" topLine="164" />
</File>
<File name="src/testApp.h" open="1" top="0" tabpos="4">
<Cursor position="629" topLine="0" />
diff --git a/src/main.cpp b/src/main.cpp
index 5e84581..ad74a97 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -6,7 +6,7 @@
int main( ){
ofAppGlutWindow window;
- ofSetupOpenGL(&window, 720,400, OF_WINDOW ); // <-------- setup the GL context
+ ofSetupOpenGL(&window, 450,800, OF_WINDOW ); // <-------- setup the GL context
printf("%ix%i on screen %ix%i\n",ofGetWidth(),ofGetHeight(),ofGetScreenWidth(),ofGetScreenHeight());
// this kicks off the running of my app
// can be OF_WINDOW or OF_FULLSCREEN
diff --git a/src/obtsDevice.cpp b/src/obtsDevice.cpp
index 70e60c3..85d5f18 100644
--- a/src/obtsDevice.cpp
+++ b/src/obtsDevice.cpp
@@ -4,30 +4,82 @@ obtsDevice::obtsDevice()
{
}
-obtsDevice::obtsDevice(string &imsi,ofImage *_icon,ofVec2f _coords)
+obtsDevice::obtsDevice(string &imsi,string &imei,string &num,ofImage *_icon,ofVec2f _coords)
{
IMSI=imsi;
+ IMEI=imei;
+ number=num;
coords=_coords;
icon=_icon;
- connect();
+ active=false;
+ calling=false;
+ exciteLevel=1.0;
+ lastTime=ofGetElapsedTimef();
printf("new device: IMSI%s\n",IMSI.c_str());
}
+obtsDevice::~obtsDevice()
+{
+ //dtor
+}
+
+
void obtsDevice::connect(){
- connectionHistory.push_back(timeseg(ofGetElapsedTimef(),0.0f));
+ if (!active) {
+ connectionHistory.push_back(timeseg());
+ active=true;
+ }
}
void obtsDevice::disconnect(){
- connectionHistory[connectionHistory.size()-1].endTime=ofGetElapsedTimef();
+ if (active) {
+ connectionHistory[connectionHistory.size()-1].endTime=ofGetElapsedTimef();
+ active=false;
+ }
}
-obtsDevice::~obtsDevice()
-{
- //dtor
+void obtsDevice::ringing(obtsDevice *to){
+ if (!calling) {
+ callHistory.push_back(tcall(to,false));
+ calling=true;
+ }
+}
+
+void obtsDevice::connectCall(){
+ if (calling) {
+ callHistory[callHistory.size()-1].connect();
+ }
+}
+
+void obtsDevice::call(obtsDevice *to){
+ if (!calling) {
+ callHistory.push_back(tcall(to,true));
+ calling=true;
+ }
+}
+
+void obtsDevice::endCall(){
+ if (calling) {
+ callHistory[callHistory.size()-1].endTime=ofGetElapsedTimef();
+ callHistory[callHistory.size()-1].connected=false;
+ calling=false;
+ }
+}
+
+void obtsDevice::sms(obtsDevice *to){
+ smsHistory.push_back(tsms(to));
+}
+
+void obtsDevice::excite(float amount) {
+ exciteLevel=amount;
}
void obtsDevice::draw(float timeScale)
{
+ float decay=1.0;
+ float now=ofGetElapsedTimef();
+ float timeSeg=now-lastTime;
+ lastTime=now;
//draw a line at the angular position of the device
//z=0 is the 'surface' i.e. now.
//the device know the time now and when it was created
@@ -37,11 +89,35 @@ void obtsDevice::draw(float timeScale)
//for fixed/dynamic, pass a scaling parameter when drawing
float rf=sin((coords.y/(ofGetWidth()*0.9))*TWO_PI);
ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf);
- float now=ofGetElapsedTimef();
+ float endPos;
for (vector<timeseg>::iterator i=connectionHistory.begin();i!=connectionHistory.end();i++){
- float startPos=(-now+(*i).startTime)/timeScale;
- float endPos=(*i).endTime>0.0f?(-now+(*i).endTime)/timeScale:0.0f;
+ float startPos=((*i).startTime-now)/timeScale;
+ endPos=(*i).endTime>0.0f?((*i).endTime-now)/timeScale:0.0f;
ofLine(cos(coords.x)*coords.y,sin(coords.x)*coords.y,startPos,cos(coords.x)*coords.y,sin(coords.x)*coords.y,endPos);
//printf("%f drawing %f,%f,%f to %f,%f,%f\n",ofGetElapsedTimef(),cos(coords.x)*coords.y,sin(coords.x)*coords.y,startPos,cos(coords.x)*coords.y,sin(coords.x)*coords.y,endPos);
}
+ ofSetColor(0xff,0x8f,0x8f);
+ for (vector<tsms>::iterator i=smsHistory.begin();i!=smsHistory.end();i++){
+ float timepos=((*i).time-now)/timeScale;
+ ofLine(cos(coords.x)*coords.y,sin(coords.x)*coords.y,timepos,cos((*i).recipient->coords.x)*(*i).recipient->coords.y,sin((*i).recipient->coords.x)*(*i).recipient->coords.y,timepos);
+ }
+
+ for (vector<tcall>::iterator i=callHistory.begin();i!=callHistory.end();i++){
+ ofSetColor(0xff,0xff,0x8f);
+ float stimepos=((*i).startTime-now)/timeScale;
+ float etimepos=((*i).endTime>0.0f?((*i).endTime-now)/timeScale:0.0f);
+ glBegin(GL_QUADS);
+ glVertex3f(cos(coords.x)*coords.y,sin(coords.x)*coords.y,stimepos);
+ glVertex3f(cos((*i).recipient->coords.x)*(*i).recipient->coords.y,sin((*i).recipient->coords.x)*(*i).recipient->coords.y,stimepos);
+ glVertex3f(cos((*i).recipient->coords.x)*(*i).recipient->coords.y,sin((*i).recipient->coords.x)*(*i).recipient->coords.y,etimepos);
+ glVertex3f(cos(coords.x)*coords.y,sin(coords.x)*coords.y,etimepos);
+ glEnd();
+ }
+
+ int greylev=0x7f+((int)(128.0f*exciteLevel));
+ ofSetHexColor(greylev+(greylev<<8)+(greylev<<16));
+ ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
+ ofDrawBitmapString(number,cos(coords.x)*coords.y,sin(coords.x)*coords.y,endPos);
+ ofSetDrawBitmapMode(OF_BITMAPMODE_SIMPLE);
+ exciteLevel=pow(exciteLevel,1+(timeSeg*decay));
}
diff --git a/src/obtsDevice.h b/src/obtsDevice.h
index 884600b..b300d64 100644
--- a/src/obtsDevice.h
+++ b/src/obtsDevice.h
@@ -16,15 +16,50 @@ functions: draw(time) getPosition(time)
variables: pointer to icon image
+//draw the icons - passed the IMEI
+//colours for networks
+//connect & disconnect
+
*/
+class obtsDevice; //forward declaration
+
struct timeseg{
- timeseg(float _st,float _et){
- startTime=_st;
- endTime=_et;
+ timeseg(){
+ startTime=ofGetElapsedTimef();
+ endTime=0.0f;
+ }
+ float startTime;
+ float endTime;
+};
+
+struct tsms{
+ tsms(obtsDevice* to){
+ recipient=to;
+ time=ofGetElapsedTimef();
}
+ obtsDevice *recipient;
+ float time;
+};
+
+struct tcall{
+ tcall(obtsDevice* to,bool _connected){
+ recipient=to;
+ startTime=ofGetElapsedTimef();
+ endTime=0.0f;
+ connected=_connected;
+ if (connected) connectedTime=startTime;
+ else connectedTime=0.0f;
+ }
+ void connect(){
+ connected=true;
+ connectedTime=ofGetElapsedTimef();
+ }
+ obtsDevice *recipient;
float startTime;
+ float connectedTime;
float endTime;
+ bool connected;
};
@@ -32,17 +67,32 @@ class obtsDevice
{
public:
obtsDevice();
- obtsDevice(string &imsi,ofImage *_icon,ofVec2f _coords);
+ obtsDevice(string &imsi,string &imei,string &num,ofImage *_icon,ofVec2f _coords);
virtual ~obtsDevice();
void draw(float timeScale); //units per second
void connect();
void disconnect();
+ void ringing(obtsDevice *to);
+ void call(obtsDevice *to);
+ void connectCall();
+ void endCall();
+ void sms(obtsDevice *to);
+ void excite(float amount=1.0);
protected:
private:
- string IMSI;
+ float exciteLevel;
+ string IMSI,IMEI,number;
ofVec2f coords; //angular coords
vector<timeseg> connectionHistory;
+ vector<tsms> smsHistory; //argle
+ vector<tcall> callHistory;
ofImage *icon;
+ bool active,calling;
+
+ float lastTime;
};
+
+
+
#endif // OBTSDEVICE_H
diff --git a/src/testApp.cpp b/src/testApp.cpp
index ae42217..3ce4f36 100644
--- a/src/testApp.cpp
+++ b/src/testApp.cpp
@@ -33,6 +33,12 @@ position update
function to interpolate position
+basically working
+-antialisaing on polys in crazy
+-colours of everything pretty naff
+-fading feature
+-draw incoming events text
+
*/
std::vector<std::string> split(std::string l, char delim)
@@ -71,7 +77,7 @@ void testApp::setup(){
camera.cacheMatrices(); //stop error messages
*/
- ofSetFrameRate(25);
+ //ofSetFrameRate(25);
ofSetCircleResolution(windowWidth);
ofEnableSmoothing();
@@ -81,24 +87,6 @@ void testApp::setup(){
camera.setFov(6.5);
camera.cacheMatrices();
- numLines=100;
-
- lines = new ofPoint[numLines];
- imeis = new string[numLines];
- for (int i=0;i<numLines;i++) {
- float a=ofRandom(TWO_PI);
- float r=ofRandom(windowWidth/2);
- float l=ofRandom(windowHeight);
- lines[i]=ofPoint(a,r,-l); //polar coords
- for (int j=0;j<15;j++) {
- imeis[i]+=(char)(ofRandom(10)+48);
- }
- }
-
- start=10;
- end=15;
-
-
bgimg.allocate(256,256,OF_IMAGE_COLOR);
@@ -138,29 +126,114 @@ void testApp::setup(){
udpConnection.Create();
udpConnection.Bind(7888);
udpConnection.SetNonBlocking(true);
+
+ string def="default";
+ devices["base"]=obtsDevice(def,def,def,icons,ofVec2f(0,0));
}
//--------------------------------------------------------------
void testApp::update(){
+
//check incoming messages
//create device or update as necessary
+ //also display a feed of events in text form
+
+ /*
+
+ MESSAGE FORMAT
+
+ NETWORK
+
+ * "GSM joined network" for a first time connection
+ * "GSM rejoined network" for a phone coming back
+ * "GSM leaving network" for a phone leaving. (Though these can't be relied upon)
+
+ SMS
+
+ * "SMS to IMSIXXXXXXXXXXXXXXX queued for sending" for an attempt to text a valid number
+ * "SMS to XX failed. Number not found" for an attempt to text an invalid number
+ * "SMS Message acknowledged" A message sent by this IMSI was delivered.
+
+ CALLS
+
+ a.) To a non-mobile number:
+
+ * "GSM connect acknowledge <phone_number>" at call commence.
+ * "GSM disconnect" and then "GSM release" at call end.
+
+ b.) To a mobile number:
+
+ * "GSM alerting <phone_number>" when ringing.
+ * "GSM call confirmed to <phone_number>" when ringing at both ends.
+ * "GSM connect to <phone_number>" at pickup.
+ * "GSM disconnect" as above at end, then "GSM release from <phone_number".
+
+ username: "tim"
+ password: "Visualise this"
+ host: 134.226.86.120
+ database: openbts
+
+ As a sanity check, you should be able to connect from a command line using:
+
+ > mysql -u tim -h 134.226.86.120 -p
+ <Enter password>
+ > use openbts
+
+ */
char udpMessage[1024];
udpConnection.Receive(udpMessage,1024);
string message=udpMessage;
if(message.length()){
vector<string> tokens=split(message,',');
- string imsi=tokens[0].substr(4);
//long dev=atol(n.c_str()); something crazy going on. this always seems to read out 32 bits
- if (!tokens[0].substr(0,4).compare("IMSI")) { //not an event
- if (!devices.count(imsi)) {
+ if (!tokens[0].substr(0,4).compare("IMSI")) { //this is an event
+ string number=tokens[2];
+ if (!devices.count(number)) {
+ string imei=string(tokens[1]);
+ string imsi=string(tokens[0].substr(4));
//create a new device at a random position
float a=ofRandom(TWO_PI);
- float r=ofRandom(windowWidth/2);
- devices[imsi]=obtsDevice(imsi,icons,ofVec2f(a,r));
+ float r=ofRandom(windowWidth/3)+(windowWidth/6);
+ devices[number]=obtsDevice(imsi,imei,number,icons,ofVec2f(a,r));
+ }
+ devices[number].excite(); //whenever an event concerns a device it brightens
+
+ if(tokens[3].find("joined network")!=string::npos) devices[number].connect();
+ if(tokens[3].find("leaving network")!=string::npos) devices[number].disconnect();
+ if(tokens[3].find("queued")!=string::npos) {
+ string t_number=split(tokens[3],' ')[2];
+ printf("SMS from %s to %s\n",number.c_str(),t_number.c_str());
+ if (devices.count(t_number)) {
+ devices[number].sms(&devices[t_number]);
+ }
+ }
+ if(tokens[3].find("connect acknowledge")!=string::npos) {
+ string t_number=split(tokens[3],' ')[3];
+ printf("call from %s to %s\n",number.c_str(),t_number.c_str());
+ if (devices.count(t_number)) {
+ devices[number].call(&devices[t_number]);
+ }
+ else devices[number].call(&devices["default"]);
+ }
+ if(tokens[3].find("call confirmed")!=string::npos) {
+ string t_number=split(tokens[3],' ')[4];
+ printf("ringing from %s to %s\n",number.c_str(),t_number.c_str());
+ if (devices.count(t_number)) {
+ devices[number].ringing(&devices[t_number]);
+ }
+ }
+ if(tokens[3].find("connect to")!=string::npos) {
+ string t_number=split(tokens[3],' ')[3];
+ printf("call connected from %s to %s\n",number.c_str(),t_number.c_str());
+ if (devices.count(t_number)) {
+ devices[number].connectCall();
+ }
}
- printf("%s\n",imsi.c_str());
+ if(tokens[3].find("GSM release")!=string::npos) devices[number].endCall();
+
+
}
else printf("%s\n",tokens[0].c_str());
}
@@ -168,9 +241,8 @@ void testApp::update(){
//--------------------------------------------------------------
void testApp::draw(){
- if (ofRandom(1.0)>0.99) start=min(99,start+1);
- if (ofRandom(1.0)>0.98) end=min(99,end+1);
+ ofSetLineWidth(1.5f);
glDisable(GL_LIGHTING);
bgimg.draw(0,0,windowWidth,windowHeight);
diff --git a/src/testApp.h b/src/testApp.h
index 29c9d03..cfb6f0a 100644
--- a/src/testApp.h
+++ b/src/testApp.h
@@ -28,12 +28,6 @@ class testApp : public ofBaseApp{
map<string,obtsDevice> devices;
- int numLines;
- ofPoint *lines;
- string *imeis;
-
- int start,end;
-
ofImage bgimg;
ofColor *cols;