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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
|
#include "testApp.h"
/*
openBTS visualisation
ALL units relative to screen size in H or W
viewpoint dynamic? focus on 'interesting' events?
FRAMING
REPRESENTATION OF TIME
LABELLING & INFO
handset class
represents a handset
how to deal with time/ range being limited
-exponential
-choose VP carefully- perspective
-just decide the longest time that it will be active
scalability
-amount of text on screen
icons
-worthwhile?
call/sms -pointer from caller to callee
position update
function to interpolate position
basically working
-antialisaing on polys in crazy
-colours of everything pretty naff
-fading feature
-draw incoming events text
//logarithmic time
//better colours/ thicker lines?
//line in middle?
//colours from networks
//ripples from events
//ringing and connected segments of call - polygons much more transparent
*/
std::vector<std::string> split(std::string l, char delim)
{
std::istringstream stm(l);
std::vector<std::string> tokens;
for (;;) {
std::string word;
if (!getline(stm, word, delim)) break;
tokens.push_back(word);
}
return tokens;
}
void testApp::setup(){
printf("setup: %ix%i on screen %ix%i\n",ofGetWidth(),ofGetHeight(),ofGetScreenWidth(),ofGetScreenHeight());
int windowMode = ofGetWindowMode();
if(windowMode == OF_FULLSCREEN){
this->windowWidth = ofGetWidth(); //Screen
this->windowHeight = ofGetHeight(); //Screen
}
else if(windowMode == OF_WINDOW){
this->windowWidth = ofGetWidth();
this->windowHeight = ofGetHeight();
}
//Q Why is it that if you put a camera at (0,0,-100) looking at (0,0,0) and an object at (0,0,0) the camera isn't pointing at the object?
//A Because ortho is different
/*
camera.enableOrtho();
camera.setPosition(-windowWidth/2,-windowHeight*4.1f,windowWidth);
//camera.lookAt(ofVec3f(-windowWidth/2,-windowHeight,0),ofVec3f(0, 1, 0));
camera.rotate(70,1,0,0);
camera.cacheMatrices(); //stop error messages
*/
//ofSetFrameRate(25);
ofSetCircleResolution(windowWidth);
ofEnableSmoothing();
camera.setPosition(0,windowHeight*10,windowHeight);
camera.lookAt(ofVec3f(0,0,-windowHeight*.49),ofVec3f(0, 0, 1));
camera.setFov(6.5);
// camera.cacheMatrices();3047
bgimg.allocate(256,256,OF_IMAGE_COLOR);
cols=new ofColor[4];
cols[0]=ofColor(100,100,150);
cols[1]=ofColor(100,100,100);
cols[2]=ofColor(0,0,0);
cols[3]=ofColor(0,0,0);
float fi,fj,ifi,ifj;
fi=0.0f;
ifi=1.0f;
float si=1.0f/bgimg.width;
float sj=1.0f/bgimg.height;
unsigned char* px=bgimg.getPixels();
for (int i=0;i<bgimg.width;i++,fi+=si,ifi-=si){
fj=0.0f;
ifj=1.0f;
for (int j=0;j<bgimg.height;j++,fj+=sj,ifj-=sj){
px[(j*bgimg.width+i)*3]=(unsigned char)((ifj*((ifi*cols[0].r)+(fi*cols[1].r)))+(fj*((ifi*cols[2].r)+(fi*cols[3].r))));
px[(j*bgimg.width+i)*3+1]=(unsigned char)((ifj*((ifi*cols[0].g)+(fi*cols[1].g)))+(fj*((ifi*cols[2].g)+(fi*cols[3].g))));
px[(j*bgimg.width+i)*3+2]=(unsigned char)((ifj*((ifi*cols[0].b)+(fi*cols[1].b)))+(fj*((ifi*cols[2].b)+(fi*cols[3].b))));
}
}
textimg.loadImage("text.png");
bgimg.setUseTexture(true);
bgimg.update();
icons=new ofImage[3];
icons[0].loadImage("Phone.png");
icons[1].loadImage("iPhone.png");
icons[2].loadImage("Tablet.png");
//create the socket and bind to port 7888
udpConnection.Create();
udpConnection.Bind(7888);
udpConnection.SetNonBlocking(true);
string def="";
devices["base"]=obtsDevice(def,def,def,icons,ofVec2f(0,0));
devices["base"].connect();
message="";
messageTime=0.0f;
showFps=false;
}
//--------------------------------------------------------------
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 mess=udpMessage;
if(mess.length()){
messageTime=ofGetElapsedTimef();
printf("%s\n",mess.c_str());
vector<string> tokens=split(mess,'^');
//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")) { //this is an event
message=tokens[0]+" "+tokens[3];
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/3)+(windowWidth/6);
devices[number]=obtsDevice(imsi,imei,number,icons,ofVec2f(a,r));
}
if(tokens[3].find("retreived")==string::npos) 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],' ')[4];
printf(">>> SMS from %s to %s (%i)\n",number.c_str(),t_number.c_str(),devices.count(t_number));
if (devices.count(t_number)) {
devices[t_number].excite(); //just in case it hasnt been recognised
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[t_number].excite(); //just in case it hasnt been recognised
devices[number].call(&devices[t_number]);
}
else devices[number].call(&devices["base"]);
}
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[t_number].excite(); //just in case it hasnt been recognised
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[t_number].excite(); //just in case it hasnt been recognised
devices[number].connectCall();
}
}
if(tokens[3].find("GSM release")!=string::npos) devices[number].endCall();
}
}
}
//--------------------------------------------------------------
void testApp::draw(){
devices["base"].excite();
ofSetLineWidth(1.5f);
glDisable(GL_LIGHTING);
ofSetHexColor(0xffffff);
bgimg.draw(0,0,windowWidth,windowHeight);
ofEnableAlphaBlending();
ofSetColor(0xff,0xff,0xff,0x5f);
textimg.draw(0,windowHeight-(textimg.getHeight()*2),textimg.getWidth()*2,textimg.getHeight()*2);
ofDisableAlphaBlending();
camera.begin();
//ofSphere(0,0,0,10);
glDisable(GL_DEPTH_TEST);
glDisable(GL_BLEND);
ofPushMatrix();
ofRotate(ofGetElapsedTimef(),0,0,1);
ofNoFill();
float rt=((ofGetElapsedTimef()*.25f)-floor(ofGetElapsedTimef()*.25f));
for (float f=rt*(windowWidth/10);f<windowWidth*0.9;f+=windowWidth/10) {
float rf=sin((f/(windowWidth*0.9))*TWO_PI);
ofSetColor(0x7f*rf,0x7f*rf,0xff*rf,0xff*rf);
ofEnableAlphaBlending();
ofCircle(0,0,0,f);
ofDisableAlphaBlending();
}
/*
for (int i=start;i<end;i++) {
float rf=sin((lines[i].y/(windowWidth*0.9))*TWO_PI);
ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf);
ofLine(cos(lines[i].x)*lines[i].y,sin(lines[i].x)*lines[i].y,0,cos(lines[i].x)*lines[i].y,sin(lines[i].x)*lines[i].y,lines[i].z);
}
for (int i=start;i<end;i++) {
float rf=sin((lines[i].y/(windowWidth*0.9))*TWO_PI);
ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf);
ofVec3f p=camera.worldToScreen(ofVec3f(cos(lines[i].x)*lines[i].y,sin(lines[i].x)*lines[i].y,lines[i].z).rotated(ofGetElapsedTimef(),ofVec3f(0,0,1)),ofGetCurrentViewport());
ofDrawBitmapString(imeis[i],p.x-20,p.y,p.z);
}
*/
float timeScale=windowHeight/ofGetElapsedTimef(); //pixels per second
for (map<string,obtsDevice>::iterator i=devices.begin();i!=devices.end();i++){
(*i).second.draw(timeScale);
}
ofPopMatrix();
camera.end();
ofSetHexColor(0xffffff);
char reportStr[1024];
if (showFps) {
sprintf(reportStr, "fps: %3.0f", ofGetFrameRate());
ofDrawBitmapString(reportStr, windowWidth-70, 12);
}
int amt=255-((ofGetElapsedTimef()-messageTime)*8.0f);
if (amt>0) {
//ofEnableAlphaBlending();
ofSetColor(amt,amt,amt);
sprintf(reportStr, "%s", message.c_str());
ofDrawBitmapString(reportStr, 10, windowHeight-10);
//ofDisableAlphaBlending();
}
//ofSaveFrame();
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
switch (key){
case ' ':
ofSaveFrame();
printf("[%8.2f] saved an image\n",ofGetElapsedTimef());
break;
case 'f':
showFps=!showFps;
}
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void testApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
|