summaryrefslogtreecommitdiffstats
path: root/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history
diff options
context:
space:
mode:
Diffstat (limited to 'Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history')
-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/36/a07dff68fd6100111a83ded3e22caa93823
-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/c9/f0b573ecfa6100111a83ded3e22caa93824
-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
167 files changed, 0 insertions, 25488 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
deleted file mode 100644
index 7a577ee..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/0/80724b69a6f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,53 +0,0 @@
-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
deleted file mode 100644
index 55df466..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/0/809df803a7f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644
index a4674db..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/11/c0d39316bbf100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,824 +0,0 @@
-/* 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
deleted file mode 100644
index d1e14da..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/12/50c0646979f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,111 +0,0 @@
-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
deleted file mode 100644
index 6dc84dd..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/14/f045290a99f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,43 +0,0 @@
-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
deleted file mode 100644
index e46caaf..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/18/f0e1cb9376f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index f1e1291..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1c/00ad039779f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,111 +0,0 @@
-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
deleted file mode 100644
index 52d6394..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1f/50bcc67f6ef2001013089cecc8a626ff
+++ /dev/null
@@ -1,52 +0,0 @@
-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
deleted file mode 100644
index 00b8418..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/1f/70887a0eb9f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,823 +0,0 @@
-/* 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
deleted file mode 100644
index 43e4c17..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2/50a917bf96f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,41 +0,0 @@
-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
deleted file mode 100644
index b4ed9a1..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/21/306e25ea72f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,76 +0,0 @@
-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
deleted file mode 100644
index 0ea055d..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/22/d05c9a89a7f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,59 +0,0 @@
-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
deleted file mode 100644
index 52fd5c2..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/24/309d645797f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,42 +0,0 @@
-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
deleted file mode 100644
index cacaf59..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/200219d8a8f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,115 +0,0 @@
-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
deleted file mode 100644
index 509e31b..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/70afa34676f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,133 +0,0 @@
-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
deleted file mode 100644
index 0731a05..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/25/70eef59a7cf2001019c79f38f40e52ba
+++ /dev/null
@@ -1,55 +0,0 @@
-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
deleted file mode 100644
index e385acf..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2c/701a355cbaf100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,824 +0,0 @@
-/* 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
deleted file mode 100644
index f3a9921..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2c/d09ab8b97af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index 7aa34d6..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/009445f880f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index d4e6448..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/40352fbb7af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index a2ca408..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/2f/60915ebb74f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,76 +0,0 @@
-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
deleted file mode 100644
index 473ee89..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3/304c2c2d78f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,83 +0,0 @@
-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
deleted file mode 100644
index dd6206b..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/30/c0de99f993f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644
index bbcf393..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/31/70ab7def79f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index 4a331bc..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/31/b054af3b95f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,36 +0,0 @@
-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
deleted file mode 100644
index 375c1fa..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/34/60a3370194f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644
index 0da2133..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/00df2df6b9f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,824 +0,0 @@
-/* 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
deleted file mode 100644
index 1850b00..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/406dec5270f2001013089cecc8a626ff
+++ /dev/null
@@ -1,73 +0,0 @@
-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
deleted file mode 100644
index ad2c7cf..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/35/b0fb1f8075f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,82 +0,0 @@
-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/36/a07dff68fd6100111a83ded3e22caa93 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/36/a07dff68fd6100111a83ded3e22caa93
deleted file mode 100644
index 7050c59..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/36/a07dff68fd6100111a83ded3e22caa93
+++ /dev/null
@@ -1,823 +0,0 @@
-/* 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/37/108910487af2001019c79f38f40e52ba b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/37/108910487af2001019c79f38f40e52ba
deleted file mode 100644
index 7cfc5c3..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/37/108910487af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,113 +0,0 @@
-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
deleted file mode 100644
index 35d38b3..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/38/903d7e0179f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,99 +0,0 @@
-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
deleted file mode 100644
index 615f5b5..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/39/20f54fab7ef2001019c79f38f40e52ba
+++ /dev/null
@@ -1,53 +0,0 @@
-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
deleted file mode 100644
index 09d38c4..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3a/30fc6a5a93f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644
index 8cb8692..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3a/70a4dbf8baf100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,824 +0,0 @@
-/* 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
deleted file mode 100644
index 4f01e12..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3d/0063938879f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,111 +0,0 @@
-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
deleted file mode 100644
index 1221b11..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3d/60d3a1e97ff2001019c79f38f40e52ba
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index 4fb2d9f..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/3e/40158315a6f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,48 +0,0 @@
-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
deleted file mode 100644
index 7aa34d6..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/41/a0d0fc9a9af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index 68e86be..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/41/b0277c4870f2001013089cecc8a626ff
+++ /dev/null
@@ -1,73 +0,0 @@
-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
deleted file mode 100644
index 2f91f98..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/42/1029600bb9f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,822 +0,0 @@
-/* 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
deleted file mode 100644
index 717d47f..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/43/10b7eba37ef2001019c79f38f40e52ba
+++ /dev/null
@@ -1,53 +0,0 @@
-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
deleted file mode 100644
index 3b05c7d..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/43/a09263f594f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,33 +0,0 @@
-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
deleted file mode 100644
index caba811..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/45/40832d7574f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,76 +0,0 @@
-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
deleted file mode 100644
index 15a69ee..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/45/f05d2f919ef2001019c79f38f40e52ba
+++ /dev/null
@@ -1,44 +0,0 @@
-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
deleted file mode 100644
index 179d2e2..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/47/0053978475f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,82 +0,0 @@
-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
deleted file mode 100644
index 550800b..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/47/c0ac774db8f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,821 +0,0 @@
-/* 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
deleted file mode 100644
index d60e245..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/48/60a9c87f74f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,76 +0,0 @@
-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
deleted file mode 100644
index d35a1ac..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/49/50e7aec57ef2001019c79f38f40e52ba
+++ /dev/null
@@ -1,53 +0,0 @@
-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
deleted file mode 100644
index def11b3..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4d/e070b4b399f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,43 +0,0 @@
-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
deleted file mode 100644
index d0604c1..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4e/1099a8e99ef2001019c79f38f40e52ba
+++ /dev/null
@@ -1,46 +0,0 @@
-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
deleted file mode 100644
index 34ba7c8..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/4f/409c89e692f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,30 +0,0 @@
-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
deleted file mode 100644
index cce1de8..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/50/70fa89f7a7f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,60 +0,0 @@
-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
deleted file mode 100644
index dcc4b4f..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/52/701063ea93f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644
index bf0377c..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/54/207fc56993f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,59 +0,0 @@
-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
deleted file mode 100644
index d048dd7..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/55/b0d520b394f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,32 +0,0 @@
-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
deleted file mode 100644
index 5d6d1b8..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/55/e0e2e3dda5f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,47 +0,0 @@
-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
deleted file mode 100644
index 16f9c29..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/56/a0aab0d478f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,100 +0,0 @@
-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
deleted file mode 100644
index af92733..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/57/4009d7c6a2f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,47 +0,0 @@
-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
deleted file mode 100644
index 40f7bc8..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5a/60c47c6a97f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,42 +0,0 @@
-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
deleted file mode 100644
index 609e61f..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5b/707fc8806ff2001013089cecc8a626ff
+++ /dev/null
@@ -1,71 +0,0 @@
-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
deleted file mode 100644
index c1cf06a..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5c/102a296345f300101883fa35752b544b
+++ /dev/null
@@ -1,824 +0,0 @@
-/* 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
deleted file mode 100644
index 20374e6..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5c/802b0bfea7f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,60 +0,0 @@
-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
deleted file mode 100644
index 43460f1..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/5d/d0bbc63480f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index 11cd4a9..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/60/406700eba6f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,55 +0,0 @@
-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
deleted file mode 100644
index 2b58e74..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/61/e08194a57af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index 5b8fb2b..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/63/a0b698a879f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,111 +0,0 @@
-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
deleted file mode 100644
index 3cebf6d..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/65/304bccca95f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,37 +0,0 @@
-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
deleted file mode 100644
index a7c6377..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/66/d0bcdf7a7af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,113 +0,0 @@
-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
deleted file mode 100644
index d35a1ac..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/67/9046d1037ff2001019c79f38f40e52ba
+++ /dev/null
@@ -1,53 +0,0 @@
-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
deleted file mode 100644
index 35474fc..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/67/d06f0dae70f2001013089cecc8a626ff
+++ /dev/null
@@ -1,74 +0,0 @@
-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
deleted file mode 100644
index 1a9c33c..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/68/3059941eb8f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,820 +0,0 @@
-/* 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
deleted file mode 100644
index 2869433..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/68/903de4d6a6f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,55 +0,0 @@
-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
deleted file mode 100644
index 13c2c52..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/6c/603ece379ff2001019c79f38f40e52ba
+++ /dev/null
@@ -1,115 +0,0 @@
-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
deleted file mode 100644
index 0202bdd..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/6c/c0fb5eec78f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,100 +0,0 @@
-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
deleted file mode 100644
index 5dba40f..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/70/b00ea6a778f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,98 +0,0 @@
-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
deleted file mode 100644
index 27f219c..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/71/401a8118baf100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,824 +0,0 @@
-/* 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
deleted file mode 100644
index ad66245..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/71/605b64bd93f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,33 +0,0 @@
-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
deleted file mode 100644
index 5cad65f..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/73/202199087af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,111 +0,0 @@
-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
deleted file mode 100644
index d5cebd7..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/75/008ba64293f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644
index ded6293..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/77/f048b41e97f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,41 +0,0 @@
-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
deleted file mode 100644
index 6b4e17a..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/78/20ff0f466ff2001013089cecc8a626ff
+++ /dev/null
@@ -1,71 +0,0 @@
-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
deleted file mode 100644
index 41fc0e2..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/79/80a9be6276f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index 2c3935c..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/7b/90342ca6a7f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,58 +0,0 @@
-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
deleted file mode 100644
index 8f5aac3..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/7e/60ef6ad577f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,82 +0,0 @@
-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
deleted file mode 100644
index 8067855..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/84/c0614a7670f2001013089cecc8a626ff
+++ /dev/null
@@ -1,74 +0,0 @@
-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
deleted file mode 100644
index 76bf08f..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/85/e011f3a7a7f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,59 +0,0 @@
-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
deleted file mode 100644
index 7387de2..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/86/609cf02c70f2001013089cecc8a626ff
+++ /dev/null
@@ -1,72 +0,0 @@
-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
deleted file mode 100644
index af44ef9..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/89/20c7b2636ef2001013089cecc8a626ff
+++ /dev/null
@@ -1,50 +0,0 @@
-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
deleted file mode 100644
index 2c3935c..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8a/00229f17a7f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,58 +0,0 @@
-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
deleted file mode 100644
index bcc6567..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8a/50abaff980f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index 880b9fc..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/8c/0007523691f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,29 +0,0 @@
-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
deleted file mode 100644
index 9b7cff9..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9/00ec0b5d76f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,51 +0,0 @@
-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
deleted file mode 100644
index fd3b3ff..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9/30082eba96f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,41 +0,0 @@
-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
deleted file mode 100644
index c330b9f..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/90/c051e5f079f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index bdcfe75..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/91/f0e9754a72f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,824 +0,0 @@
-/* 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
deleted file mode 100644
index c8a0e0d..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/94/00dbdc9893f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,60 +0,0 @@
-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
deleted file mode 100644
index 6a3816a..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/96/70f084bf9ef2001019c79f38f40e52ba
+++ /dev/null
@@ -1,45 +0,0 @@
-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
deleted file mode 100644
index 35efe72..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/97/f035184f7ff2001019c79f38f40e52ba
+++ /dev/null
@@ -1,113 +0,0 @@
-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
deleted file mode 100644
index d13bba4..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/98/a029fc1b9ef2001019c79f38f40e52ba
+++ /dev/null
@@ -1,43 +0,0 @@
-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
deleted file mode 100644
index cc96074..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9a/708a4064b9f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,823 +0,0 @@
-/* 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
deleted file mode 100644
index 03da125..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9b/c076e09f78f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,97 +0,0 @@
-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
deleted file mode 100644
index f3dad30..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9c/700748b079f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,111 +0,0 @@
-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
deleted file mode 100644
index 313faba..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/9e/60047c4d7af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,113 +0,0 @@
-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
deleted file mode 100644
index 0155a44..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a/f042c6c4a8f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index 013246f..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a0/d01cd48b7ef2001019c79f38f40e52ba
+++ /dev/null
@@ -1,53 +0,0 @@
-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
deleted file mode 100644
index ed872e8..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a2/608cf8de93f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,33 +0,0 @@
-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
deleted file mode 100644
index 1c32c2c..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a3/2097d8f194f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,32 +0,0 @@
-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
deleted file mode 100644
index 71c93a7..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a4/d04323d974f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,80 +0,0 @@
-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
deleted file mode 100644
index 776eb14..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a5/9036ba2395f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,33 +0,0 @@
-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
deleted file mode 100644
index 0b74597..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a7/704048c09ef2001019c79f38f40e52ba
+++ /dev/null
@@ -1,46 +0,0 @@
-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
deleted file mode 100644
index dceb4fb..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/a7/e0f402ec7ff2001019c79f38f40e52ba
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index 4e3aa65..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ab/90e8e32198f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,43 +0,0 @@
-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
deleted file mode 100644
index de99ce4..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ad/f034ed3493f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,55 +0,0 @@
-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
deleted file mode 100644
index 7d215d8..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/70572ccb93f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,33 +0,0 @@
-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
deleted file mode 100644
index d22ffbc..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/a01ff9a797f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644
index 6157a7d..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/af/d016566876f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,134 +0,0 @@
-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
deleted file mode 100644
index b9e0683..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b/5074d5f6a3f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,47 +0,0 @@
-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
deleted file mode 100644
index 948a1a3..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b/d010489ba2f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,46 +0,0 @@
-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
deleted file mode 100644
index 27290be..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b2/304fe0d6a4f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,195 +0,0 @@
-/* "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
deleted file mode 100644
index 695290d..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b4/1076a1137cf2001019c79f38f40e52ba
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index 4476f02..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b5/108e7d6a9ff2001019c79f38f40e52ba
+++ /dev/null
@@ -1,46 +0,0 @@
-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
deleted file mode 100644
index 64167f6..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b5/40650fe374f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,81 +0,0 @@
-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
deleted file mode 100644
index 3290a2b..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b8/e017b3e67ff2001019c79f38f40e52ba
+++ /dev/null
@@ -1,53 +0,0 @@
-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
deleted file mode 100644
index 4af8b45..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/b9/004bc24280f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index 0b59f38..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ba/409db4d5a0f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,13 +0,0 @@
-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
deleted file mode 100644
index 7de39d5..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ba/b06e730f7af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,112 +0,0 @@
-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
deleted file mode 100644
index 056ba58..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/bd/803ca2d3a7f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,60 +0,0 @@
-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
deleted file mode 100644
index 6b4e17a..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/bf/9074167f6df2001013089cecc8a626ff
+++ /dev/null
@@ -1,71 +0,0 @@
-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
deleted file mode 100644
index 157c568..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c/50d1292c6df2001013089cecc8a626ff
+++ /dev/null
@@ -1,71 +0,0 @@
-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
deleted file mode 100644
index f6db5b5..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c0/808dbdf172f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,76 +0,0 @@
-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
deleted file mode 100644
index fdf53e9..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c0/90c0377bb9f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,824 +0,0 @@
-/* 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
deleted file mode 100644
index 10dd70f..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c5/40a1b819a9f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index 446700d..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c7/8043f0f2a6f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644
index 48a93c2..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c8/d009dc3b70f2001013089cecc8a626ff
+++ /dev/null
@@ -1,73 +0,0 @@
-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/c9/f0b573ecfa6100111a83ded3e22caa93 b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c9/f0b573ecfa6100111a83ded3e22caa93
deleted file mode 100644
index 00ed944..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/c9/f0b573ecfa6100111a83ded3e22caa93
+++ /dev/null
@@ -1,824 +0,0 @@
-/* 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/ce/a04fca6b6ef2001013089cecc8a626ff b/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ce/a04fca6b6ef2001013089cecc8a626ff
deleted file mode 100644
index 54e5e40..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ce/a04fca6b6ef2001013089cecc8a626ff
+++ /dev/null
@@ -1,51 +0,0 @@
-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
deleted file mode 100644
index 67f7f65..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d0/70b06cf0a7f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,60 +0,0 @@
-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
deleted file mode 100644
index 90c5fbf..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d1/70d3bbca74f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,52 +0,0 @@
-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
deleted file mode 100644
index 5894499..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d3/20d9c4909af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index 8c8e835..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d3/e0c53cc672f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,74 +0,0 @@
-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
deleted file mode 100644
index cce9ff2..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d4/90921cb57cf2001019c79f38f40e52ba
+++ /dev/null
@@ -1,53 +0,0 @@
-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
deleted file mode 100644
index f4b03ae..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d4/f035b3eb79f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index 12a14fd..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/d5/50de5fb596f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,39 +0,0 @@
-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
deleted file mode 100644
index 227c3b8..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/db/105e2a299bf2001019c79f38f40e52ba
+++ /dev/null
@@ -1,136 +0,0 @@
-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
deleted file mode 100644
index 7aa34d6..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/db/206a23659af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index 300e840..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/dd/104bf38092f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,30 +0,0 @@
-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
deleted file mode 100644
index c080efe..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/de/a05b390195f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,33 +0,0 @@
-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
deleted file mode 100644
index 5218ef2..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e1/b038af7f9af2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index eaaf495..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e2/600de8ac96f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,38 +0,0 @@
-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
deleted file mode 100644
index a1ea642..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/e7/8045c3c879f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,111 +0,0 @@
-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
deleted file mode 100644
index 171bfc9..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ea/00ee7f5995f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,36 +0,0 @@
-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
deleted file mode 100644
index 9e8e766..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ec/809acae2b8f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,821 +0,0 @@
-/* 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
deleted file mode 100644
index 2e29928..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ed/e0b609eb76f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index 1a6ac96..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ef/30af64edb8f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,822 +0,0 @@
-/* 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
deleted file mode 100644
index ee214a7..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ef/b0389b949ef2001019c79f38f40e52ba
+++ /dev/null
@@ -1,44 +0,0 @@
-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
deleted file mode 100644
index 2b58e74..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f0/d0aaa69677f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,54 +0,0 @@
-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
deleted file mode 100644
index e291884..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f1/102a37d070f2001013089cecc8a626ff
+++ /dev/null
@@ -1,74 +0,0 @@
-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
deleted file mode 100644
index 0048b66..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f4/20a0f53292f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,30 +0,0 @@
-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
deleted file mode 100644
index 1a415f5..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f4/e0af8cb878f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,99 +0,0 @@
-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
deleted file mode 100644
index 7335a5b..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f6/9022b6e879f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index c6a7023..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f8/4038d97897f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,57 +0,0 @@
-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
deleted file mode 100644
index 7ab6681..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/f8/b0bf377270f2001013089cecc8a626ff
+++ /dev/null
@@ -1,73 +0,0 @@
-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
deleted file mode 100644
index 208d410..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fa/309e53f36ff2001013089cecc8a626ff
+++ /dev/null
@@ -1,71 +0,0 @@
-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
deleted file mode 100644
index d7a16ee..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fa/40273e0481f2001019c79f38f40e52ba
+++ /dev/null
@@ -1,135 +0,0 @@
-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
deleted file mode 100644
index 0ad91d1..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/fc/700191bfb9f100101fc6d5dee7f902b6
+++ /dev/null
@@ -1,824 +0,0 @@
-/* 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
deleted file mode 100644
index d6dbb86..0000000
--- a/Src/eclipse/.metadata/.plugins/org.eclipse.core.resources/.history/ff/e063106c6ff2001013089cecc8a626ff
+++ /dev/null
@@ -1,71 +0,0 @@
-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