summaryrefslogtreecommitdiffstats
path: root/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources
diff options
context:
space:
mode:
Diffstat (limited to 'Src/eclipse/.metadata/.plugins/org.eclipse.core.resources')
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/0/80724b69a6f2001019c79f38f40e52ba53
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/0/809df803a7f2001019c79f38f40e52ba57
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/11/c0d39316bbf100101fc6d5dee7f902b6824
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/12/50c0646979f2001019c79f38f40e52ba111
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/14/f045290a99f2001019c79f38f40e52ba43
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/18/f0e1cb9376f2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1c/00ad039779f2001019c79f38f40e52ba111
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1f/50bcc67f6ef2001013089cecc8a626ff52
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1f/70887a0eb9f100101fc6d5dee7f902b6823
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2/50a917bf96f2001019c79f38f40e52ba41
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/21/306e25ea72f2001019c79f38f40e52ba76
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/22/d05c9a89a7f2001019c79f38f40e52ba59
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/24/309d645797f2001019c79f38f40e52ba42
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/200219d8a8f2001019c79f38f40e52ba115
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/70afa34676f2001019c79f38f40e52ba133
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/70eef59a7cf2001019c79f38f40e52ba55
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2c/701a355cbaf100101fc6d5dee7f902b6824
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2c/d09ab8b97af2001019c79f38f40e52ba54
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/009445f880f2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/40352fbb7af2001019c79f38f40e52ba54
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/60915ebb74f2001019c79f38f40e52ba76
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3/304c2c2d78f2001019c79f38f40e52ba83
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/30/c0de99f993f2001019c79f38f40e52ba57
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/31/70ab7def79f2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/31/b054af3b95f2001019c79f38f40e52ba36
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/34/60a3370194f2001019c79f38f40e52ba57
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/00df2df6b9f100101fc6d5dee7f902b6824
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/406dec5270f2001013089cecc8a626ff73
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/b0fb1f8075f2001019c79f38f40e52ba82
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/37/108910487af2001019c79f38f40e52ba113
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/38/903d7e0179f2001019c79f38f40e52ba99
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/39/20f54fab7ef2001019c79f38f40e52ba53
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3a/30fc6a5a93f2001019c79f38f40e52ba57
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70a4dbf8baf100101fc6d5dee7f902b6824
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3d/0063938879f2001019c79f38f40e52ba111
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3d/60d3a1e97ff2001019c79f38f40e52ba54
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3e/40158315a6f2001019c79f38f40e52ba48
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/41/a0d0fc9a9af2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/41/b0277c4870f2001013089cecc8a626ff73
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/42/1029600bb9f100101fc6d5dee7f902b6822
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/43/10b7eba37ef2001019c79f38f40e52ba53
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/43/a09263f594f2001019c79f38f40e52ba33
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/45/40832d7574f2001019c79f38f40e52ba76
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/45/f05d2f919ef2001019c79f38f40e52ba44
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/47/0053978475f2001019c79f38f40e52ba82
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/47/c0ac774db8f100101fc6d5dee7f902b6821
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/48/60a9c87f74f2001019c79f38f40e52ba76
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/49/50e7aec57ef2001019c79f38f40e52ba53
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4d/e070b4b399f2001019c79f38f40e52ba43
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4e/1099a8e99ef2001019c79f38f40e52ba46
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4f/409c89e692f2001019c79f38f40e52ba30
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/50/70fa89f7a7f2001019c79f38f40e52ba60
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/52/701063ea93f2001019c79f38f40e52ba57
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/54/207fc56993f2001019c79f38f40e52ba59
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/55/b0d520b394f2001019c79f38f40e52ba32
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/55/e0e2e3dda5f2001019c79f38f40e52ba47
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/56/a0aab0d478f2001019c79f38f40e52ba100
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/57/4009d7c6a2f2001019c79f38f40e52ba47
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5a/60c47c6a97f2001019c79f38f40e52ba42
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5b/707fc8806ff2001013089cecc8a626ff71
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5c/102a296345f300101883fa35752b544b824
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5c/802b0bfea7f2001019c79f38f40e52ba60
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5d/d0bbc63480f2001019c79f38f40e52ba54
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/60/406700eba6f2001019c79f38f40e52ba55
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/61/e08194a57af2001019c79f38f40e52ba54
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/63/a0b698a879f2001019c79f38f40e52ba111
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/65/304bccca95f2001019c79f38f40e52ba37
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/66/d0bcdf7a7af2001019c79f38f40e52ba113
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/67/9046d1037ff2001019c79f38f40e52ba53
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/67/d06f0dae70f2001013089cecc8a626ff74
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/68/3059941eb8f100101fc6d5dee7f902b6820
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/68/903de4d6a6f2001019c79f38f40e52ba55
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/6c/603ece379ff2001019c79f38f40e52ba115
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/6c/c0fb5eec78f2001019c79f38f40e52ba100
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/70/b00ea6a778f2001019c79f38f40e52ba98
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/71/401a8118baf100101fc6d5dee7f902b6824
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/71/605b64bd93f2001019c79f38f40e52ba33
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/73/202199087af2001019c79f38f40e52ba111
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/75/008ba64293f2001019c79f38f40e52ba57
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/77/f048b41e97f2001019c79f38f40e52ba41
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/78/20ff0f466ff2001013089cecc8a626ff71
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/79/80a9be6276f2001019c79f38f40e52ba54
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/7b/90342ca6a7f2001019c79f38f40e52ba58
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/7e/60ef6ad577f2001019c79f38f40e52ba82
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/84/c0614a7670f2001013089cecc8a626ff74
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/85/e011f3a7a7f2001019c79f38f40e52ba59
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/86/609cf02c70f2001013089cecc8a626ff72
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/89/20c7b2636ef2001013089cecc8a626ff50
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8a/00229f17a7f2001019c79f38f40e52ba58
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8a/50abaff980f2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8c/0007523691f2001019c79f38f40e52ba29
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9/00ec0b5d76f2001019c79f38f40e52ba51
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9/30082eba96f2001019c79f38f40e52ba41
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/90/c051e5f079f2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/91/f0e9754a72f2001019c79f38f40e52ba824
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/94/00dbdc9893f2001019c79f38f40e52ba60
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/96/70f084bf9ef2001019c79f38f40e52ba45
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/97/f035184f7ff2001019c79f38f40e52ba113
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/98/a029fc1b9ef2001019c79f38f40e52ba43
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9a/708a4064b9f100101fc6d5dee7f902b6823
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9b/c076e09f78f2001019c79f38f40e52ba97
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9c/700748b079f2001019c79f38f40e52ba111
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9e/60047c4d7af2001019c79f38f40e52ba113
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a/f042c6c4a8f2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a0/d01cd48b7ef2001019c79f38f40e52ba53
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a2/608cf8de93f2001019c79f38f40e52ba33
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a3/2097d8f194f2001019c79f38f40e52ba32
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a4/d04323d974f2001019c79f38f40e52ba80
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a5/9036ba2395f2001019c79f38f40e52ba33
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a7/704048c09ef2001019c79f38f40e52ba46
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a7/e0f402ec7ff2001019c79f38f40e52ba54
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ab/90e8e32198f2001019c79f38f40e52ba43
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ad/f034ed3493f2001019c79f38f40e52ba55
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/70572ccb93f2001019c79f38f40e52ba33
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/a01ff9a797f2001019c79f38f40e52ba57
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/d016566876f2001019c79f38f40e52ba134
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b/5074d5f6a3f2001019c79f38f40e52ba47
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b/d010489ba2f2001019c79f38f40e52ba46
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b2/304fe0d6a4f100101fc6d5dee7f902b6195
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b4/1076a1137cf2001019c79f38f40e52ba54
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b5/108e7d6a9ff2001019c79f38f40e52ba46
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b5/40650fe374f2001019c79f38f40e52ba81
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b8/e017b3e67ff2001019c79f38f40e52ba53
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b9/004bc24280f2001019c79f38f40e52ba54
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ba/409db4d5a0f100101fc6d5dee7f902b613
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ba/b06e730f7af2001019c79f38f40e52ba112
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/bd/803ca2d3a7f2001019c79f38f40e52ba60
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/bf/9074167f6df2001013089cecc8a626ff71
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c/50d1292c6df2001013089cecc8a626ff71
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c0/808dbdf172f2001019c79f38f40e52ba76
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c0/90c0377bb9f100101fc6d5dee7f902b6824
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c5/40a1b819a9f2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c7/8043f0f2a6f2001019c79f38f40e52ba57
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c8/d009dc3b70f2001013089cecc8a626ff73
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ce/a04fca6b6ef2001013089cecc8a626ff51
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d0/70b06cf0a7f2001019c79f38f40e52ba60
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d1/70d3bbca74f2001019c79f38f40e52ba52
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d3/20d9c4909af2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d3/e0c53cc672f2001019c79f38f40e52ba74
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d4/90921cb57cf2001019c79f38f40e52ba53
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d4/f035b3eb79f2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d5/50de5fb596f2001019c79f38f40e52ba39
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/db/105e2a299bf2001019c79f38f40e52ba136
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/db/206a23659af2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/dd/104bf38092f2001019c79f38f40e52ba30
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/de/a05b390195f2001019c79f38f40e52ba33
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e1/b038af7f9af2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e2/600de8ac96f2001019c79f38f40e52ba38
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e7/8045c3c879f2001019c79f38f40e52ba111
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ea/00ee7f5995f2001019c79f38f40e52ba36
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ec/809acae2b8f100101fc6d5dee7f902b6821
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ed/e0b609eb76f2001019c79f38f40e52ba54
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ef/30af64edb8f100101fc6d5dee7f902b6822
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ef/b0389b949ef2001019c79f38f40e52ba44
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f0/d0aaa69677f2001019c79f38f40e52ba54
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f1/102a37d070f2001013089cecc8a626ff74
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f4/20a0f53292f2001019c79f38f40e52ba30
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f4/e0af8cb878f2001019c79f38f40e52ba99
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f6/9022b6e879f2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f8/4038d97897f2001019c79f38f40e52ba57
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f8/b0bf377270f2001013089cecc8a626ff73
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fa/309e53f36ff2001013089cecc8a626ff71
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fa/40273e0481f2001019c79f38f40e52ba135
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fc/700191bfb9f100101fc6d5dee7f902b6824
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ff/e063106c6ff2001013089cecc8a626ff71
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/a8/c5/40/15/properties.indexbin0 -> 171 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/e4/ec/history.indexbin0 -> 563 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/e4/ec/properties.indexbin0 -> 154 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/properties.indexbin0 -> 364 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.locationbin0 -> 105 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.markersbin0 -> 33929 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.indexes/e4/history.indexbin0 -> 3234 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.locationbin0 -> 104 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.markersbin0 -> 1785 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/0.v1_projectinfodelta1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/1.v1_projectinfodelta29
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/2.v1_projectinfodelta1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/3.v1_projectinfodelta4
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/4.v1_projectinfodelta1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/5.v1_projectinfodelta21
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/6.v1_projectinfodelta1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/7.v1_projectinfodelta29
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/AdditionalProjectInterpreterInfo.pydevinfobin0 -> 20983 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/driverConnector_cgu0.v1_indexcache1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/main_eull.v1_indexcache1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherController_9q73.v1_indexcache1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherModel_63t0.v1_indexcache1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherSettings_2o9c.v1_indexcache1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherView_7nth.v1_indexcache1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/xdot_1ua2.v1_indexcache1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/0.v1_astdelta1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/1.v1_astdelta1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/2.v1_astdelta1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/3.v1_astdelta1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/v1_astmanager/modulesKeys8
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/v1_astmanager/pythonpath1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.indexbin0 -> 151 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version1
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/4.treebin0 -> 88564 bytes
-rw-r--r--Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resourcesbin0 -> 766 bytes
201 files changed, 23950 insertions, 0 deletions
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/0/80724b69a6f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/0/80724b69a6f2001019c79f38f40e52ba
new file mode 100644
index 0000000..7a577ee
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/0/80724b69a6f2001019c79f38f40e52ba
@@ -0,0 +1,53 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/0/809df803a7f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/0/809df803a7f2001019c79f38f40e52ba
new file mode 100644
index 0000000..55df466
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/0/809df803a7f2001019c79f38f40e52ba
@@ -0,0 +1,57 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+ if bit == '1':
+ neighbour_arfcn.append(abs(index))
+ return neighbour_arfcn
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/11/c0d39316bbf100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/11/c0d39316bbf100101fc6d5dee7f902b6
new file mode 100644
index 0000000..a4674db
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/11/c0d39316bbf100101fc6d5dee7f902b6
@@ -0,0 +1,824 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ //LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ // arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ // gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ LOGFILE("provider %s\n", gsm_get_mcc(s->mcc))
+ LOGFILE("country %s\n", gsm_get_mnc(s->mcc, s->mnc))
+ LOGFILE("arfcn %d\n", s->arfcn);
+ //log_time();
+ //log_gps();
+ //LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ //HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/12/50c0646979f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/12/50c0646979f2001019c79f38f40e52ba
new file mode 100644
index 0000000..d1e14da
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/12/50c0646979f2001019c79f38f40e52ba
@@ -0,0 +1,111 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search('',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search('',line)
+ if match:
+ base_station.country = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search('',line)
+ if match:
+ base_station.country = match.group(1)
+ #get rx
+ line = line = scan_process.stdout.readline()
+ match = re.search('',line)
+ if match:
+ base_station.country = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search('',line)
+ if match:
+ base_station.country = match.group(1)
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/14/f045290a99f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/14/f045290a99f2001019c79f38f40e52ba
new file mode 100644
index 0000000..6dc84dd
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/14/f045290a99f2001019c79f38f40e52ba
@@ -0,0 +1,43 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'graph bsnetwork{\n'
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r';\n'
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/18/f0e1cb9376f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/18/f0e1cb9376f2001019c79f38f40e52ba
new file mode 100644
index 0000000..e46caaf
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/18/f0e1cb9376f2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": ,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_close(self, widget):
+
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1c/00ad039779f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1c/00ad039779f2001019c79f38f40e52ba
new file mode 100644
index 0000000..f1e1291
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1c/00ad039779f2001019c79f38f40e52ba
@@ -0,0 +1,111 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get rx
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'',line)
+ if match:
+ base_station.country = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'',line)
+ if match:
+ base_station.country = match.group(1)
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1f/50bcc67f6ef2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1f/50bcc67f6ef2001013089cecc8a626ff
new file mode 100644
index 0000000..52d6394
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1f/50bcc67f6ef2001013089cecc8a626ff
@@ -0,0 +1,52 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning()
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def _found_base_station_callback(self):
+ self._gui.log_line("found base station")
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1f/70887a0eb9f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1f/70887a0eb9f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..00b8418
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1f/70887a0eb9f100101fc6d5dee7f902b6
@@ -0,0 +1,823 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ LOGFILE("provider: %s", )
+ LOGFILE("arfcn %d\n", s->arfcn);
+ log_time();
+ log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2/50a917bf96f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2/50a917bf96f2001019c79f38f40e52ba
new file mode 100644
index 0000000..43e4c17
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2/50a917bf96f2001019c79f38f40e52ba
@@ -0,0 +1,41 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'graph bsnetwork{\n'
+ postamble = r'''}'''
+
+
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/21/306e25ea72f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/21/306e25ea72f2001019c79f38f40e52ba
new file mode 100644
index 0000000..b4ed9a1
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/21/306e25ea72f2001019c79f38f40e52ba
@@ -0,0 +1,76 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if line == '[SysInfo]':
+ self._base_station_found_callback()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/22/d05c9a89a7f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/22/d05c9a89a7f2001019c79f38f40e52ba
new file mode 100644
index 0000000..0ea055d
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/22/d05c9a89a7f2001019c79f38f40e52ba
@@ -0,0 +1,59 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+ if bit == '1':
+ neighbour_arfcn.append(abs(index))
+ return neighbour_arfcn
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+ base_station.get_neighbour_arfcn()
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/24/309d645797f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/24/309d645797f2001019c79f38f40e52ba
new file mode 100644
index 0000000..52fd5c2
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/24/309d645797f2001019c79f38f40e52ba
@@ -0,0 +1,42 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'graph bsnetwork{\n'
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'[label='+ + r'];\n'
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/200219d8a8f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/200219d8a8f2001019c79f38f40e52ba
new file mode 100644
index 0000000..cacaf59
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/200219d8a8f2001019c79f38f40e52ba
@@ -0,0 +1,115 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+ self._firmThread = None
+ self._scanThread = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ if self._firmThread:
+ self._firmThread.join(10)
+ if self._scanThread:
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ #print line
+ #sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.provider = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.arfcn = match.group(1)
+ #get rxlev
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'rxlev\s(.\d+)',line)
+ if match:
+ base_station.rxlev = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'si2\s(.+)',line)
+ if match:
+ base_station.system_info_t2 = match.group(1).split(' ')
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/70afa34676f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/70afa34676f2001019c79f38f40e52ba
new file mode 100644
index 0000000..509e31b
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/70afa34676f2001019c79f38f40e52ba
@@ -0,0 +1,133 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": gtk.main_quit,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_close(self, widget):
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/70eef59a7cf2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/70eef59a7cf2001019c79f38f40e52ba
new file mode 100644
index 0000000..0731a05
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/70eef59a7cf2001019c79f38f40e52ba
@@ -0,0 +1,55 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found " + base_station_info.country + '(' + base_station_info.arfcn + ')')
+ self.bs_tree_list_data =
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2c/701a355cbaf100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2c/701a355cbaf100101fc6d5dee7f902b6
new file mode 100644
index 0000000..e385acf
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2c/701a355cbaf100101fc6d5dee7f902b6
@@ -0,0 +1,824 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ LOGFILE("provider: %s\n", gsm_get_mcc(s->mcc))
+ LOGFILE("country: %s\n", gsm_get_mnc(s->mcc, s->mnc))
+ LOGFILE("arfcn %d\n", s->arfcn);
+ //log_time();
+ //log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ //HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2c/d09ab8b97af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2c/d09ab8b97af2001019c79f38f40e52ba
new file mode 100644
index 0000000..f3a9921
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2c/d09ab8b97af2001019c79f38f40e52ba
@@ -0,0 +1,54 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found " + base_station_info.country)
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/009445f880f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/009445f880f2001019c79f38f40e52ba
new file mode 100644
index 0000000..7aa34d6
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/009445f880f2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_destroy(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/40352fbb7af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/40352fbb7af2001019c79f38f40e52ba
new file mode 100644
index 0000000..d4e6448
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/40352fbb7af2001019c79f38f40e52ba
@@ -0,0 +1,54 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found " + base_station_info.country + '(' + base_station_info.arfcn + '3')
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/60915ebb74f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/60915ebb74f2001019c79f38f40e52ba
new file mode 100644
index 0000000..a2ca408
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/60915ebb74f2001019c79f38f40e52ba
@@ -0,0 +1,76 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if line.strip() == '[SysInfo]':
+ self._base_station_found_callback()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3/304c2c2d78f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3/304c2c2d78f2001019c79f38f40e52ba
new file mode 100644
index 0000000..473ee89
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3/304c2c2d78f2001019c79f38f40e52ba
@@ -0,0 +1,83 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station =
+ self._base_station_found_callback()
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/30/c0de99f993f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/30/c0de99f993f2001019c79f38f40e52ba
new file mode 100644
index 0000000..dd6206b
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/30/c0de99f993f2001019c79f38f40e52ba
@@ -0,0 +1,57 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ store = gtk.ListStore(str,str,str,str)
+ store.append(('-','-','-','-'))
+ self.bs_tree_list_data = store
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.provider + ' (' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+
+ #TODO rebuild diagram
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/31/70ab7def79f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/31/70ab7def79f2001019c79f38f40e52ba
new file mode 100644
index 0000000..bbcf393
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/31/70ab7def79f2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_close(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/31/b054af3b95f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/31/b054af3b95f2001019c79f38f40e52ba
new file mode 100644
index 0000000..4a331bc
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/31/b054af3b95f2001019c79f38f40e52ba
@@ -0,0 +1,36 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ already_in_list = False
+ for item in self._base_station_list:
+
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/34/60a3370194f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/34/60a3370194f2001019c79f38f40e52ba
new file mode 100644
index 0000000..375c1fa
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/34/60a3370194f2001019c79f38f40e52ba
@@ -0,0 +1,57 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ store = gtk.ListStore(str,str,str,str)
+ store.append(('-','-','-','-'))
+ self.bs_tree_list_data = store
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.provider + ' (' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ self._base_station_list.refill_store(self.bs_tree_list_data)
+ #TODO rebuild diagram
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/00df2df6b9f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/00df2df6b9f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..0da2133
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/00df2df6b9f100101fc6d5dee7f902b6
@@ -0,0 +1,824 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ //LOGFILE("provider: %s", )
+ //LOGFILE("country: %s", )
+ LOGFILE("arfcn %d\n", s->arfcn);
+ //log_time();
+ //log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ //HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/406dec5270f2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/406dec5270f2001013089cecc8a626ff
new file mode 100644
index 0000000..1850b00
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/406dec5270f2001013089cecc8a626ff
@@ -0,0 +1,73 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ scanThread = FirmwareThread(self._base_station_found_callback)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._base_station_found_callback, self._scan_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/b0fb1f8075f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/b0fb1f8075f2001019c79f38f40e52ba
new file mode 100644
index 0000000..ad2c7cf
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/b0fb1f8075f2001019c79f38f40e52ba
@@ -0,0 +1,82 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if line.strip() == '[SysInfo]':
+ self._base_station_found_callback()
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/37/108910487af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/37/108910487af2001019c79f38f40e52ba
new file mode 100644
index 0000000..7cfc5c3
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/37/108910487af2001019c79f38f40e52ba
@@ -0,0 +1,113 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ if self._firmThread:
+ self._firmThread.join(10)
+ if self._scanThread:
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.provider = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.arfcn = match.group(1)
+ #get rx
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'rxlev\s(.\d+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'si2\s(.+)',line)
+ if match:
+ base_station.neighbours = match.group(1).split(' ')
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/38/903d7e0179f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/38/903d7e0179f2001019c79f38f40e52ba
new file mode 100644
index 0000000..35d38b3
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/38/903d7e0179f2001019c79f38f40e52ba
@@ -0,0 +1,99 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search('',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ #get rx
+ line = line = scan_process.stdout.readline()
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/39/20f54fab7ef2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/39/20f54fab7ef2001019c79f38f40e52ba
new file mode 100644
index 0000000..615f5b5
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/39/20f54fab7ef2001019c79f38f40e52ba
@@ -0,0 +1,53 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ self.bs_tree_list_data = gtk.ListStore()
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found " + base_station_info.country + '(' + base_station_info.arfcn + ')')
+ #self.bs_tree_list_data =
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3a/30fc6a5a93f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3a/30fc6a5a93f2001019c79f38f40e52ba
new file mode 100644
index 0000000..09d38c4
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3a/30fc6a5a93f2001019c79f38f40e52ba
@@ -0,0 +1,57 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ store = gtk.ListStore(str,str,str,str)
+ store.append(('a','b','c','d'))
+ self.bs_tree_list_data = store
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.country + '(' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ self.bs_tree_list_data = self._base_station_list.get_list_store()
+ #TODO rebuild diagram
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70a4dbf8baf100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70a4dbf8baf100101fc6d5dee7f902b6
new file mode 100644
index 0000000..8cb8692
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70a4dbf8baf100101fc6d5dee7f902b6
@@ -0,0 +1,824 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ //LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ // arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ // gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ LOGFILE("provider: %s\n", gsm_get_mcc(s->mcc))
+ LOGFILE("country: %s\n", gsm_get_mnc(s->mcc, s->mnc))
+ LOGFILE("arfcn %d\n", s->arfcn);
+ //log_time();
+ //log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ //HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3d/0063938879f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3d/0063938879f2001019c79f38f40e52ba
new file mode 100644
index 0000000..4f01e12
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3d/0063938879f2001019c79f38f40e52ba
@@ -0,0 +1,111 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'',line)
+ if match:
+ base_station.country = match.group(1)
+ #get rx
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'',line)
+ if match:
+ base_station.country = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'',line)
+ if match:
+ base_station.country = match.group(1)
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3d/60d3a1e97ff2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3d/60d3a1e97ff2001019c79f38f40e52ba
new file mode 100644
index 0000000..1221b11
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3d/60d3a1e97ff2001019c79f38f40e52ba
@@ -0,0 +1,54 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station_info.country + '(' + base_station_info.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ #self.bs_tree_list_data =
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3e/40158315a6f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3e/40158315a6f2001019c79f38f40e52ba
new file mode 100644
index 0000000..4fb2d9f
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3e/40158315a6f2001019c79f38f40e52ba
@@ -0,0 +1,48 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/41/a0d0fc9a9af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/41/a0d0fc9a9af2001019c79f38f40e52ba
new file mode 100644
index 0000000..7aa34d6
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/41/a0d0fc9a9af2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_destroy(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/41/b0277c4870f2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/41/b0277c4870f2001013089cecc8a626ff
new file mode 100644
index 0000000..68e86be
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/41/b0277c4870f2001013089cecc8a626ff
@@ -0,0 +1,73 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ scanThread = FirmwareThread(self._base_station_found_callback)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/42/1029600bb9f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/42/1029600bb9f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..2f91f98
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/42/1029600bb9f100101fc6d5dee7f902b6
@@ -0,0 +1,822 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ //LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ // arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ // gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ LOGFILE("arfcn %d\n", s->arfcn);
+ log_time();
+ log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/43/10b7eba37ef2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/43/10b7eba37ef2001019c79f38f40e52ba
new file mode 100644
index 0000000..717d47f
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/43/10b7eba37ef2001019c79f38f40e52ba
@@ -0,0 +1,53 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found " + base_station_info.country + '(' + base_station_info.arfcn + ')')
+ #self.bs_tree_list_data =
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/43/a09263f594f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/43/a09263f594f2001019c79f38f40e52ba
new file mode 100644
index 0000000..3b05c7d
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/43/a09263f594f2001019c79f38f40e52ba
@@ -0,0 +1,33 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.found = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, )
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/45/40832d7574f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/45/40832d7574f2001019c79f38f40e52ba
new file mode 100644
index 0000000..caba811
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/45/40832d7574f2001019c79f38f40e52ba
@@ -0,0 +1,76 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if line.strip() == '[SysInfo]':
+ self._base_station_found_callback()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/45/f05d2f919ef2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/45/f05d2f919ef2001019c79f38f40e52ba
new file mode 100644
index 0000000..15a69ee
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/45/f05d2f919ef2001019c79f38f40e52ba
@@ -0,0 +1,44 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #5-19
+
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/47/0053978475f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/47/0053978475f2001019c79f38f40e52ba
new file mode 100644
index 0000000..179d2e2
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/47/0053978475f2001019c79f38f40e52ba
@@ -0,0 +1,82 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', string, flags):
+ self._base_station_found_callback()
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/47/c0ac774db8f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/47/c0ac774db8f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..550800b
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/47/c0ac774db8f100101fc6d5dee7f902b6
@@ -0,0 +1,821 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[sysinfo]\n");
+ LOGFILE("arfcn %d\n", s->arfcn);
+ log_time();
+ log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ //HACK: no use for us right now
+ //LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ // "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/48/60a9c87f74f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/48/60a9c87f74f2001019c79f38f40e52ba
new file mode 100644
index 0000000..d60e245
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/48/60a9c87f74f2001019c79f38f40e52ba
@@ -0,0 +1,76 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if line.strip() == '[SysInfo]':
+ self._base_station_found_callback()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/49/50e7aec57ef2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/49/50e7aec57ef2001019c79f38f40e52ba
new file mode 100644
index 0000000..d35a1ac
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/49/50e7aec57ef2001019c79f38f40e52ba
@@ -0,0 +1,53 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found " + base_station_info.country + '(' + base_station_info.arfcn + ')')
+ #self.bs_tree_list_data =
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4d/e070b4b399f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4d/e070b4b399f2001019c79f38f40e52ba
new file mode 100644
index 0000000..def11b3
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4d/e070b4b399f2001019c79f38f40e52ba
@@ -0,0 +1,43 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'graph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4e/1099a8e99ef2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4e/1099a8e99ef2001019c79f38f40e52ba
new file mode 100644
index 0000000..d0604c1
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4e/1099a8e99ef2001019c79f38f40e52ba
@@ -0,0 +1,46 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #5-19
+ neighbours = self.system_info_t2[6-21]
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+ base_station.get_neighbour_arfcn()
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4f/409c89e692f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4f/409c89e692f2001019c79f38f40e52ba
new file mode 100644
index 0000000..34ba7c8
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4f/409c89e692f2001019c79f38f40e52ba
@@ -0,0 +1,30 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+
+ def get_list_model(self):
+ return [self.provider, self.arfcn, self.rxlev, datetime.datetime.now().strftime('%I:%M %p')]
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def get_list_store(self):
+ store = gtk.ListStore(str,str,str,str)
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ return store
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/50/70fa89f7a7f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/50/70fa89f7a7f2001019c79f38f40e52ba
new file mode 100644
index 0000000..cce1de8
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/50/70fa89f7a7f2001019c79f38f40e52ba
@@ -0,0 +1,60 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+ if bit == '1':
+ neighbour_arfcn.append(abs(index))
+ return neighbour_arfcn
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for station in self._base_station_list:
+ code += station.arfcn + r'; '
+ for neighbour in station.get_neighbour_arfcn():
+ code += station.arfcn + ' -> ' neighbour +
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/52/701063ea93f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/52/701063ea93f2001019c79f38f40e52ba
new file mode 100644
index 0000000..dcc4b4f
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/52/701063ea93f2001019c79f38f40e52ba
@@ -0,0 +1,57 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ store = gtk.ListStore(str,str,str,str)
+ store.append(('-','-','-','-'))
+ self.bs_tree_list_data = store
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.provider + '(' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ self.bs_tree_list_data = self._base_station_list.get_list_store()
+ #TODO rebuild diagram
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/54/207fc56993f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/54/207fc56993f2001019c79f38f40e52ba
new file mode 100644
index 0000000..bf0377c
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/54/207fc56993f2001019c79f38f40e52ba
@@ -0,0 +1,59 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ store = gtk.ListStore(str,str,str,str)
+ store.append(('a','b','c','d'))
+ self.bs_tree_list_data = store
+ self._gui = PyCatcherGUI(self)
+ store2 = gtk.ListStore(str,str,str,str)
+ store2.append(('a','b','c','d'))
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.country + '(' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ self.bs_tree_list_data = self._base_station_list.get_list_store()
+ #TODO rebuild diagram
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/55/b0d520b394f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/55/b0d520b394f2001019c79f38f40e52ba
new file mode 100644
index 0000000..d048dd7
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/55/b0d520b394f2001019c79f38f40e52ba
@@ -0,0 +1,32 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, datetime.datetime.now().strftime('%I:%M %p'))
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/55/e0e2e3dda5f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/55/e0e2e3dda5f2001019c79f38f40e52ba
new file mode 100644
index 0000000..5d6d1b8
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/55/e0e2e3dda5f2001019c79f38f40e52ba
@@ -0,0 +1,47 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+ base_station.get_neighbour_arfcn()
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/56/a0aab0d478f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/56/a0aab0d478f2001019c79f38f40e52ba
new file mode 100644
index 0000000..16f9c29
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/56/a0aab0d478f2001019c79f38f40e52ba
@@ -0,0 +1,100 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search('',line)
+ if match:
+ base_station.neighbours
+ #get provider
+ line = line = scan_process.stdout.readline()
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ #get rx
+ line = line = scan_process.stdout.readline()
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/57/4009d7c6a2f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/57/4009d7c6a2f2001019c79f38f40e52ba
new file mode 100644
index 0000000..af92733
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/57/4009d7c6a2f2001019c79f38f40e52ba
@@ -0,0 +1,47 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #examine plmn permitted byte
+ #examine
+ neighbours = self.system_info_t2[4:20]
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+ base_station.get_neighbour_arfcn()
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5a/60c47c6a97f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5a/60c47c6a97f2001019c79f38f40e52ba
new file mode 100644
index 0000000..40f7bc8
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5a/60c47c6a97f2001019c79f38f40e52ba
@@ -0,0 +1,42 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'graph bsnetwork{\n'
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'\n'
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5b/707fc8806ff2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5b/707fc8806ff2001013089cecc8a626ff
new file mode 100644
index 0000000..609e61f
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5b/707fc8806ff2001013089cecc8a626ff
@@ -0,0 +1,71 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self:_base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ threading.Thread(target= self._do_scan).start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5c/102a296345f300101883fa35752b544b b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5c/102a296345f300101883fa35752b544b
new file mode 100644
index 0000000..c1cf06a
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5c/102a296345f300101883fa35752b544b
@@ -0,0 +1,824 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ //LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ // arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ // gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ LOGFILE("country %s\n", gsm_get_mcc(s->mcc))
+ LOGFILE("provider %s\n", gsm_get_mnc(s->mcc, s->mnc))
+ LOGFILE("arfcn %d\n", s->arfcn);
+ //log_time();
+ //log_gps();
+ //LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ //if (s->si1)
+ // log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ //if (s->si2bis)
+ // log_frame("si2bis", s->si2b_msg);
+ //if (s->si2ter)
+ // log_frame("si2ter", s->si2t_msg);
+ //if (s->si3)
+ // log_frame("si3", s->si3_msg);
+ //if (s->si4)
+ // log_frame("si4", s->si4_msg);
+ //if (log_si.ta != 0xff)
+ // LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ //HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5c/802b0bfea7f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5c/802b0bfea7f2001019c79f38f40e52ba
new file mode 100644
index 0000000..20374e6
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5c/802b0bfea7f2001019c79f38f40e52ba
@@ -0,0 +1,60 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+ if bit == '1':
+ neighbour_arfcn.append(abs(index))
+ return neighbour_arfcn
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for station in self._base_station_list:
+ code += station.arfcn + r'; '
+ for neighbour in station.get_neighbour_arfcn():
+ code += station.arfcn + ' -> ' + str(neighbour) +
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5d/d0bbc63480f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5d/d0bbc63480f2001019c79f38f40e52ba
new file mode 100644
index 0000000..43460f1
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5d/d0bbc63480f2001019c79f38f40e52ba
@@ -0,0 +1,54 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.country + '(' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ #self.bs_tree_list_data =
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/60/406700eba6f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/60/406700eba6f2001019c79f38f40e52ba
new file mode 100644
index 0000000..11cd4a9
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/60/406700eba6f2001019c79f38f40e52ba
@@ -0,0 +1,55 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/61/e08194a57af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/61/e08194a57af2001019c79f38f40e52ba
new file mode 100644
index 0000000..2b58e74
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/61/e08194a57af2001019c79f38f40e52ba
@@ -0,0 +1,54 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found base station")
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/63/a0b698a879f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/63/a0b698a879f2001019c79f38f40e52ba
new file mode 100644
index 0000000..5b8fb2b
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/63/a0b698a879f2001019c79f38f40e52ba
@@ -0,0 +1,111 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get rx
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'rxlev\s(.\d+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'',line)
+ if match:
+ base_station.country = match.group(1)
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/65/304bccca95f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/65/304bccca95f2001019c79f38f40e52ba
new file mode 100644
index 0000000..3cebf6d
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/65/304bccca95f2001019c79f38f40e52ba
@@ -0,0 +1,37 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ already_in_list = False
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/66/d0bcdf7a7af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/66/d0bcdf7a7af2001019c79f38f40e52ba
new file mode 100644
index 0000000..a7c6377
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/66/d0bcdf7a7af2001019c79f38f40e52ba
@@ -0,0 +1,113 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ if self._firmThread:
+ self._firmThread.join(10)
+ if self._scanThread:
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.provider = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.arfcn = match.group(1)
+ #get rxlev
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'rxlev\s(.\d+)',line)
+ if match:
+ base_station.rxlev = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'si2\s(.+)',line)
+ if match:
+ base_station.neighbours = match.group(1).split(' ')
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/67/9046d1037ff2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/67/9046d1037ff2001019c79f38f40e52ba
new file mode 100644
index 0000000..d35a1ac
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/67/9046d1037ff2001019c79f38f40e52ba
@@ -0,0 +1,53 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found " + base_station_info.country + '(' + base_station_info.arfcn + ')')
+ #self.bs_tree_list_data =
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/67/d06f0dae70f2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/67/d06f0dae70f2001013089cecc8a626ff
new file mode 100644
index 0000000..35474fc
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/67/d06f0dae70f2001013089cecc8a626ff
@@ -0,0 +1,74 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ scanThread = FirmwareThread(self._base_station_found_callback, self._scan_thread_break)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/68/3059941eb8f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/68/3059941eb8f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..1a9c33c
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/68/3059941eb8f100101fc6d5dee7f902b6
@@ -0,0 +1,820 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[sysinfo]\n");
+ LOGFILE("arfcn %d\n", s->arfcn);
+ log_time();
+ log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/68/903de4d6a6f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/68/903de4d6a6f2001019c79f38f40e52ba
new file mode 100644
index 0000000..2869433
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/68/903de4d6a6f2001019c79f38f40e52ba
@@ -0,0 +1,55 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/6c/603ece379ff2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/6c/603ece379ff2001019c79f38f40e52ba
new file mode 100644
index 0000000..13c2c52
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/6c/603ece379ff2001019c79f38f40e52ba
@@ -0,0 +1,115 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+ self._firmThread = None
+ self._scanThread = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ if self._firmThread:
+ self._firmThread.join(10)
+ if self._scanThread:
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ #print line
+ #sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.provider = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.arfcn = match.group(1)
+ #get rxlev
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'rxlev\s(.\d+)',line)
+ if match:
+ base_station.rxlev = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'si2\s(.+)',line)
+ if match:
+ base_station.neighbours = match.group(1).split(' ')
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/6c/c0fb5eec78f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/6c/c0fb5eec78f2001019c79f38f40e52ba
new file mode 100644
index 0000000..0202bdd
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/6c/c0fb5eec78f2001019c79f38f40e52ba
@@ -0,0 +1,100 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search('',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ #get rx
+ line = line = scan_process.stdout.readline()
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/70/b00ea6a778f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/70/b00ea6a778f2001019c79f38f40e52ba
new file mode 100644
index 0000000..5dba40f
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/70/b00ea6a778f2001019c79f38f40e52ba
@@ -0,0 +1,98 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search('',line)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ #get rx
+ line = line = scan_process.stdout.readline()
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/71/401a8118baf100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/71/401a8118baf100101fc6d5dee7f902b6
new file mode 100644
index 0000000..27f219c
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/71/401a8118baf100101fc6d5dee7f902b6
@@ -0,0 +1,824 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ LOGFILE("provider: %s", gsm_get_mcc(s->mcc))
+ LOGFILE("country: %s", gsm_get_mnc(s->mcc, s->mnc))
+ LOGFILE("arfcn %d\n", s->arfcn);
+ //log_time();
+ //log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ //HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/71/605b64bd93f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/71/605b64bd93f2001019c79f38f40e52ba
new file mode 100644
index 0000000..ad66245
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/71/605b64bd93f2001019c79f38f40e52ba
@@ -0,0 +1,33 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+
+ def get_list_model(self):
+ return [self.provider, self.arfcn, self.rxlev, datetime.datetime.now().strftime('%I:%M %p')]
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def get_list_store(self):
+ store = gtk.ListStore(str,str,str,str)
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ return store
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/73/202199087af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/73/202199087af2001019c79f38f40e52ba
new file mode 100644
index 0000000..5cad65f
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/73/202199087af2001019c79f38f40e52ba
@@ -0,0 +1,111 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.provider = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.arfcn = match.group(1)
+ #get rx
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'rxlev\s(.\d+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'si2\s(.+)',line)
+ if match:
+ base_station.neighbours = match.group(1).split(' ')
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/75/008ba64293f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/75/008ba64293f2001019c79f38f40e52ba
new file mode 100644
index 0000000..d5cebd7
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/75/008ba64293f2001019c79f38f40e52ba
@@ -0,0 +1,57 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ store = gtk.ListStore(str,str,str,str)
+ store.append('a','b','c','d')
+ self.bs_tree_list_data = store
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.country + '(' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ self.bs_tree_list_data = self._base_station_list.get_list_store()
+ #TODO rebuild diagram
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/77/f048b41e97f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/77/f048b41e97f2001019c79f38f40e52ba
new file mode 100644
index 0000000..ded6293
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/77/f048b41e97f2001019c79f38f40e52ba
@@ -0,0 +1,41 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'graph bsnetwork{\n'
+ postamble = r'}'
+
+
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/78/20ff0f466ff2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/78/20ff0f466ff2001013089cecc8a626ff
new file mode 100644
index 0000000..6b4e17a
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/78/20ff0f466ff2001013089cecc8a626ff
@@ -0,0 +1,71 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._test_thread = None
+
+ def start_scanning (self):
+ self._scan_thread_break = False
+ threading.Thread(target= self._do_scan).start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/79/80a9be6276f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/79/80a9be6276f2001019c79f38f40e52ba
new file mode 100644
index 0000000..41fc0e2
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/79/80a9be6276f2001019c79f38f40e52ba
@@ -0,0 +1,54 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+
+
+ def _found_base_station_callback(self):
+ self._gui.log_line("found base station")
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/7b/90342ca6a7f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/7b/90342ca6a7f2001019c79f38f40e52ba
new file mode 100644
index 0000000..2c3935c
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/7b/90342ca6a7f2001019c79f38f40e52ba
@@ -0,0 +1,58 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+ if bit == '1':
+ neighbour_arfcn.append(abs(index))
+ return neighbour_arfcn
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/7e/60ef6ad577f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/7e/60ef6ad577f2001019c79f38f40e52ba
new file mode 100644
index 0000000..8f5aac3
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/7e/60ef6ad577f2001019c79f38f40e52ba
@@ -0,0 +1,82 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ self._base_station_found_callback()
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/84/c0614a7670f2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/84/c0614a7670f2001013089cecc8a626ff
new file mode 100644
index 0000000..8067855
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/84/c0614a7670f2001013089cecc8a626ff
@@ -0,0 +1,74 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ scanThread = FirmwareThread(self._base_station_found_callback, self._scan_thread_break)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/85/e011f3a7a7f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/85/e011f3a7a7f2001019c79f38f40e52ba
new file mode 100644
index 0000000..76bf08f
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/85/e011f3a7a7f2001019c79f38f40e52ba
@@ -0,0 +1,59 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+ if bit == '1':
+ neighbour_arfcn.append(abs(index))
+ return neighbour_arfcn
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ for neighbour in item.get_neighbour_arfcn()
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/86/609cf02c70f2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/86/609cf02c70f2001013089cecc8a626ff
new file mode 100644
index 0000000..7387de2
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/86/609cf02c70f2001013089cecc8a626ff
@@ -0,0 +1,72 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ scanThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/89/20c7b2636ef2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/89/20c7b2636ef2001013089cecc8a626ff
new file mode 100644
index 0000000..af44ef9
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/89/20c7b2636ef2001013089cecc8a626ff
@@ -0,0 +1,50 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def _found_base_station_callback(self):
+ self._gui.log_line("found base station")
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8a/00229f17a7f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8a/00229f17a7f2001019c79f38f40e52ba
new file mode 100644
index 0000000..2c3935c
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8a/00229f17a7f2001019c79f38f40e52ba
@@ -0,0 +1,58 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+ if bit == '1':
+ neighbour_arfcn.append(abs(index))
+ return neighbour_arfcn
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8a/50abaff980f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8a/50abaff980f2001019c79f38f40e52ba
new file mode 100644
index 0000000..bcc6567
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8a/50abaff980f2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime('%I:%M %p) + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_destroy(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8c/0007523691f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8c/0007523691f2001019c79f38f40e52ba
new file mode 100644
index 0000000..880b9fc
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8c/0007523691f2001019c79f38f40e52ba
@@ -0,0 +1,29 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+
+ def get_list_model():
+ return [self.provider, self.arfcn, self.rxlev, datetime.datetime.now().strftime('%I:%M %p')]
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def get_list_store(self):
+ store = gtk.ListStore(str,str,str,str)
+ for item in self._base_station_list
+ return store
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9/00ec0b5d76f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9/00ec0b5d76f2001019c79f38f40e52ba
new file mode 100644
index 0000000..9b7cff9
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9/00ec0b5d76f2001019c79f38f40e52ba
@@ -0,0 +1,51 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def _found_base_station_callback(self):
+ self._gui.log_line("found base station")
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9/30082eba96f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9/30082eba96f2001019c79f38f40e52ba
new file mode 100644
index 0000000..fd3b3ff
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9/30082eba96f2001019c79f38f40e52ba
@@ -0,0 +1,41 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'''graph bsnetwork{\n'''
+ postamble = r'''}'''
+
+
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/90/c051e5f079f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/90/c051e5f079f2001019c79f38f40e52ba
new file mode 100644
index 0000000..c330b9f
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/90/c051e5f079f2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_destrpy(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/91/f0e9754a72f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/91/f0e9754a72f2001019c79f38f40e52ba
new file mode 100644
index 0000000..bdcfe75
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/91/f0e9754a72f2001019c79f38f40e52ba
@@ -0,0 +1,824 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ //LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ // arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ // gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ LOGFILE("provider %s\n", gsm_get_mcc(s->mcc))
+ LOGFILE("country %s\n", gsm_get_mnc(s->mcc, s->mnc))
+ LOGFILE("arfcn %d\n", s->arfcn);
+ //log_time();
+ //log_gps();
+ //LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ //if (s->si1)
+ // log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ //if (s->si2bis)
+ // log_frame("si2bis", s->si2b_msg);
+ //if (s->si2ter)
+ // log_frame("si2ter", s->si2t_msg);
+ //if (s->si3)
+ // log_frame("si3", s->si3_msg);
+ //if (s->si4)
+ // log_frame("si4", s->si4_msg);
+ //if (log_si.ta != 0xff)
+ // LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ //HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/94/00dbdc9893f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/94/00dbdc9893f2001019c79f38f40e52ba
new file mode 100644
index 0000000..c8a0e0d
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/94/00dbdc9893f2001019c79f38f40e52ba
@@ -0,0 +1,60 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ store = gtk.ListStore(str,str,str,str)
+ store.append(('a','b','c','d'))
+ self.bs_tree_list_data = store
+ self._gui = PyCatcherGUI(self)
+ store2 = gtk.ListStore(str,str,str,str)
+ store2.append(('aa','ba','cc','dd'))
+ self.bs_tree_list_data = store2
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.country + '(' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ self.bs_tree_list_data = self._base_station_list.get_list_store()
+ #TODO rebuild diagram
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/96/70f084bf9ef2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/96/70f084bf9ef2001019c79f38f40e52ba
new file mode 100644
index 0000000..6a3816a
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/96/70f084bf9ef2001019c79f38f40e52ba
@@ -0,0 +1,45 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #5-19
+ neighbours = self.system_info_t2[6-21]
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/97/f035184f7ff2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/97/f035184f7ff2001019c79f38f40e52ba
new file mode 100644
index 0000000..35efe72
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/97/f035184f7ff2001019c79f38f40e52ba
@@ -0,0 +1,113 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ if self._firmThread:
+ self._firmThread.join(10)
+ if self._scanThread:
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ #print line
+ #sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.provider = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.arfcn = match.group(1)
+ #get rxlev
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'rxlev\s(.\d+)',line)
+ if match:
+ base_station.rxlev = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'si2\s(.+)',line)
+ if match:
+ base_station.neighbours = match.group(1).split(' ')
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/98/a029fc1b9ef2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/98/a029fc1b9ef2001019c79f38f40e52ba
new file mode 100644
index 0000000..d13bba4
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/98/a029fc1b9ef2001019c79f38f40e52ba
@@ -0,0 +1,43 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9a/708a4064b9f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9a/708a4064b9f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..cc96074
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9a/708a4064b9f100101fc6d5dee7f902b6
@@ -0,0 +1,823 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ //LOGFILE("provider: %s", )
+ LOGFILE("arfcn %d\n", s->arfcn);
+ log_time();
+ log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9b/c076e09f78f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9b/c076e09f78f2001019c79f38f40e52ba
new file mode 100644
index 0000000..03da125
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9b/c076e09f78f2001019c79f38f40e52ba
@@ -0,0 +1,97 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+
+ #get country
+ line = line = scan_process.stdout.readline()
+ #get provider
+ line = line = scan_process.stdout.readline()
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ #get rx
+ line = line = scan_process.stdout.readline()
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9c/700748b079f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9c/700748b079f2001019c79f38f40e52ba
new file mode 100644
index 0000000..f3dad30
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9c/700748b079f2001019c79f38f40e52ba
@@ -0,0 +1,111 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get rx
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'rxlev\s(.\d+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'si2\s(.+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9e/60047c4d7af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9e/60047c4d7af2001019c79f38f40e52ba
new file mode 100644
index 0000000..313faba
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9e/60047c4d7af2001019c79f38f40e52ba
@@ -0,0 +1,113 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ if self._firmThread:
+ self._firmThread.join(10)
+ if self._scanThread:
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.provider = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.arfcn = match.group(1)
+ #get rx
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'rxlev\s(.\d+)',line)
+ if match:
+ base_station.rxlev = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'si2\s(.+)',line)
+ if match:
+ base_station.neighbours = match.group(1).split(' ')
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a/f042c6c4a8f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a/f042c6c4a8f2001019c79f38f40e52ba
new file mode 100644
index 0000000..0155a44
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a/f042c6c4a8f2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_destroy(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a0/d01cd48b7ef2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a0/d01cd48b7ef2001019c79f38f40e52ba
new file mode 100644
index 0000000..013246f
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a0/d01cd48b7ef2001019c79f38f40e52ba
@@ -0,0 +1,53 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found " + base_station_info.country + '(' + base_station_info.arfcn + ')')
+ self.bs_tree_list_data =
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a2/608cf8de93f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a2/608cf8de93f2001019c79f38f40e52ba
new file mode 100644
index 0000000..ed872e8
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a2/608cf8de93f2001019c79f38f40e52ba
@@ -0,0 +1,33 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+
+ def get_list_model(self):
+ return [self.provider, self.arfcn, self.rxlev, datetime.datetime.now().strftime('%I:%M %p')]
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def refill_store(self, store):
+ store = gtk.ListStore(str,str,str,str)
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ return store
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a3/2097d8f194f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a3/2097d8f194f2001019c79f38f40e52ba
new file mode 100644
index 0000000..1c32c2c
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a3/2097d8f194f2001019c79f38f40e52ba
@@ -0,0 +1,32 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, datetime.datetime.now().strftime('%T'))
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a4/d04323d974f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a4/d04323d974f2001019c79f38f40e52ba
new file mode 100644
index 0000000..71c93a7
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a4/d04323d974f2001019c79f38f40e52ba
@@ -0,0 +1,80 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if line.strip() == '[SysInfo]':
+ self._base_station_found_callback()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a5/9036ba2395f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a5/9036ba2395f2001019c79f38f40e52ba
new file mode 100644
index 0000000..776eb14
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a5/9036ba2395f2001019c79f38f40e52ba
@@ -0,0 +1,33 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a7/704048c09ef2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a7/704048c09ef2001019c79f38f40e52ba
new file mode 100644
index 0000000..0b74597
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a7/704048c09ef2001019c79f38f40e52ba
@@ -0,0 +1,46 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #5-19
+ neighbours = self.system_info_t2[6-21]
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+ base_station.get_neighbour_arfcn
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a7/e0f402ec7ff2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a7/e0f402ec7ff2001019c79f38f40e52ba
new file mode 100644
index 0000000..dceb4fb
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a7/e0f402ec7ff2001019c79f38f40e52ba
@@ -0,0 +1,54 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.country + '(' + base_station_info.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ #self.bs_tree_list_data =
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ab/90e8e32198f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ab/90e8e32198f2001019c79f38f40e52ba
new file mode 100644
index 0000000..4e3aa65
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ab/90e8e32198f2001019c79f38f40e52ba
@@ -0,0 +1,43 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'graph bsnetwork{\n'
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'\n'
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ad/f034ed3493f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ad/f034ed3493f2001019c79f38f40e52ba
new file mode 100644
index 0000000..de99ce4
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ad/f034ed3493f2001019c79f38f40e52ba
@@ -0,0 +1,55 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.country + '(' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ self.bs_tree_list_data = self._base_station_list.get_list_store()
+ #TODO rebuild diagram
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/70572ccb93f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/70572ccb93f2001019c79f38f40e52ba
new file mode 100644
index 0000000..7d215d8
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/70572ccb93f2001019c79f38f40e52ba
@@ -0,0 +1,33 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+
+ def get_list_model(self):
+ return [self.provider, self.arfcn, self.rxlev, datetime.datetime.now().strftime('%I:%M %p')]
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def fill_store(self):
+ store = gtk.ListStore(str,str,str,str)
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ return store
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/a01ff9a797f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/a01ff9a797f2001019c79f38f40e52ba
new file mode 100644
index 0000000..d22ffbc
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/a01ff9a797f2001019c79f38f40e52ba
@@ -0,0 +1,57 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ store = gtk.ListStore(str,str,str,str)
+ store.append(('-','-','-','-'))
+ self.bs_tree_list_data = store
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.provider + ' (' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ self._base_station_list.refill_store(self.bs_tree_list_data)
+
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/d016566876f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/d016566876f2001019c79f38f40e52ba
new file mode 100644
index 0000000..6157a7d
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/d016566876f2001019c79f38f40e52ba
@@ -0,0 +1,134 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": ,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_close(self, widget):
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b/5074d5f6a3f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b/5074d5f6a3f2001019c79f38f40e52ba
new file mode 100644
index 0000000..b9e0683
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b/5074d5f6a3f2001019c79f38f40e52ba
@@ -0,0 +1,47 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[4:20]
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+ base_station.get_neighbour_arfcn()
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b/d010489ba2f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b/d010489ba2f2001019c79f38f40e52ba
new file mode 100644
index 0000000..948a1a3
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b/d010489ba2f2001019c79f38f40e52ba
@@ -0,0 +1,46 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #5-19
+ neighbours = self.system_info_t2[4:20]
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+ base_station.get_neighbour_arfcn()
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b2/304fe0d6a4f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b2/304fe0d6a4f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..27290be
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b2/304fe0d6a4f100101fc6d5dee7f902b6
@@ -0,0 +1,195 @@
+/* "Application" code of the layer2/3 stack */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <signal.h>
+#include <stdlib.h>
+#include <time.h>
+#include <getopt.h>
+
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/l23_app.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+
+#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
+
+#include <l1ctl_proto.h>
+
+extern struct log_target *stderr_target;
+extern void *l23_ctx;
+
+char *logname = "/var/log/osmocom.log";
+int RACH_MAX = 2;
+
+int _scan_work(struct osmocom_ms *ms)
+{
+ return 0;
+}
+
+int _scan_exit(struct osmocom_ms *ms)
+{
+ /* in case there is a lockup during exit */
+ signal(SIGINT, SIG_DFL);
+ signal(SIGHUP, SIG_DFL);
+ signal(SIGTERM, SIG_DFL);
+ signal(SIGPIPE, SIG_DFL);
+
+ scan_exit();
+
+ return 0;
+}
+
+int l23_app_init(struct osmocom_ms *ms)
+{
+ int rc;
+
+ srand(time(NULL));
+
+// log_parse_category_mask(stderr_target, "DL1C:DRSL:DRR:DGPS:DSUM");
+ log_parse_category_mask(stderr_target, "DSUM");
+ log_set_log_level(stderr_target, LOGL_INFO);
+
+ l23_app_work = _scan_work;
+ l23_app_exit = _scan_exit;
+
+ rc = scan_init(ms);
+ if (rc)
+ return rc;
+
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ printf("Mobile initialized, please start phone now!\n");
+ return 0;
+}
+
+static int l23_cfg_supported()
+{
+ return L23_OPT_TAP | L23_OPT_DBG;
+}
+
+static int l23_getopt_options(struct option **options)
+{
+ static struct option opts [] = {
+ {"logfile", 1, 0, 'l'},
+ {"rach", 1, 0, 'r'},
+ {"no-rach", 1, 0, 'n'},
+#ifdef _HAVE_GPSD
+ {"gpsd-host", 1, 0, 'g'},
+ {"gpsd-port", 1, 0, 'p'},
+#endif
+ {"gps", 1, 0, 'g'},
+ {"baud", 1, 0, 'b'}
+ };
+
+ *options = opts;
+ return ARRAY_SIZE(opts);
+}
+
+static int l23_cfg_print_help()
+{
+ printf("\nApplication specific\n");
+ printf(" -l --logfile LOGFILE Logfile for the cell log.\n");
+ printf(" -r --rach RACH Nr. of RACH bursts to send.\n");
+ printf(" -n --no-rach Send no rach bursts.\n");
+ printf(" -g --gpsd-host HOST 127.0.0.1. gpsd host.\n");
+ printf(" -p --port PORT 2947. gpsd port\n");
+ printf(" -f --gps DEVICE /dev/ttyACM0. GPS serial device.\n");
+ printf(" -b --baud BAUDRAT The baud rate of the GPS device\n");
+
+ return 0;
+}
+
+static int l23_cfg_handle(int c, const char *optarg)
+{
+ switch (c) {
+ case 'l':
+ logname = talloc_strdup(l23_ctx, optarg);
+ break;
+ case 'r':
+ RACH_MAX = atoi(optarg);
+ break;
+ case 'n':
+ RACH_MAX = 0;
+ break;
+ case 'g':
+#ifdef _HAVE_GPSD
+ snprintf(g.gpsd_host, ARRAY_SIZE(g.gpsd_host), "%s", optarg);
+ /* force string terminator */
+ g.gpsd_host[ARRAY_SIZE(g.gpsd_host) - 1] = '\0';
+ if (g.gps_type != GPS_TYPE_UNDEF)
+ goto cmd_line_error;
+ g.gps_type = GPS_TYPE_GPSD;
+ LOGP(DGPS, LOGL_INFO, "Using gpsd host %s\n", g.gpsd_host);
+#else
+ printf("Gpsd support not compiled.\n");
+ exit(1);
+#endif
+ break;
+ case 'p':
+#ifdef _HAVE_GPSD
+ snprintf(g.gpsd_port, ARRAY_SIZE(g.gpsd_port), "%s", optarg);
+ /* force string terminator */
+ g.gpsd_port[ARRAY_SIZE(g.gpsd_port) - 1] = '\0';
+ g.gps_type = GPS_TYPE_GPSD;
+ LOGP(DGPS, LOGL_INFO, "Using gpsd port %s\n", g.gpsd_port);
+#else
+ printf("Gpsd support not compiled.\n");
+ exit(1);
+#endif
+ break;
+ case 'f':
+ snprintf(g.device, ARRAY_SIZE(g.device), "%s", optarg);
+ /* force string terminator */
+ g.device[ARRAY_SIZE(g.device) - 1] = '\0';
+ if (g.gps_type != GPS_TYPE_UNDEF)
+ goto cmd_line_error;
+ g.gps_type = GPS_TYPE_SERIAL;
+ LOGP(DGPS, LOGL_INFO, "Using GPS serial device %s\n", g.device);
+ break;
+ case 'b':
+ g.baud = atoi(optarg);
+ g.gps_type = GPS_TYPE_SERIAL;
+ LOGP(DGPS, LOGL_INFO, "Setting GPS baudrate to %u\n", g.baud);
+ break;
+ }
+ return 0;
+
+cmd_line_error:
+ printf("\nYou can't specify both gpsd and serial gps!!\n\n");
+ exit(1);
+}
+
+static struct l23_app_info info = {
+ .copyright = "Copyright (C) 2010 Andreas Eversberg\n",
+ .getopt_string = "g:p:l:r:nf:b:",
+ .cfg_supported = l23_cfg_supported,
+ .cfg_getopt_opt = l23_getopt_options,
+ .cfg_handle_opt = l23_cfg_handle,
+ .cfg_print_help = l23_cfg_print_help,
+};
+
+struct l23_app_info *l23_app_info()
+{
+ return &info;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b4/1076a1137cf2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b4/1076a1137cf2001019c79f38f40e52ba
new file mode 100644
index 0000000..695290d
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b4/1076a1137cf2001019c79f38f40e52ba
@@ -0,0 +1,54 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found " + base_station_info.country + '(' + base_station_info.arfcn + ')')
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b5/108e7d6a9ff2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b5/108e7d6a9ff2001019c79f38f40e52ba
new file mode 100644
index 0000000..4476f02
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b5/108e7d6a9ff2001019c79f38f40e52ba
@@ -0,0 +1,46 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #5-19
+ neighbours = self.system_info_t2[6:21]
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+ base_station.get_neighbour_arfcn()
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b5/40650fe374f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b5/40650fe374f2001019c79f38f40e52ba
new file mode 100644
index 0000000..64167f6
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b5/40650fe374f2001019c79f38f40e52ba
@@ -0,0 +1,81 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if line.strip() == '[SysInfo]':
+ self._base_station_found_callback()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b8/e017b3e67ff2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b8/e017b3e67ff2001019c79f38f40e52ba
new file mode 100644
index 0000000..3290a2b
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b8/e017b3e67ff2001019c79f38f40e52ba
@@ -0,0 +1,53 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found " + base_station_info.country + '(' + base_station_info.arfcn + ')')
+ #self.bs_tree_list_data =
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b9/004bc24280f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b9/004bc24280f2001019c79f38f40e52ba
new file mode 100644
index 0000000..4af8b45
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b9/004bc24280f2001019c79f38f40e52ba
@@ -0,0 +1,54 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.country + '(' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ self.bs_tree_list_data = self._base_station_list.get_list_store()
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ba/409db4d5a0f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ba/409db4d5a0f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..0b59f38
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ba/409db4d5a0f100101fc6d5dee7f902b6
@@ -0,0 +1,13 @@
+INCLUDES = $(all_includes) -I$(top_srcdir)/include
+AM_CFLAGS = -Wall $(LIBOSMOCORE_CFLAGS) $(LIBOSMOGSM_CFLAGS)
+LDADD = ../common/liblayer23.a $(LIBOSMOCORE_LIBS) $(LIBOSMOGSM_LIBS) $(LIBOSMOCODEC_LIBS)
+
+bin_PROGRAMS = bcch_scan ccch_scan echo_test cell_log cbch_sniff
+
+bcch_scan_SOURCES = ../common/main.c app_bcch_scan.c bcch_scan.c
+ccch_scan_SOURCES = ../common/main.c app_ccch_scan.c rslms.c
+echo_test_SOURCES = ../common/main.c app_echo_test.c
+cell_log_LDADD = $(LDADD) -lm
+cell_log_SOURCES = ../common/main.c app_cell_log.c cell_log.c \
+ ../../../gsmmap/geo.c
+cbch_sniff_SOURCES = ../common/main.c app_cbch_sniff.c
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ba/b06e730f7af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ba/b06e730f7af2001019c79f38f40e52ba
new file mode 100644
index 0000000..7de39d5
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ba/b06e730f7af2001019c79f38f40e52ba
@@ -0,0 +1,112 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ if self._firmThread:
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.provider = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.arfcn = match.group(1)
+ #get rx
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'rxlev\s(.\d+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'si2\s(.+)',line)
+ if match:
+ base_station.neighbours = match.group(1).split(' ')
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/bd/803ca2d3a7f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/bd/803ca2d3a7f2001019c79f38f40e52ba
new file mode 100644
index 0000000..056ba58
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/bd/803ca2d3a7f2001019c79f38f40e52ba
@@ -0,0 +1,60 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+ if bit == '1':
+ neighbour_arfcn.append(abs(index))
+ return neighbour_arfcn
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ for neighbour in item.get_neighbour_arfcn():
+
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/bf/9074167f6df2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/bf/9074167f6df2001013089cecc8a626ff
new file mode 100644
index 0000000..6b4e17a
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/bf/9074167f6df2001013089cecc8a626ff
@@ -0,0 +1,71 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._test_thread = None
+
+ def start_scanning (self):
+ self._scan_thread_break = False
+ threading.Thread(target= self._do_scan).start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c/50d1292c6df2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c/50d1292c6df2001013089cecc8a626ff
new file mode 100644
index 0000000..157c568
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c/50d1292c6df2001013089cecc8a626ff
@@ -0,0 +1,71 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._test_thread = None
+
+ def start_scanning (self):
+ self._scan_thread_break = False
+ threading.Thread(target= self._do_scan).start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ testThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ testThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c0/808dbdf172f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c0/808dbdf172f2001019c79f38f40e52ba
new file mode 100644
index 0000000..f6db5b5
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c0/808dbdf172f2001019c79f38f40e52ba
@@ -0,0 +1,76 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if line.strip() == '[SysInfo]':
+ self._base_station_found_callback()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c0/90c0377bb9f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c0/90c0377bb9f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..fdf53e9
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c0/90c0377bb9f100101fc6d5dee7f902b6
@@ -0,0 +1,824 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ //LOGFILE("provider: %s", )
+ //LOGFILE("country: %s", )
+ LOGFILE("arfcn %d\n", s->arfcn);
+ log_time();
+ log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c5/40a1b819a9f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c5/40a1b819a9f2001019c79f38f40e52ba
new file mode 100644
index 0000000..10dd70f
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c5/40a1b819a9f2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_destroy(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ #self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c7/8043f0f2a6f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c7/8043f0f2a6f2001019c79f38f40e52ba
new file mode 100644
index 0000000..446700d
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c7/8043f0f2a6f2001019c79f38f40e52ba
@@ -0,0 +1,57 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+ if bit == '1':
+ neighbour_arfcn.append(abs(index))
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c8/d009dc3b70f2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c8/d009dc3b70f2001013089cecc8a626ff
new file mode 100644
index 0000000..48a93c2
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c8/d009dc3b70f2001013089cecc8a626ff
@@ -0,0 +1,73 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ scanThread = FirmwareThread(self._base_station_found_callback)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ce/a04fca6b6ef2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ce/a04fca6b6ef2001013089cecc8a626ff
new file mode 100644
index 0000000..54e5e40
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ce/a04fca6b6ef2001013089cecc8a626ff
@@ -0,0 +1,51 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning()
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def _found_base_station_callback(self):
+ self._gui.log_line("found base station")
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d0/70b06cf0a7f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d0/70b06cf0a7f2001019c79f38f40e52ba
new file mode 100644
index 0000000..67f7f65
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d0/70b06cf0a7f2001019c79f38f40e52ba
@@ -0,0 +1,60 @@
+import datetime
+import gtk
+import math
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #TODO: examine plmn permitted byte
+ #TODO: examine emergency call capability
+ neighbours = self.system_info_t2[3:19]
+ bin_representation = ''
+ neighbour_arfcn = []
+
+ for value in neighbours:
+ bin_representation += str(bin(int(value, 16))[2:].zfill(8))
+
+ for x in xrange(1,125):
+ index = 0-x
+ bit = bin_representation[index]
+ if bit == '1':
+ neighbour_arfcn.append(abs(index))
+ return neighbour_arfcn
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for station in self._base_station_list:
+ code += station.arfcn + r'; '
+ for neighbour in station.get_neighbour_arfcn():
+ code += station.arfcn
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d1/70d3bbca74f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d1/70d3bbca74f2001019c79f38f40e52ba
new file mode 100644
index 0000000..90c5fbf
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d1/70d3bbca74f2001019c79f38f40e52ba
@@ -0,0 +1,52 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def _found_base_station_callback(self):
+ self._gui.log_line("found base station")
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d3/20d9c4909af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d3/20d9c4909af2001019c79f38f40e52ba
new file mode 100644
index 0000000..5894499
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d3/20d9c4909af2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_destroy(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ # self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d3/e0c53cc672f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d3/e0c53cc672f2001019c79f38f40e52ba
new file mode 100644
index 0000000..8c8e835
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d3/e0c53cc672f2001019c79f38f40e52ba
@@ -0,0 +1,74 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d4/90921cb57cf2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d4/90921cb57cf2001019c79f38f40e52ba
new file mode 100644
index 0000000..cce9ff2
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d4/90921cb57cf2001019c79f38f40e52ba
@@ -0,0 +1,53 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found " + base_station_info.country + '(' + base_station_info.arfcn + ')')
+ self.bs_tree_list_data =
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d4/f035b3eb79f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d4/f035b3eb79f2001019c79f38f40e52ba
new file mode 100644
index 0000000..f4b03ae
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d4/f035b3eb79f2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_close,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_close(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d5/50de5fb596f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d5/50de5fb596f2001019c79f38f40e52ba
new file mode 100644
index 0000000..12a14fd
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d5/50de5fb596f2001019c79f38f40e52ba
@@ -0,0 +1,39 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'''graph bsnetwork{'''
+ postamble = r'''}'''
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/db/105e2a299bf2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/db/105e2a299bf2001019c79f38f40e52ba
new file mode 100644
index 0000000..227c3b8
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/db/105e2a299bf2001019c79f38f40e52ba
@@ -0,0 +1,136 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_destroy(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ #self._dot_widget.zoom_to_fit()
+ pass
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/db/206a23659af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/db/206a23659af2001019c79f38f40e52ba
new file mode 100644
index 0000000..7aa34d6
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/db/206a23659af2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_destroy(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/dd/104bf38092f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/dd/104bf38092f2001019c79f38f40e52ba
new file mode 100644
index 0000000..300e840
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/dd/104bf38092f2001019c79f38f40e52ba
@@ -0,0 +1,30 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+
+ def get_list_model(self):
+ return [self.provider, self.arfcn, self.rxlev, datetime.datetime.now().strftime('%I:%M %p')]
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def get_list_store(self):
+ store = gtk.ListStore(str,str,str,str)
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ return store
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/de/a05b390195f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/de/a05b390195f2001019c79f38f40e52ba
new file mode 100644
index 0000000..c080efe
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/de/a05b390195f2001019c79f38f40e52ba
@@ -0,0 +1,33 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.found = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.found)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e1/b038af7f9af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e1/b038af7f9af2001019c79f38f40e52ba
new file mode 100644
index 0000000..5218ef2
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e1/b038af7f9af2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_destroy(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ #self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e2/600de8ac96f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e2/600de8ac96f2001019c79f38f40e52ba
new file mode 100644
index 0000000..eaaf495
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e2/600de8ac96f2001019c79f38f40e52ba
@@ -0,0 +1,38 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e7/8045c3c879f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e7/8045c3c879f2001019c79f38f40e52ba
new file mode 100644
index 0000000..a1ea642
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e7/8045c3c879f2001019c79f38f40e52ba
@@ -0,0 +1,111 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'country\s(\w+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get provider
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'provider\s(.+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'arfcn\s(\d+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get rx
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'rxlev\s(.\d+)',line)
+ if match:
+ base_station.country = match.group(1)
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ match = re.search(r'si2\s(.+)',line)
+ if match:
+ base_station.country = match.group(1).split(' ')
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ea/00ee7f5995f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ea/00ee7f5995f2001019c79f38f40e52ba
new file mode 100644
index 0000000..171bfc9
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ea/00ee7f5995f2001019c79f38f40e52ba
@@ -0,0 +1,36 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ pass
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ already_in_list = False
+ for item in self._base_station_list:
+ if item.arfcn ==
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ec/809acae2b8f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ec/809acae2b8f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..9e8e766
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ec/809acae2b8f100101fc6d5dee7f902b6
@@ -0,0 +1,821 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[sysinfo]\n");
+ LOGFILE("arfcn %d\n", s->arfcn);
+ log_time();
+ log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ed/e0b609eb76f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ed/e0b609eb76f2001019c79f38f40e52ba
new file mode 100644
index 0000000..2e29928
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ed/e0b609eb76f2001019c79f38f40e52ba
@@ -0,0 +1,54 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self):
+ self._gui.log_line("found base station")
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ef/30af64edb8f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ef/30af64edb8f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..1a6ac96
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ef/30af64edb8f100101fc6d5dee7f902b6
@@ -0,0 +1,822 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ LOGFILE("arfcn %d\n", s->arfcn);
+ log_time();
+ log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ef/b0389b949ef2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ef/b0389b949ef2001019c79f38f40e52ba
new file mode 100644
index 0000000..ee214a7
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ef/b0389b949ef2001019c79f38f40e52ba
@@ -0,0 +1,44 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.system_info_t2 = []
+ self.discovery_time = datetime.datetime.now().strftime('%T')
+
+ def get_list_model(self):
+ return (self.provider, self.arfcn, self.rxlev, self.discovery_time)
+
+ def get_neighbour_arfcn(self):
+ #5-19
+ neighbours = self.system_info_t2[6-21]
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ for item in self._base_station_list:
+ if item.arfcn == base_station.arfcn:
+ item.discovery_time = datetime.datetime.now().strftime('%T')
+ break
+ else:
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ preamble = r'digraph bsnetwork{ '
+ postamble = r'}'
+ code = ''
+ for item in self._base_station_list:
+ code += item.arfcn + r'; '
+ return preamble + code + postamble
+
+ def refill_store(self, store):
+ store.clear()
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f0/d0aaa69677f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f0/d0aaa69677f2001019c79f38f40e52ba
new file mode 100644
index 0000000..2b58e74
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f0/d0aaa69677f2001019c79f38f40e52ba
@@ -0,0 +1,54 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self.bs_tree_list_data = gtk.ListStore(str,str,str,str)
+
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+
+ self._gui.log_line("GUI initialized")
+
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station_info):
+ self._gui.log_line("found base station")
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f1/102a37d070f2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f1/102a37d070f2001013089cecc8a626ff
new file mode 100644
index 0000000..e291884
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f1/102a37d070f2001013089cecc8a626ff
@@ -0,0 +1,74 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f4/20a0f53292f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f4/20a0f53292f2001019c79f38f40e52ba
new file mode 100644
index 0000000..0048b66
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f4/20a0f53292f2001019c79f38f40e52ba
@@ -0,0 +1,30 @@
+import datetime
+import gtk
+
+class BaseStationInformation:
+ def __init__ (self):
+ self.country = 'Nowhere'
+ self.provider = 'Carry'
+ self.arfcn = 0
+ self.rxlev = 0
+ self.neighbours = []
+
+ def get_list_model():
+ return [self.provider, self.arfcn, self.rxlev, datetime.datetime.now().strftime('%I:%M %p')]
+
+class BaseStationInformationList:
+ def __init__(self):
+ self._base_station_list = []
+
+ def add_station(self, base_station):
+ self._base_station_list.append(base_station)
+
+ def get_dot_code(self):
+ pass
+
+ def get_list_store(self):
+ store = gtk.ListStore(str,str,str,str)
+ for item in self._base_station_list:
+ store.append(item.get_list_model())
+ return store
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f4/e0af8cb878f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f4/e0af8cb878f2001019c79f38f40e52ba
new file mode 100644
index 0000000..1a415f5
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f4/e0af8cb878f2001019c79f38f40e52ba
@@ -0,0 +1,99 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ self._scanThread = ScanThread(self._base_station_found_callback, self._scan_thread_break)
+ self._scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ self._firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+ def shutdown(self):
+ self._firmThread.join(10)
+ self._scanThread.join(10)
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if line.strip() == 'Finishing download phase':
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ print 'killing firmware'
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._base_station_found_callback = base_station_found_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ if re.search('SysInfo', line):
+ base_station = BaseStationInformation()
+
+ #get country
+ line = line = scan_process.stdout.readline()
+ match = re.search('',line)
+ if match:
+ #get provider
+ line = line = scan_process.stdout.readline()
+ #get arfcn
+ line = line = scan_process.stdout.readline()
+ #get rx
+ line = line = scan_process.stdout.readline()
+ #get neighbours
+ line = line = scan_process.stdout.readline()
+ #endinfo
+ line = line = scan_process.stdout.readline()
+
+ self._base_station_found_callback(base_station)
+ print 'killing scan'
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f6/9022b6e879f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f6/9022b6e879f2001019c79f38f40e52ba
new file mode 100644
index 0000000..7335a5b
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f6/9022b6e879f2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": ,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime("%A, %d. %B %Y %I:%M %p") + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_close(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f8/4038d97897f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f8/4038d97897f2001019c79f38f40e52ba
new file mode 100644
index 0000000..c6a7023
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f8/4038d97897f2001019c79f38f40e52ba
@@ -0,0 +1,57 @@
+import sys
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from driverConnector import DriverConnector
+from pyCatcherModel import BaseStationInformation, BaseStationInformationList
+from pyCatcherView import PyCatcherGUI
+
+class PyCatcherController:
+ def __init__(self):
+
+ self._base_station_list = BaseStationInformationList()
+ store = gtk.ListStore(str,str,str,str)
+ store.append(('-','-','-','-'))
+ self.bs_tree_list_data = store
+ self._gui = PyCatcherGUI(self)
+ self._driver_connector = DriverConnector()
+ self._gui.log_line("GUI initialized")
+ gtk.main()
+
+ def log_message(self, message):
+ self._gui.log_line(message)
+
+ def start_scan(self):
+ self._gui.log_line("start scan")
+ self._driver_connector.start_scanning(self._found_base_station_callback)
+
+ def stop_scan(self):
+ self._gui.log_line("stop scan")
+ self._driver_connector.stop_scanning()
+
+ def start_firmware(self):
+ self._gui.log_line("start firmware")
+ self._driver_connector.start_firmware(self._firmware_waiting_callback, self._firmware_done_callback)
+
+ def stop_firmware(self):
+ self._gui.log_line("stop firmware")
+ print 'stop firmwares'
+ self._driver_connector.stop_firmware()
+
+ def shutdown(self):
+ self._driver_connector.shutdown()
+
+ def _found_base_station_callback(self, base_station):
+ self._gui.log_line("found " + base_station.provider + ' (' + base_station.arfcn + ')')
+ self._base_station_list.add_station(base_station)
+ self._base_station_list.refill_store(self.bs_tree_list_data)
+ #TODO rebuild diagram
+
+ def _firmware_waiting_callback(self):
+ self._gui.log_line("firmware waiting for device")
+ self._gui.show_info('Switch on the phone now.', 'Firmware')
+
+ def _firmware_done_callback(self):
+ self._gui.log_line("firmware loaded, ready for scanning")
+ self._gui.show_info('Firmware load completed', 'Firmware')
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f8/b0bf377270f2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f8/b0bf377270f2001013089cecc8a626ff
new file mode 100644
index 0000000..7ab6681
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f8/b0bf377270f2001013089cecc8a626ff
@@ -0,0 +1,73 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ self._base_station_found_callback = base_station_found_callback
+ scanThread = FirmwareThread(self._base_station_found_callback, self._scan_thread_break)
+ scanThread.start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, base_station_found_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fa/309e53f36ff2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fa/309e53f36ff2001013089cecc8a626ff
new file mode 100644
index 0000000..208d410
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fa/309e53f36ff2001013089cecc8a626ff
@@ -0,0 +1,71 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._base_station_found_callback = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ threading.Thread(target= self._do_scan).start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fa/40273e0481f2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fa/40273e0481f2001019c79f38f40e52ba
new file mode 100644
index 0000000..d7a16ee
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fa/40273e0481f2001019c79f38f40e52ba
@@ -0,0 +1,135 @@
+import sys
+import locale
+import pygtk
+import gtk #@UnresolvedImport
+import gtk.glade #@UnresolvedImport
+from pyCatcherModel import BaseStationInformation
+from xdot import DotWidget
+import datetime
+import time
+
+class PyCatcherGUI:
+
+ def __init__(self, catcher_controller):
+ encoding = locale.getlocale()[1]
+ self._utf8conv = lambda x : unicode(x, encoding).encode('utf8')
+
+ self._scan_toggled_on = False
+ self._firmware_toggled_on = False
+
+ self._catcher_controller = catcher_controller
+
+ self._w_tree = gtk.glade.XML("../GUI/mainWindow.glade")
+
+ self._bs_tree_view = self._w_tree.get_widget("bs_table")
+ self._add_column("Provider", 0)
+ self._add_column("Frequency", 1)
+ self._add_column("Strength",2)
+ self._add_column("Last seen", 3)
+ self._bs_tree_view.set_model(self._catcher_controller.bs_tree_list_data)
+
+ self._horizontal_container = self._w_tree.get_widget("vbox4")
+ self._dot_widget = DotWidget()
+ self._horizontal_container.pack_start_defaults(self._dot_widget)
+ self._dot_widget.show()
+
+ self._main_window = self._w_tree.get_widget("main_window")
+ signals = {"on_main_window_destroy": self._on_main_window_destroy,
+ "on_scan_toggle_toggled": self._on_toggle_scan,
+ "on_firmware_toggle_toggled": self._on_toggle_firmware,
+ "on_graph_zoom_in_clicked": self._dot_widget.on_zoom_in,
+ "on_graph_zoom_out_clicked": self._dot_widget.on_zoom_out,
+ "on_graph_fit_clicked": self._dot_widget.on_zoom_fit,
+ "on_graph_zoom_default_clicked": self._dot_widget.on_zoom_100,
+ "on_save_project_clicked": self._on_save_project,
+ "on_open_file_clicked": self._on_open_file
+ }
+ self._w_tree.signal_autoconnect(signals)
+
+ log_view = self._w_tree.get_widget("log_output")
+ self._log_buffer = log_view.get_buffer()
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv("-- Log execution on " + datetime.datetime.now().strftime('%I:%M %p') + " --\n\n"))
+
+ self._main_window.show()
+
+
+ def _add_column(self, name, index):
+ column = gtk.TreeViewColumn(name, gtk.CellRendererText(), text=index)
+ column.set_resizable(True)
+ column.set_sort_column_id(index)
+ self._bs_tree_view.append_column(column)
+
+ def _on_main_window_destroy(self, widget):
+ self._catcher_controller.shutdown()
+ gtk.main_quit()
+
+ def _on_toggle_scan(self, widget):
+ if(not self._scan_toggled_on):
+ self._catcher_controller.start_scan()
+ self._scan_toggled_on = True
+ else:
+ self._catcher_controller.stop_scan()
+ self._scan_toggled_on = False
+
+ def _on_toggle_firmware(self, widget):
+ if(not self._firmware_toggled_on):
+ self._catcher_controller.start_firmware()
+ self._firmware_toggled_on = True
+ else:
+ self._catcher_controller.stop_firmware()
+ self._firmware_toggled_on = False
+
+ def _on_open_file(self, widget):
+ chooser = gtk.FileChooserDialog(title="Open dot File",
+ action=gtk.FILE_CHOOSER_ACTION_OPEN,
+ buttons=(gtk.STOCK_CANCEL,
+ gtk.RESPONSE_CANCEL,
+ gtk.STOCK_OPEN,
+ gtk.RESPONSE_OK))
+ chooser.set_default_response(gtk.RESPONSE_OK)
+ filter = gtk.FileFilter()
+ filter.set_name("Graphviz dot files")
+ filter.add_pattern("*.dot")
+ chooser.add_filter(filter)
+ filter = gtk.FileFilter()
+ filter.set_name("All files")
+ filter.add_pattern("*")
+ chooser.add_filter(filter)
+ if chooser.run() == gtk.RESPONSE_OK:
+ filename = chooser.get_filename()
+ chooser.destroy()
+ self.load_dot_from_file(filename)
+ else:
+ chooser.destroy()
+
+ def load_dot_from_file(self, filename):
+ try:
+ fp = file(filename, 'rt')
+ self.load_dot(fp.read(), filename)
+ fp.close()
+ except IOError, ex:
+ self.show_info(ex)
+
+ def load_dot(self, dotcode, filename="<stdin>"):
+ if self._dot_widget.set_dotcode(dotcode, filename):
+ self._dot_widget.zoom_to_fit()
+
+ def _on_save_project(self, widget):
+ pass
+
+ def show_info(self, message, title='PyCatcher', time_to_sleep=3, type='INFO'):
+ gtk_type = {'INFO' : gtk.MESSAGE_INFO,
+ 'ERROR': gtk.MESSAGE_ERROR}
+
+ dlg = gtk.MessageDialog(type=gtk.MESSAGE_INFO,
+ message_format=str(message)
+ )
+
+ dlg.set_title(title)
+ #dlg.run()
+ dlg.show()
+ time.sleep(time_to_sleep)
+ dlg.destroy()
+
+ def log_line(self, line):
+ self._log_buffer.insert(self._log_buffer.get_end_iter(),self._utf8conv(datetime.datetime.now().strftime("%I:%M:%S %p")+ ": " + line + "\n")) \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fc/700191bfb9f100101fc6d5dee7f902b6 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fc/700191bfb9f100101fc6d5dee7f902b6
new file mode 100644
index 0000000..0ad91d1
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fc/700191bfb9f100101fc6d5dee7f902b6
@@ -0,0 +1,824 @@
+/* Cell Scanning code for OsmocomBB */
+
+/* (C) 2010 by Andreas Eversberg <jolly@eversberg.eu>
+ *
+ * All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <errno.h>
+
+#include <l1ctl_proto.h>
+
+#include <osmocom/core/logging.h>
+#include <osmocom/core/timer.h>
+#include <osmocom/core/signal.h>
+#include <osmocom/core/msgb.h>
+#include <osmocom/gsm/gsm_utils.h>
+#include <osmocom/gsm/protocol/gsm_04_08.h>
+#include <osmocom/gsm/rsl.h>
+
+#include <osmocom/bb/common/l1ctl.h>
+#include <osmocom/bb/common/osmocom_data.h>
+#include <osmocom/bb/common/lapdm.h>
+#include <osmocom/bb/common/logging.h>
+#include <osmocom/bb/common/networks.h>
+#include <osmocom/bb/common/gps.h>
+#include <osmocom/bb/misc/cell_log.h>
+#include "../../../gsmmap/geo.h"
+
+#define READ_WAIT 2, 0
+#define RACH_WAIT 0, 900000
+#define MIN_RXLEV -106
+#define MAX_DIST 2000
+
+enum {
+ SCAN_STATE_PM,
+ SCAN_STATE_SYNC,
+ SCAN_STATE_READ,
+ SCAN_STATE_RACH,
+};
+
+/* ranges of bands */
+static uint16_t band_range[][2] = {{0, 124}, {512, 885}, {955, 1023}, {0, 0}};
+
+#define INFO_FLG_PM 1
+#define INFO_FLG_SYNC 2
+#define INFO_FLG_SI1 4
+#define INFO_FLG_SI2 8
+#define INFO_FLG_SI2bis 16
+#define INFO_FLG_SI2ter 32
+#define INFO_FLG_SI3 64
+#define INFO_FLG_SI4 128
+
+static struct osmocom_ms *ms;
+static struct osmo_timer_list timer;
+
+static struct pm_info {
+ uint16_t flags;
+ int8_t rxlev;
+} pm[1024];
+
+static int started = 0;
+static int state;
+static int8_t min_rxlev = MIN_RXLEV;
+static int sync_count;
+static int pm_index, pm_gps_valid;
+static double pm_gps_x, pm_gps_y, pm_gps_z;
+static int arfcn;
+static int rach_count;
+static FILE *logfp = NULL;
+extern char *logname;
+extern int RACH_MAX;
+
+
+static struct gsm48_sysinfo sysinfo;
+
+static struct log_si {
+ uint16_t flags;
+ uint8_t bsic;
+ int8_t rxlev;
+ uint16_t mcc, mnc, lac, cellid;
+ uint8_t ta;
+ double latitude, longitude;
+} log_si;
+
+struct rach_ref {
+ uint8_t valid;
+ uint8_t cr;
+ uint8_t t1, t2, t3;
+} rach_ref;
+
+#define LOGFILE(fmt, args...) \
+ fprintf(logfp, fmt, ## args);
+#define LOGFLUSH() \
+ fflush(logfp);
+
+static void start_sync(void);
+static void start_rach(void);
+static void start_pm(void);
+
+static void log_gps(void)
+{
+ if (!g.enable || !g.valid)
+ return;
+ LOGFILE("position %.8f %.8f\n", g.longitude, g.latitude);
+}
+
+static void log_time(void)
+{
+ time_t now;
+
+ if (g.enable && g.valid)
+ now = g.gmt;
+ else
+ time(&now);
+ LOGFILE("time %lu\n", now);
+}
+
+static void log_frame(char *tag, uint8_t *data)
+{
+ int i;
+
+ LOGFILE("%s", tag);
+ for (i = 0; i < 23; i++)
+ LOGFILE(" %02x", *data++);
+ LOGFILE("\n");
+}
+
+static void log_pm(void)
+{
+ int count = 0, i;
+
+ LOGFILE("[power]\n");
+ log_time();
+ log_gps();
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)) {
+ if (!count)
+ LOGFILE("arfcn %d", i);
+ LOGFILE(" %d", pm[i].rxlev);
+ count++;
+ if (count == 12) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ } else {
+ if (count) {
+ LOGFILE("\n");
+ count = 0;
+ }
+ }
+ }
+ if (count)
+ LOGFILE("\n");
+
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void log_sysinfo(void)
+{
+ struct rx_meas_stat *meas = &ms->meas;
+ struct gsm48_sysinfo *s = &sysinfo;
+ int8_t rxlev;
+ char ta_str[32] = "";
+
+ if (log_si.ta != 0xff)
+ sprintf(ta_str, " TA=%d", log_si.ta);
+
+ LOGP(DSUM, LOGL_INFO, "Cell: ARFCN=%d MCC=%s MNC=%s (%s, %s)%s\n",
+ arfcn, gsm_print_mcc(s->mcc), gsm_print_mnc(s->mnc),
+ gsm_get_mcc(s->mcc), gsm_get_mnc(s->mcc, s->mnc), ta_str);
+
+ LOGFILE("[SysInfo]\n");
+ //LOGFILE("provider: %s", )
+ //LOGFILE("country: %s", )
+ LOGFILE("arfcn %d\n", s->arfcn);
+ //log_time();
+ //log_gps();
+ LOGFILE("bsic %d,%d\n", s->bsic >> 3, s->bsic & 7);
+ rxlev = meas->rxlev / meas->frames - 110;
+ LOGFILE("rxlev %d\n", rxlev);
+ if (s->si1)
+ log_frame("si1", s->si1_msg);
+ if (s->si2)
+ log_frame("si2", s->si2_msg);
+ if (s->si2bis)
+ log_frame("si2bis", s->si2b_msg);
+ if (s->si2ter)
+ log_frame("si2ter", s->si2t_msg);
+ if (s->si3)
+ log_frame("si3", s->si3_msg);
+ if (s->si4)
+ log_frame("si4", s->si4_msg);
+ if (log_si.ta != 0xff)
+ LOGFILE("ta %d\n", log_si.ta);
+
+ LOGFILE("[EndInfo]\n");
+ LOGFILE("\n");
+ LOGFLUSH();
+}
+
+static void timeout_cb(void *arg)
+{
+ switch (state) {
+ case SCAN_STATE_READ:
+ LOGP(DRR, LOGL_INFO, "Timeout reading BCCH\n");
+ start_sync();
+ break;
+ case SCAN_STATE_RACH:
+ LOGP(DRR, LOGL_INFO, "Timeout on RACH\n");
+ rach_count++;
+ start_rach();
+ break;
+ }
+}
+
+static void stop_timer(void)
+{
+ if (osmo_timer_pending(&timer))
+ osmo_timer_del(&timer);
+}
+
+static void start_timer(int sec, int micro)
+{
+ stop_timer();
+ timer.cb = timeout_cb;
+ timer.data = ms;
+ osmo_timer_schedule(&timer, sec, micro);
+}
+
+static void start_rach(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ uint8_t chan_req_val, chan_req_mask;
+ struct msgb *nmsg;
+ struct abis_rsl_cchan_hdr *ncch;
+
+ if (rach_count == RACH_MAX) {
+ log_sysinfo();
+ start_sync();
+ return;
+ }
+
+ state = SCAN_STATE_RACH;
+
+ if (s->neci) {
+ chan_req_mask = 0x0f;
+ chan_req_val = 0x01;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x "
+ "(OTHER with NECI)\n", chan_req_val);
+ } else {
+ chan_req_mask = 0x1f;
+ chan_req_val = 0xe0;
+ LOGP(DRR, LOGL_INFO, "CHANNEL REQUEST: %02x (OTHER no NECI)\n",
+ chan_req_val);
+ }
+
+ rach_ref.valid = 0;
+ rach_ref.cr = random();
+ rach_ref.cr &= chan_req_mask;
+ rach_ref.cr |= chan_req_val;
+
+ nmsg = msgb_alloc_headroom(RSL_ALLOC_SIZE+RSL_ALLOC_HEADROOM,
+ RSL_ALLOC_HEADROOM, "GSM 04.06 RSL");
+ if (!nmsg)
+ return;
+ nmsg->l2h = nmsg->data;
+ ncch = (struct abis_rsl_cchan_hdr *) msgb_put(nmsg, sizeof(*ncch)
+ + 4 + 2 + 2);
+ rsl_init_cchan_hdr(ncch, RSL_MT_CHAN_RQD);
+ ncch->chan_nr = RSL_CHAN_RACH;
+ ncch->data[0] = RSL_IE_REQ_REFERENCE;
+ ncch->data[1] = rach_ref.cr;
+ ncch->data[2] = (s->ccch_conf == 1) << 7;
+ ncch->data[3] = 0;
+ ncch->data[4] = RSL_IE_ACCESS_DELAY;
+ ncch->data[5] = 0; /* no delay */
+ ncch->data[6] = RSL_IE_MS_POWER;
+ ncch->data[7] = 0; /* full power */
+
+ start_timer(RACH_WAIT);
+
+ lapdm_rslms_recvmsg(nmsg, &ms->lapdm_channel);
+}
+
+static void start_sync(void)
+{
+ int rxlev = -128;
+ int i, dist = 0;
+ char dist_str[32] = "";
+
+ arfcn = 0xffff;
+ for (i = 0; i <= 1023; i++) {
+ if ((pm[i].flags & INFO_FLG_PM)
+ && !(pm[i].flags & INFO_FLG_SYNC)) {
+ if (pm[i].rxlev > rxlev) {
+ rxlev = pm[i].rxlev;
+ arfcn = i;
+ }
+ }
+ }
+ /* if GPS becomes valid, like after exitting a tunnel */
+ if (!pm_gps_valid && g.valid) {
+ pm_gps_valid = 1;
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z, g.longitude,
+ g.latitude);
+ }
+ if (pm_gps_valid && g.valid) {
+ double x, y, z;
+
+ geo2space(&x, &y, &z, g.longitude, g.latitude);
+ dist = distinspace(pm_gps_x, pm_gps_y, pm_gps_z, x, y, z);
+ sprintf(dist_str, " dist %d", (int)dist);
+ }
+ if (dist > MAX_DIST || arfcn == 0xffff || rxlev < min_rxlev) {
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ return;
+ }
+ pm[arfcn].flags |= INFO_FLG_SYNC;
+ HACK: no use for us right now
+ LOGP(DSUM, LOGL_INFO, "Sync ARFCN %d (rxlev %d, %d syncs "
+ "left)%s\n", arfcn, pm[arfcn].rxlev, sync_count--, dist_str);
+ memset(&sysinfo, 0, sizeof(sysinfo));
+ sysinfo.arfcn = arfcn;
+ state = SCAN_STATE_SYNC;
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_fbsb_req(ms, arfcn, L1CTL_FBSB_F_FB01SB, 100, 0,
+ CCCH_MODE_NONE);
+}
+
+static void start_pm(void)
+{
+ uint16_t from, to;
+
+ state = SCAN_STATE_PM;
+ from = band_range[pm_index][0];
+ to = band_range[pm_index][1];
+
+ if (from == 0 && to == 0) {
+ LOGP(DSUM, LOGL_INFO, "Measurement done\n");
+ pm_gps_valid = g.enable && g.valid;
+ if (pm_gps_valid)
+ geo2space(&pm_gps_x, &pm_gps_y, &pm_gps_z,
+ g.longitude, g.latitude);
+ log_pm();
+ start_sync();
+ return;
+ }
+ LOGP(DSUM, LOGL_INFO, "Measure from %d to %d\n", from, to);
+ l1ctl_tx_reset_req(ms, L1CTL_RES_T_FULL);
+ l1ctl_tx_pm_req_range(ms, from, to);
+}
+
+static int signal_cb(unsigned int subsys, unsigned int signal,
+ void *handler_data, void *signal_data)
+{
+ struct osmobb_meas_res *mr;
+ struct osmobb_fbsb_res *fr;
+ uint16_t index;
+
+ if (subsys != SS_L1CTL)
+ return 0;
+
+ switch (signal) {
+ case S_L1CTL_PM_RES:
+ mr = signal_data;
+ index = mr->band_arfcn & 0x3ff;
+ pm[index].flags |= INFO_FLG_PM;
+ pm[index].rxlev = mr->rx_lev - 110;
+ if (pm[index].rxlev >= min_rxlev)
+ sync_count++;
+// printf("rxlev %d = %d (sync_count %d)\n", index, pm[index].rxlev, sync_count);
+ break;
+ case S_L1CTL_PM_DONE:
+ pm_index++;
+ start_pm();
+ break;
+ case S_L1CTL_FBSB_RESP:
+ fr = signal_data;
+ sysinfo.bsic = fr->bsic;
+ state = SCAN_STATE_READ;
+ memset(&ms->meas, 0, sizeof(ms->meas));
+ memset(&log_si, 0, sizeof(log_si));
+ log_si.flags |= INFO_FLG_SYNC;
+ log_si.ta = 0xff; /* invalid */
+ start_timer(READ_WAIT);
+ LOGP(DRR, LOGL_INFO, "Synchronized, start reading\n");
+ break;
+ case S_L1CTL_FBSB_ERR:
+ LOGP(DRR, LOGL_INFO, "Sync failed\n");
+ start_sync();
+ break;
+ case S_L1CTL_RESET:
+ if (started)
+ break;
+ started = 1;
+ memset(pm, 0, sizeof(pm));
+ pm_index = 0;
+ sync_count = 0;
+ start_pm();
+ }
+ return 0;
+}
+
+static int ta_result(uint8_t ta)
+{
+ stop_timer();
+
+ if (ta == 0xff)
+ LOGP(DSUM, LOGL_INFO, "Got assignment reject\n");
+ else {
+ LOGP(DSUM, LOGL_DEBUG, "Got assignment TA = %d\n", ta);
+ log_si.ta = ta;
+ }
+
+ log_sysinfo();
+ start_sync();
+
+ return 0;
+}
+
+/* match request reference agains request */
+static int match_ra(struct osmocom_ms *ms, struct gsm48_req_ref *ref)
+{
+ uint8_t ia_t1, ia_t2, ia_t3;
+
+ /* filter confirmed RACH requests only */
+ if (rach_ref.valid && ref->ra == rach_ref.cr) {
+ ia_t1 = ref->t1;
+ ia_t2 = ref->t2;
+ ia_t3 = (ref->t3_high << 3) | ref->t3_low;
+ if (ia_t1 == rach_ref.t1 && ia_t2 == rach_ref.t2
+ && ia_t3 == rach_ref.t3) {
+ LOGP(DRR, LOGL_INFO, "request %02x matches "
+ "(fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2,
+ ia_t3);
+ return 1;
+ } else
+ LOGP(DRR, LOGL_INFO, "request %02x matches but not "
+ "frame number (IMM.ASS fn=%d,%d,%d != RACH "
+ "fn=%d,%d,%d)\n", ref->ra, ia_t1, ia_t2, ia_t3,
+ rach_ref.t1, rach_ref.t2, rach_ref.t3);
+ }
+
+ return 0;
+}
+
+/* 9.1.18 IMMEDIATE ASSIGNMENT is received */
+static int imm_ass(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref */
+ if (match_ra(ms, &ia->req_ref)) {
+ return ta_result(ia->timing_advance);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.19 IMMEDIATE ASSIGNMENT EXTENDED is received */
+static int imm_ass_ext(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_ext *ia = msgb_l3(msg);
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT EXTENDED:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ /* request ref 1 */
+ if (match_ra(ms, &ia->req_ref1)) {
+ return ta_result(ia->timing_advance1);
+ }
+ /* request ref 2 */
+ if (match_ra(ms, &ia->req_ref2)) {
+ return ta_result(ia->timing_advance2);
+ }
+ LOGP(DRR, LOGL_INFO, "Request, but not for us.\n");
+
+ return 0;
+}
+
+/* 9.1.20 IMMEDIATE ASSIGNMENT REJECT is received */
+static int imm_ass_rej(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_imm_ass_rej *ia = msgb_l3(msg);
+ int i;
+ struct gsm48_req_ref *req_ref;
+
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT:\n");
+
+ if (state != SCAN_STATE_RACH) {
+ LOGP(DRR, LOGL_INFO, "Not for us, no request.\n");
+ return 0;
+ }
+
+ for (i = 0; i < 4; i++) {
+ /* request reference */
+ req_ref = (struct gsm48_req_ref *)
+ (((uint8_t *)&ia->req_ref1) + i * 4);
+ LOGP(DRR, LOGL_INFO, "IMMEDIATE ASSIGNMENT REJECT "
+ "(ref 0x%02x)\n", req_ref->ra);
+ if (match_ra(ms, req_ref)) {
+ return ta_result(0xff);
+ }
+ }
+
+ return 0;
+}
+
+/* receive CCCH at RR layer */
+static int pch_agch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+
+ switch (sih->system_information) {
+ case GSM48_MT_RR_PAG_REQ_1:
+ case GSM48_MT_RR_PAG_REQ_2:
+ case GSM48_MT_RR_PAG_REQ_3:
+ return 0;
+ case GSM48_MT_RR_IMM_ASS:
+ return imm_ass(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_EXT:
+ return imm_ass_ext(ms, msg);
+ case GSM48_MT_RR_IMM_ASS_REJ:
+ return imm_ass_rej(ms, msg);
+ default:
+ return -EINVAL;
+ }
+}
+
+/* check if sysinfo is complete, change to RACH state */
+static int new_sysinfo(void)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+
+ /* restart timer */
+ start_timer(READ_WAIT);
+
+ /* mandatory */
+ if (!s->si1 || !s->si2 || !s->si3 || !s->si4) {
+ LOGP(DRR, LOGL_INFO, "not all mandatory SI received\n");
+ return 0;
+ }
+
+ /* extended band */
+ if (s->nb_ext_ind_si2 && !s->si2bis) {
+ LOGP(DRR, LOGL_INFO, "extended ba, but si2bis not received\n");
+ return 0;
+ }
+
+ /* 2ter */
+ if (s->si2ter_ind && !s->si2ter) {
+ LOGP(DRR, LOGL_INFO, "si2ter_ind, but si2ter not received\n");
+ return 0;
+ }
+
+ LOGP(DRR, LOGL_INFO, "Sysinfo complete\n");
+
+ stop_timer();
+
+ rach_count = 0;
+ start_rach();
+
+ return 0;
+}
+
+/* receive BCCH at RR layer */
+static int bcch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct gsm48_sysinfo *s = &sysinfo;
+ struct gsm48_system_information_type_header *sih = msgb_l3(msg);
+ uint8_t ccch_mode;
+
+ if (msgb_l3len(msg) != 23) {
+ LOGP(DRR, LOGL_NOTICE, "Invalid BCCH message length\n");
+ return -EINVAL;
+ }
+ switch (sih->system_information) {
+ case GSM48_MT_RR_SYSINFO_1:
+ if (!memcmp(sih, s->si1_msg, sizeof(s->si1_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 1\n");
+ gsm48_decode_sysinfo1(s,
+ (struct gsm48_system_information_type_1 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2:
+ if (!memcmp(sih, s->si2_msg, sizeof(s->si2_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2\n");
+ gsm48_decode_sysinfo2(s,
+ (struct gsm48_system_information_type_2 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2bis:
+ if (!memcmp(sih, s->si2b_msg, sizeof(s->si2b_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2bis\n");
+ gsm48_decode_sysinfo2bis(s,
+ (struct gsm48_system_information_type_2bis *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_2ter:
+ if (!memcmp(sih, s->si2t_msg, sizeof(s->si2t_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 2ter\n");
+ gsm48_decode_sysinfo2ter(s,
+ (struct gsm48_system_information_type_2ter *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_3:
+ if (!memcmp(sih, s->si3_msg, sizeof(s->si3_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 3\n");
+ gsm48_decode_sysinfo3(s,
+ (struct gsm48_system_information_type_3 *) sih,
+ msgb_l3len(msg));
+ ccch_mode = (s->ccch_conf == 1) ? CCCH_MODE_COMBINED :
+ CCCH_MODE_NON_COMBINED;
+ LOGP(DRR, LOGL_INFO, "Changing CCCH_MODE to %d\n", ccch_mode);
+ l1ctl_tx_ccch_mode_req(ms, ccch_mode);
+ return new_sysinfo();
+ case GSM48_MT_RR_SYSINFO_4:
+ if (!memcmp(sih, s->si4_msg, sizeof(s->si4_msg)))
+ return 0;
+ LOGP(DRR, LOGL_INFO, "New SYSTEM INFORMATION 4\n");
+ gsm48_decode_sysinfo4(s,
+ (struct gsm48_system_information_type_4 *) sih,
+ msgb_l3len(msg));
+ return new_sysinfo();
+ default:
+ return -EINVAL;
+ }
+}
+
+static int unit_data_ind(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ struct tlv_parsed tv;
+ uint8_t ch_type, ch_subch, ch_ts;
+
+ DEBUGP(DRSL, "RSLms UNIT DATA IND chan_nr=0x%02x link_id=0x%02x\n",
+ rllh->chan_nr, rllh->link_id);
+
+ rsl_tlv_parse(&tv, rllh->data, msgb_l2len(msg)-sizeof(*rllh));
+ if (!TLVP_PRESENT(&tv, RSL_IE_L3_INFO)) {
+ DEBUGP(DRSL, "UNIT_DATA_IND without L3 INFO ?!?\n");
+ return -EIO;
+ }
+ msg->l3h = (uint8_t *) TLVP_VAL(&tv, RSL_IE_L3_INFO);
+
+ if (state != SCAN_STATE_READ && state != SCAN_STATE_RACH) {
+ return -EINVAL;
+ }
+
+ rsl_dec_chan_nr(rllh->chan_nr, &ch_type, &ch_subch, &ch_ts);
+ switch (ch_type) {
+ case RSL_CHAN_PCH_AGCH:
+ return pch_agch(ms, msg);
+ case RSL_CHAN_BCCH:
+ return bcch(ms, msg);
+#if 0
+ case RSL_CHAN_Bm_ACCHs:
+ case RSL_CHAN_Lm_ACCHs:
+ case RSL_CHAN_SDCCH4_ACCH:
+ case RSL_CHAN_SDCCH8_ACCH:
+ return rx_acch(ms, msg);
+#endif
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "RSL with chan_nr 0x%02x unknown.\n",
+ rllh->chan_nr);
+ return -EINVAL;
+ }
+}
+
+static int rcv_rll(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_rll_hdr *rllh = msgb_l2(msg);
+ int msg_type = rllh->c.msg_type;
+
+ if (msg_type == RSL_MT_UNIT_DATA_IND) {
+ unit_data_ind(ms, msg);
+ } else
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+
+ msgb_free(msg);
+
+ return 0;
+}
+
+int chan_conf(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ struct gsm48_req_ref *ref = (struct gsm48_req_ref *) (ch->data + 1);
+
+ if (msgb_l2len(msg) < sizeof(*ch) + sizeof(*ref)) {
+ LOGP(DRR, LOGL_ERROR, "CHAN_CNF too slort\n");
+ return -EINVAL;
+ }
+
+ rach_ref.valid = 1;
+ rach_ref.t1 = ref->t1;
+ rach_ref.t2 = ref->t2;
+ rach_ref.t3 = ref->t3_low | (ref->t3_high << 3);
+
+ return 0;
+}
+
+static int rcv_cch(struct osmocom_ms *ms, struct msgb *msg)
+{
+ struct abis_rsl_cchan_hdr *ch = msgb_l2(msg);
+ int msg_type = ch->c.msg_type;
+ int rc;
+
+ LOGP(DRSL, LOGL_INFO, "Received '%s' from layer1\n",
+ rsl_msg_name(msg_type));
+
+ if (state == SCAN_STATE_RACH && msg_type == RSL_MT_CHAN_CONF) {
+ rc = chan_conf(ms, msg);
+ msgb_free(msg);
+ return rc;
+ }
+
+ LOGP(DRSL, LOGL_NOTICE, "RSLms message unhandled\n");
+ msgb_free(msg);
+ return 0;
+}
+
+static int rcv_rsl(struct msgb *msg, struct lapdm_entity *le, void *l3ctx)
+{
+ struct osmocom_ms *ms = l3ctx;
+ struct abis_rsl_common_hdr *rslh = msgb_l2(msg);
+ int rc = 0;
+
+ switch (rslh->msg_discr & 0xfe) {
+ case ABIS_RSL_MDISC_RLL:
+ rc = rcv_rll(ms, msg);
+ break;
+ case ABIS_RSL_MDISC_COM_CHAN:
+ rc = rcv_cch(ms, msg);
+ break;
+ default:
+ LOGP(DRSL, LOGL_NOTICE, "unknown RSLms msg_discr 0x%02x\n",
+ rslh->msg_discr);
+ msgb_free(msg);
+ rc = -EINVAL;
+ break;
+ }
+
+ return rc;
+}
+
+int scan_init(struct osmocom_ms *_ms)
+{
+ ms = _ms;
+ osmo_signal_register_handler(SS_L1CTL, &signal_cb, NULL);
+ memset(&timer, 0, sizeof(timer));
+ lapdm_channel_set_l3(&ms->lapdm_channel, &rcv_rsl, ms);
+ g.enable = 1;
+ osmo_gps_init();
+ if (osmo_gps_open())
+ g.enable = 0;
+
+ if (!strcmp(logname, "-"))
+ logfp = stdout;
+ else
+ logfp = fopen(logname, "a");
+ if (!logfp) {
+ fprintf(stderr, "Failed to open logfile '%s'\n", logname);
+ scan_exit();
+ return -errno;
+ }
+ LOGP(DSUM, LOGL_INFO, "Scanner initialized\n");
+
+ return 0;
+}
+
+int scan_exit(void)
+{
+ LOGP(DSUM, LOGL_INFO, "Scanner exit\n");
+ if (g.valid)
+ osmo_gps_close();
+ if (logfp)
+ fclose(logfp);
+ osmo_signal_unregister_handler(SS_L1CTL, &signal_cb, NULL);
+ stop_timer();
+
+ return 0;
+}
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ff/e063106c6ff2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ff/e063106c6ff2001013089cecc8a626ff
new file mode 100644
index 0000000..d6dbb86
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ff/e063106c6ff2001013089cecc8a626ff
@@ -0,0 +1,71 @@
+from pyCatcherModel import BaseStationInformation
+import subprocess
+import threading
+import re
+from pyCatcherSettings import Commands
+import sys
+import time
+import gtk #@UnresolvedImport
+
+class DriverConnector:
+ def __init__ (self):
+ self._scan_thread_break = False
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = None
+ self._firmware_loaded_callback = None
+ self._test_thread = None
+
+ def start_scanning (self, base_station_found_callback):
+ self._scan_thread_break = False
+ threading.Thread(target= self._do_scan).start()
+
+ def start_firmware(self, firmware_waiting_callback, firmware_loaded_callback):
+ self._firmware_thread_break = False
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ firmThread = FirmwareThread(self._firmware_waiting_callback, self._firmware_loaded_callback, self._firmware_thread_break)
+ firmThread.start()
+
+ def stop_scanning (self):
+ self._scan_thread_break = True
+
+ def stop_firmware(self):
+ self._firmware_thread_break = True
+
+class FirmwareThread(threading.Thread):
+ def __init__(self, firmware_waiting_callback, firmware_loaded_callback, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._firmware_waiting_callback = firmware_waiting_callback
+ self._firmware_loaded_callback = firmware_loaded_callback
+ self._thread_break = thread_break
+
+ def run(self):
+ loader_process_object = subprocess.Popen(Commands['osmocon_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(3)
+ self._firmware_waiting_callback()
+ while not self._thread_break:
+ line = loader_process_object.stdout.readline()
+ #if line:
+ # print line
+ if (line.strip() == 'Finishing download phase'):
+ self._firmware_loaded_callback()
+ #time.sleep(0.5)
+ loader_process_object.kill()
+
+class ScanThread(threading.Thread):
+ def __init__(self, thread_break):
+ gtk.gdk.threads_init()
+ threading.Thread.__init__(self)
+ self._thread_break = thread_break
+
+ def run(self):
+ scan_process = subprocess.Popen(Commands['scan_command'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ time.sleep(2)
+ while not self._scan_thread_break:
+ line = scan_process.stdout.readline()
+ if line:
+ print line
+ sys.stdout.flush()
+ scan_process.kill()
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/a8/c5/40/15/properties.index b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/a8/c5/40/15/properties.index
new file mode 100644
index 0000000..0fecb54
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/a8/c5/40/15/properties.index
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/e4/ec/history.index b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/e4/ec/history.index
new file mode 100644
index 0000000..7d436d1
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/e4/ec/history.index
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/e4/ec/properties.index b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/e4/ec/properties.index
new file mode 100644
index 0000000..74ab2aa
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/e4/a8/ae/e4/ec/properties.index
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/properties.index b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/properties.index
new file mode 100644
index 0000000..8e2af78
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.indexes/properties.index
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.location b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.location
new file mode 100644
index 0000000..4edd299
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.location
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.markers b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.markers
new file mode 100644
index 0000000..f28f71c
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/CatcherLib/.markers
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.indexes/e4/history.index b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.indexes/e4/history.index
new file mode 100644
index 0000000..9e50913
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.indexes/e4/history.index
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.location b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.location
new file mode 100644
index 0000000..e3c127c
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.location
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.markers b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.markers
new file mode 100644
index 0000000..6852dc6
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/.markers
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/0.v1_projectinfodelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/0.v1_projectinfodelta
new file mode 100644
index 0000000..1581f23
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/0.v1_projectinfodelta
@@ -0,0 +1 @@
+DELSTRpyCatcherView \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/1.v1_projectinfodelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/1.v1_projectinfodelta
new file mode 100644
index 0000000..7b3808f
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/1.v1_projectinfodelta
@@ -0,0 +1,29 @@
+INSTUPpyCatcherView
+/home/tom/imsi-catcher-detection/Src/PyCatcher/src/pyCatcherView.py
+INFOS:&&1|1|2|0&&2|3|2|1&&3|4|2|5&&3|6|2|5&&3|7|2|5&&3|8|2|5&&3|9|2|5&&3|10|2|5&&3|11|2|5&&3|12|2|5&&3|13|2|5&&3|14|2|5&&2|15|2|1&&2|16|2|1&&2|17|2|1&&3|6|2|18&&3|6|2|18&&2|19|2|1&&3|7|2|20&&3|7|2|20&&2|21|2|1&&2|22|2|1&&2|23|2|1&&2|24|2|1&&2|25|2|1&&2|26|2|1
+_add_column=15
+_on_main_window_destroy=16
+_scan_toggled_on=6
+_on_toggle_scan=17
+load_dot_from_file=22
+_firmware_toggled_on=7
+PyCatcherGUI._on_toggle_firmware=20
+_on_save_project=24
+PyCatcherGUI.__init__=5
+_utf8conv=4
+load_dot=23
+_horizontal_container=11
+_dot_widget=12
+_main_window=13
+log_line=26
+_on_open_file=21
+show_info=25
+_on_toggle_firmware=19
+_catcher_controller=8
+__init__=3
+pyCatcherView=2
+PyCatcherGUI._on_toggle_scan=18
+_w_tree=9
+_log_buffer=14
+_bs_tree_view=10
+PyCatcherGUI=1
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/2.v1_projectinfodelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/2.v1_projectinfodelta
new file mode 100644
index 0000000..4baabfd
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/2.v1_projectinfodelta
@@ -0,0 +1 @@
+DELSTRmain \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/3.v1_projectinfodelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/3.v1_projectinfodelta
new file mode 100644
index 0000000..7990d0d
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/3.v1_projectinfodelta
@@ -0,0 +1,4 @@
+INSTUPmain
+/home/tom/imsi-catcher-detection/Src/PyCatcher/src/main.py
+INFOS:&&2|1|1|0
+main=1
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/4.v1_projectinfodelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/4.v1_projectinfodelta
new file mode 100644
index 0000000..13a412e
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/4.v1_projectinfodelta
@@ -0,0 +1 @@
+DELSTRpyCatcherModel \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/5.v1_projectinfodelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/5.v1_projectinfodelta
new file mode 100644
index 0000000..44eea81
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/5.v1_projectinfodelta
@@ -0,0 +1,21 @@
+INSTUPpyCatcherModel
+/home/tom/imsi-catcher-detection/Src/PyCatcher/src/pyCatcherModel.py
+INFOS:&&1|1|2|0&&2|3|2|1&&3|4|2|5&&3|6|2|5&&3|7|2|5&&3|8|2|5&&3|9|2|5&&3|10|2|5&&2|11|2|1&&2|12|2|1&&1|13|2|0&&2|3|2|13&&3|14|2|15&&2|16|2|13&&2|17|2|13&&2|18|2|13
+BaseStationInformationList=13
+rxlev=8
+pyCatcherModel=2
+BaseStationInformationList.__init__=15
+BaseStationInformation=1
+provider=6
+_base_station_list=14
+get_neighbour_arfcn=12
+refill_store=18
+get_dot_code=17
+country=4
+__init__=3
+discovery_time=10
+get_list_model=11
+BaseStationInformation.__init__=5
+arfcn=7
+system_info_t2=9
+add_station=16
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/6.v1_projectinfodelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/6.v1_projectinfodelta
new file mode 100644
index 0000000..66cd251
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/6.v1_projectinfodelta
@@ -0,0 +1 @@
+DELSTRdriverConnector \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/7.v1_projectinfodelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/7.v1_projectinfodelta
new file mode 100644
index 0000000..19b64e9
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/7.v1_projectinfodelta
@@ -0,0 +1,29 @@
+INSTUPdriverConnector
+/home/tom/imsi-catcher-detection/Src/PyCatcher/src/driverConnector.py
+INFOS:&&1|1|2|0&&2|3|2|1&&3|4|2|5&&3|6|2|5&&3|7|2|5&&3|8|2|5&&3|9|2|5&&3|10|2|5&&3|11|2|5&&2|12|2|1&&3|4|2|13&&3|9|2|13&&3|11|2|13&&2|14|2|1&&3|6|2|15&&3|7|2|15&&3|8|2|15&&3|10|2|15&&2|16|2|1&&3|4|2|17&&2|18|2|1&&3|6|2|19&&2|20|2|1&&1|21|2|0&&2|3|2|21&&3|7|2|22&&3|8|2|22&&3|23|2|22&&2|24|2|21&&1|25|2|0&&2|3|2|25&&3|9|2|26&&3|23|2|26&&2|24|2|25
+_scanThread=11
+_base_station_found_callback=9
+DriverConnector=1
+_scan_thread_break=4
+ScanThread.__init__=26
+run=24
+DriverConnector.start_scanning=13
+DriverConnector.stop_firmware=19
+start_firmware=14
+stop_firmware=18
+DriverConnector.__init__=5
+shutdown=20
+FirmwareThread=21
+DriverConnector.stop_scanning=17
+stop_scanning=16
+driverConnector=2
+ScanThread=25
+FirmwareThread.__init__=22
+_firmware_waiting_callback=7
+__init__=3
+start_scanning=12
+_firmware_thread_break=6
+_thread_break=23
+_firmThread=10
+_firmware_loaded_callback=8
+DriverConnector.start_firmware=15
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/AdditionalProjectInterpreterInfo.pydevinfo b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/AdditionalProjectInterpreterInfo.pydevinfo
new file mode 100644
index 0000000..f461428
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/AdditionalProjectInterpreterInfo.pydevinfo
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/driverConnector_cgu0.v1_indexcache b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/driverConnector_cgu0.v1_indexcache
new file mode 100644
index 0000000..c227083
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/driverConnector_cgu0.v1_indexcache
@@ -0,0 +1 @@
+0 \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/main_eull.v1_indexcache b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/main_eull.v1_indexcache
new file mode 100644
index 0000000..c227083
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/main_eull.v1_indexcache
@@ -0,0 +1 @@
+0 \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherController_9q73.v1_indexcache b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherController_9q73.v1_indexcache
new file mode 100644
index 0000000..c227083
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherController_9q73.v1_indexcache
@@ -0,0 +1 @@
+0 \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherModel_63t0.v1_indexcache b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherModel_63t0.v1_indexcache
new file mode 100644
index 0000000..c227083
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherModel_63t0.v1_indexcache
@@ -0,0 +1 @@
+0 \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherSettings_2o9c.v1_indexcache b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherSettings_2o9c.v1_indexcache
new file mode 100644
index 0000000..c227083
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherSettings_2o9c.v1_indexcache
@@ -0,0 +1 @@
+0 \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherView_7nth.v1_indexcache b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherView_7nth.v1_indexcache
new file mode 100644
index 0000000..c227083
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/pyCatcherView_7nth.v1_indexcache
@@ -0,0 +1 @@
+0 \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/xdot_1ua2.v1_indexcache b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/xdot_1ua2.v1_indexcache
new file mode 100644
index 0000000..c227083
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/com.python.pydev.analysis/v1_indexcache/xdot_1ua2.v1_indexcache
@@ -0,0 +1 @@
+0 \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/0.v1_astdelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/0.v1_astdelta
new file mode 100644
index 0000000..e0172ff
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/0.v1_astdelta
@@ -0,0 +1 @@
+INSpyCatcherModel|/home/tom/imsi-catcher-detection/Src/PyCatcher/src/pyCatcherModel.py \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/1.v1_astdelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/1.v1_astdelta
new file mode 100644
index 0000000..7fda006
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/1.v1_astdelta
@@ -0,0 +1 @@
+INSxdot|/home/tom/imsi-catcher-detection/Src/PyCatcher/src/xdot.py \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/2.v1_astdelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/2.v1_astdelta
new file mode 100644
index 0000000..c65c2df
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/2.v1_astdelta
@@ -0,0 +1 @@
+INSpyCatcherController|/home/tom/imsi-catcher-detection/Src/PyCatcher/src/pyCatcherController.py \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/3.v1_astdelta b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/3.v1_astdelta
new file mode 100644
index 0000000..0a5191c
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/3.v1_astdelta
@@ -0,0 +1 @@
+INSpyCatcherSettings|/home/tom/imsi-catcher-detection/Src/PyCatcher/src/pyCatcherSettings.py \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/v1_astmanager/modulesKeys b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/v1_astmanager/modulesKeys
new file mode 100644
index 0000000..a315443
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/v1_astmanager/modulesKeys
@@ -0,0 +1,8 @@
+MODULES_MANAGER_V2
+driverConnector|/home/tom/imsi-catcher-detection/Src/PyCatcher/src/driverConnector.py
+main|/home/tom/imsi-catcher-detection/Src/PyCatcher/src/main.py
+pyCatcherController|/home/tom/imsi-catcher-detection/Src/PyCatcher/src/pyCatcherController.py
+pyCatcherModel|/home/tom/imsi-catcher-detection/Src/PyCatcher/src/pyCatcherModel.py
+pyCatcherSettings|/home/tom/imsi-catcher-detection/Src/PyCatcher/src/pyCatcherSettings.py
+pyCatcherView|/home/tom/imsi-catcher-detection/Src/PyCatcher/src/pyCatcherView.py
+xdot|/home/tom/imsi-catcher-detection/Src/PyCatcher/src/xdot.py
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/v1_astmanager/pythonpath b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/v1_astmanager/pythonpath
new file mode 100644
index 0000000..fae2867
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.projects/PyCatcher/org.python.pydev/v1_astmanager/pythonpath
@@ -0,0 +1 @@
+/home/tom/imsi-catcher-detection/Src/PyCatcher/src \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version
new file mode 100644
index 0000000..25cb955
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index
new file mode 100644
index 0000000..bea23b4
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version
new file mode 100644
index 0000000..6b2aaa7
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version
@@ -0,0 +1 @@
+ \ No newline at end of file
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/4.tree b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/4.tree
new file mode 100644
index 0000000..c94849d
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.root/4.tree
Binary files differ
diff --git a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources
new file mode 100644
index 0000000..087edde
--- /dev/null
+++ b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources
Binary files differ