summaryrefslogtreecommitdiff
path: root/src/testApp.cpp
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 /src/testApp.cpp
parent5fb03da0c11eb42d425974a145ffa4cf3edc82a7 (diff)
drawing calls and sms
Diffstat (limited to 'src/testApp.cpp')
-rw-r--r--src/testApp.cpp126
1 files changed, 99 insertions, 27 deletions
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);