Get CellId and other Imformation from mobile phones via J2ME

Without GPS or Network Operator we can still use the Location Based Service, via the help of CellId(Cell ID the location of Cell Identities of GSM-networks). Google has one enormous database of cell ids which are linked to a longitude and latitude position, that why Google Map client know where you are even you have no embedded GPS--it is not open. But there are other opened cellid DBs that we can use freely: opencellid , mobiforge.com and http://realtimeblog.free.fr/
Ok, one we can get the cell from phone we can query the location from these cellid DB. In GSM networks, all cells in the world have a globally unique ID made up of four numbers:
cell ID, LAC, MNC, and MCC.

For example, for Motorola:
Using JavaME to obtain Cell Positioning information

  
  1. {
  2. ….
  3. String cellid = System.getProperty("CellID");
  4. String lac = System.getProperty("LocAreaCode");
  5. String imsi = System.getProperty("IMSI");
  6. // Example IMSI (O2 UK): 234103530089555
  7. String mcc = imsi.substring(0,3); // 234 (UK)
  8. String mnc = imsi.substring(3,5); // 10 (O2)
  9. String location = mcc + mnc + lac + cellID; // A globally unique ID for a cell
  10. }

Information from Truly Mobile JavaME Applications: Location, Media Capture, and Connectivity

But get Cellid is still limited by mobile phone platform, Sign-certificate and Operator:

Nokia
s40 3rd Fp1 edition, requers operator or manufactureer signing
S60 3rd edition, FP2(released 2008 and newer, does not work on e.g. N95),no singing required

SonyEricsson:
Java platform 7.3 or higher (released around 2006 and newer)
older phone may need firmware update (7.1->7.3)
does not work in SE symbian (ie. UIQ) or windownsmobile(Xperia X1) phone
Information from Terminal-based Mobile Positioning overview

And notice, even you use the right code and sign your application, it is still not possible to query the cellID, because some telecom-operators have limited this service.

The fowllowing J2ME code could help you, J2ME Polish Syntax is used here to make the procedure easier. The functions here is not complete, because some manufactories have not released their J2ME API documents to query the cellID. If you have some information which is not included in the codes please let me and others know, please supplement here, thx!

  
  1. /**
  2. * get the cell id in the phone
  3. *
  4. * @return
  5. */
  6. public static String getCellId(){
  7. String out = "";
  8. try{
  9.  
  10. out = System.getProperty("Cell-ID");
  11. if(out== null || out.equals("null") || out.equals(""))
  12. out = System.getProperty("CellID");
  13. if(out== null ||out.equals("null")|| out.equals(""))
  14. System.getProperty("phone.cid");
  15. //#if polish.Vendor == Nokia
  16. if(out== null ||out.equals("null")|| out.equals(""))
  17. out = System.getProperty("com.nokia.mid.cellid");
  18. //#elif polish.Vendor == Sony-Ericsson
  19. if(out== null ||out.equals("null")|| out.equals(""))
  20. out = System.getProperty("com.sonyericsson.net.cellid");
  21. //#elif polish.Vendor == Motorola
  22. if(out== null ||out.equals("null")|| out.equals(""))
  23. out = System.getProperty("phone.cid");//System.getProperty("CellID");
  24. //#elif polish.Vendor == Samsung
  25. if(out== null ||out.equals("null")|| out.equals(""))
  26. out = System.getProperty("com.samsung.cellid");
  27. //#elif polish.Vendor == Siemens
  28. if(out== null ||out.equals("null")|| out.equals(""))
  29. out = System.getProperty("com.siemens.cellid");
  30. //#elif polish.Vendor == BlackBerry
  31. if(out== null ||out.equals("null")|| out.equals(""))
  32. //#= out = GPRSInfo.getCellInfo().getCellId();
  33. //#else
  34. if(out== null ||out.equals("null")|| out.equals(""))
  35. out = System.getProperty("cid");
  36. //#endif
  37.  
  38. }catch(Exception e){
  39. return out==null?"":out;
  40. }
  41.  
  42. return out==null?"":out;
  43. }
  44.  
  45. /**
  46. * get the lac sring from phone
  47. */
  48. public static String getLAC(){
  49. String out = "";
  50. try{
  51.  
  52. out = System.getProperty("phone.lac");
  53.  
  54. //#if polish.Vendor == Nokia
  55. if(out== null ||out.equals("null")|| out.equals(""))
  56. out = System.getProperty("com.nokia.mid.lac");
  57. //#elif polish.Vendor == Sony-Ericsson
  58. if(out== null ||out.equals("null")|| out.equals(""))
  59. out = System.getProperty("com.sonyericsson.net.lac");
  60. //#elif polish.Vendor == Motorola
  61. if(out== null ||out.equals("null")|| out.equals(""))
  62. out = System.getProperty("LocAreaCode");
  63. //#elif polish.Vendor == Samsung
  64. if(out== null ||out.equals("null")|| out.equals(""))
  65. out = System.getProperty("com.samsung.cellid");
  66. //#elif polish.Vendor == Siemens
  67. if(out== null ||out.equals("null")|| out.equals(""))
  68. out = System.getProperty("com.siemens.cellid");
  69. //#elif polish.Vendor == BlackBerry
  70. if(out== null ||out.equals("null")|| out.equals(""))
  71. //#= out = GPRSInfo.getCellInfo().getLAC();
  72. //#else
  73. if(out== null ||out.equals("null")|| out.equals(""))
  74. out = System.getProperty("cid");
  75. //#endif
  76.  
  77. }catch(Exception e){
  78. return out==null?"":out;
  79. }
  80.  
  81. return out==null?"":out;
  82. }
  83.  
  84. /**
  85. * Example IMSI (O2 UK): 234103530089555
  86. String mcc = imsi.substring(0,3); // 234 (UK)
  87. String mnc = imsi.substring(3,5); // 10 (O2)
  88. * @return
  89. */
  90. public static String getIMSI(){
  91. String out = "";
  92. try{
  93.  
  94. out = System.getProperty("IMSI");
  95. if(out== null ||out.equals("null")|| out.equals(""))
  96. out = System.getProperty("phone.imsi") ;
  97. //#if polish.Vendor == Nokia
  98. if(out== null ||out.equals("null")|| out.equals(""))
  99. out = System.getProperty("com.nokia.mid.mobinfo.IMSI");
  100. if(out== null ||out.equals("null")|| out.equals(""))
  101. out = System.getProperty("com.nokia.mid.imsi");
  102. //#elif polish.Vendor == Sony-Ericsson
  103. /* if(out== null ||out.equals("null")|| out.equals(""))
  104. out = System.getProperty("com.sonyericsson.imsi");*/
  105. //#elif polish.Vendor == Motorola
  106. if(out== null ||out.equals("null")|| out.equals(""))
  107. out = System.getProperty("IMSI");
  108. //#elif polish.Vendor == Samsung
  109. /* if(out== null ||out.equals("null")|| out.equals(""))
  110. out = System.getProperty("com.samsung.imei");*/
  111. //#elif polish.Vendor == Siemens
  112. /* if(out== null ||out.equals("null")|| out.equals(""))
  113. out = System.getProperty("com.siemens.imei");*/
  114. //#elif polish.Vendor == BlackBerry
  115. if(out== null ||out.equals("null")|| out.equals(""))
  116. //#= out = GPRSInfo.getCellInfo().getBSIC();
  117. //#else
  118. if(out== null ||out.equals("null")|| out.equals(""))
  119. out = System.getProperty("imsi");
  120. //#endif
  121.  
  122. }catch(Exception e){
  123. return out==null?"":out;
  124. }
  125.  
  126. return out==null?"":out;
  127. }
  128.  
  129. /**
  130. *
  131. * For moto, Example IMSI (O2 UK): 234103530089555
  132. String mcc = imsi.substring(0,3); // 234 (UK)
  133. * @return
  134. */
  135. public static String getMCC(){
  136. String out = "";
  137. try{
  138.  
  139. if(out== null ||out.equals("null")|| out.equals(""))
  140. out = System.getProperty("phone.mcc") ;
  141. //#if polish.Vendor == Nokia
  142. if(out== null ||out.equals("null")|| out.equals(""))
  143. //out = System.getProperty("com.nokia.mid.mobinfo.IMSI");
  144. //#elif polish.Vendor == Sony-Ericsson
  145. if(out== null ||out.equals("null")|| out.equals(""))
  146. out = System.getProperty("com.sonyericsson.net.mcc");
  147. //#elif polish.Vendor == Motorola
  148. if(out== null ||out.equals("null")|| out.equals("")){
  149. out = getIMSI().equals("")?"": getIMSI().substring(0,3);
  150. }
  151. //#elif polish.Vendor == Samsung
  152. /* if(out== null ||out.equals("null")|| out.equals(""))
  153. out = System.getProperty("com.samsung.imei");*/
  154. //#elif polish.Vendor == Siemens
  155. /* if(out== null ||out.equals("null")|| out.equals(""))
  156. out = System.getProperty("com.siemens.imei");*/
  157. //#elif polish.Vendor == BlackBerry
  158. if(out== null ||out.equals("null")|| out.equals(""))//getMNC()
  159. //#= out = GPRSInfo.getCellInfo().getMCC();
  160. //#else
  161. if(out== null ||out.equals("null")|| out.equals(""))
  162. out = System.getProperty("mcc");
  163. //#endif
  164.  
  165. }catch(Exception e){
  166. return out==null?"":out;
  167. }
  168.  
  169. return out==null?"":out;
  170. }
  171.  
  172. /**
  173. *
  174. * For moto, Example IMSI (O2 UK): 234103530089555
  175. String mnc = imsi.substring(3,5); // 10 (O2)
  176. * @return
  177. */
  178. public static String getMNC(){
  179. String out = "";
  180. try{
  181.  
  182. if(out== null ||out.equals("null")|| out.equals(""))
  183. out = System.getProperty("phone.mnc") ;
  184. //#if polish.Vendor == Nokia
  185. if(out== null ||out.equals("null")|| out.equals(""))
  186. out = getIMSI().equals("")?"": getIMSI().substring(3,5);
  187. //#elif polish.Vendor == Sony-Ericsson
  188. if(out== null ||out.equals("null")|| out.equals(""))
  189. out = System.getProperty("com.sonyericsson.net.mnc");
  190. //#elif polish.Vendor == Motorola
  191. if(out== null ||out.equals("null")|| out.equals("")){
  192. out = getIMSI().equals("")?"": getIMSI().substring(3,5);
  193. }
  194. //#elif polish.Vendor == Samsung
  195. /* if(out== null ||out.equals("null")|| out.equals(""))
  196. out = System.getProperty("com.samsung.imei");*/
  197. //#elif polish.Vendor == Siemens
  198. /* if(out== null ||out.equals("null")|| out.equals(""))
  199. out = System.getProperty("com.siemens.imei");*/
  200. //#elif polish.Vendor == BlackBerry
  201. if(out== null ||out.equals("null")|| out.equals(""))//getMNC()
  202. //#= out = GPRSInfo.getCellInfo().getMCC();
  203. //#else
  204. if(out== null ||out.equals("null")|| out.equals(""))
  205. out = System.getProperty("mnc");
  206. //#endif
  207.  
  208. }catch(Exception e){
  209. return out==null?"":out;
  210. }
  211.  
  212. return out==null?"":out;
  213. }
  214.  
  215. /**
  216. * not used now
  217. * get the IMEI (International Mobile Equipment Identity (IMEI)) in the phone
  218. *
  219. * @return
  220. */
  221. public static String getIMEI(){
  222. String out = "";
  223. try{
  224.  
  225. out = System.getProperty("com.imei");
  226. //#if polish.Vendor == Nokia
  227. if(out== null ||out.equals("null")|| out.equals(""))
  228. out = System.getProperty("phone.imei");
  229. if(out== null ||out.equals("null")|| out.equals(""))
  230. out = System.getProperty("com.nokia.IMEI");
  231. if(out== null ||out.equals("null")|| out.equals(""))
  232. out = System.getProperty("com.nokia.mid.imei");
  233. if(out== null ||out.equals("null")|| out.equals(""))
  234. out = System.getProperty("com.nokia.mid.imei");
  235. //#elif polish.Vendor == Sony-Ericsson
  236. if(out== null ||out.equals("null")|| out.equals(""))
  237. out = System.getProperty("com.sonyericsson.imei");
  238. //#elif polish.Vendor == Motorola
  239. if(out== null ||out.equals("null")|| out.equals(""))
  240. out = System.getProperty("IMEI");
  241. if(out== null ||out.equals("null")|| out.equals(""))
  242. out = System.getProperty("com.motorola.IMEI");
  243. //#elif polish.Vendor == Samsung
  244. if(out== null ||out.equals("null")|| out.equals(""))
  245. out = System.getProperty("com.samsung.imei");
  246. //#elif polish.Vendor == Siemens
  247. if(out== null ||out.equals("null")|| out.equals(""))
  248. out = System.getProperty("com.siemens.imei");
  249. //#else
  250. if(out== null ||out.equals("null")|| out.equals(""))
  251. out = System.getProperty("imei");
  252. //#endif
  253.  
  254. }catch(Exception e){
  255. return out==null?"":out;
  256. }
  257.  
  258. return out==null?"":out;
  259. }

Some J2ME applications are also available:
http://www.ottaky.com/midlets.php#netmon2
http://www.cellspotting.com/webpages/cellspotting.html

Ref:
http://en.wikipedia.org/wiki/GSM_localization
http://www.paxmodept.com/telesto/blogitem.htm?id=531
http://www.slideshare.net/jaakl/terminalbased-mobile-positioning-overview-presentation
http://www.ottaky.com/midlets.php#netmon2
http://www.cellspotting.com/webpages/cellspotting.html

原文出处:http://www.easywms.com/easywms/?q=zh-hant/node/3589

物联网通信协议测试是保障各类设备间实现可靠数据交互的核心环节。在众多适用于物联网的通信协议中,MQTT(消息队列遥测传输)以其设计简洁与低能耗的优势,获得了广泛应用。为确保MQTT客户端与服务端的实现严格遵循既定标准,并具备良好的互操作性,实施系统化的测试验证至关重要。 为此,采用TTCN-3(树表结合表示法第3版)这一国际标准化测试语言构建的自动化测试框架被引入。该语言擅长表达复杂的测试逻辑与数据结构,同时保持了代码的清晰度与可维护性。基于此框架开发的MQTT协议一致性验证套件,旨在自动化地检验MQTT实现是否完全符合协议规范,并验证其与Eclipse基金会及欧洲电信标准化协会(ETSI)所发布的相关标准的兼容性。这两个组织在物联网通信领域具有广泛影响力,其标准常被视为行业重要参考。 MQTT协议本身存在多个迭代版本,例如3.1、3.1.1以及功能更为丰富的5.0版。一套完备的测试工具必须能够覆盖对这些不同版本的验证,以确保基于各版本开发的设备与应用均能满足一致的质量与可靠性要求,这对于物联网生态的长期稳定运行具有基础性意义。 本资源包内包含核心测试框架文件、一份概述性介绍文档以及一份附加资源文档。这些材料共同提供了关于测试套件功能、应用方法及可能包含的扩展工具或示例的详细信息,旨在协助用户快速理解并部署该测试解决方案。 综上所述,一个基于TTCN-3的高效自动化测试框架,为执行全面、标准的MQTT协议一致性验证提供了理想的技术路径。通过此类专业测试套件,开发人员能够有效确保其MQTT实现的规范符合性与系统兼容性,从而为构建稳定、安全的物联网通信环境奠定坚实基础。 资源来源于网络分享,仅用于学习交流使用,请勿用于商业,如有侵权请联系我删除!
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值