北斗手持机开发接口(北斗模块.doc

上传人:scccc 文档编号:14096397 上传时间:2022-02-01 格式:DOC 页数:9 大小:115KB
返回 下载 相关 举报
北斗手持机开发接口(北斗模块.doc_第1页
第1页 / 共9页
北斗手持机开发接口(北斗模块.doc_第2页
第2页 / 共9页
北斗手持机开发接口(北斗模块.doc_第3页
第3页 / 共9页
亲,该文档总共9页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《北斗手持机开发接口(北斗模块.doc》由会员分享,可在线阅读,更多相关《北斗手持机开发接口(北斗模块.doc(9页珍藏版)》请在三一文库上搜索。

1、北斗手持机函数接口说明1 北斗 1 代接口机制说明北斗短信接口主要是采用 android 的广播机制。2 北斗 1 代接口适用版本3 北斗 1 代接口函数说明3.1发送北斗信息android.intent.action.beidou.msg.sendBundle 数据: number : String 类型 北斗报文发送的目的卡号msgcontent : byte 类型,信息容。type : int 类型: 编码方式 0 混发1 汉字2 代码bitLen:int 类型 :报文有效数据位数 (bit 总数 )备注 :1.北斗 4.0 协议规中规定,北斗报文长度以 bit 计算。“传输方式”为代码

2、且“电文容”不满整字节,传输时在电文最后补“0”2.在“代码方式”发送和解码北斗报文时,需要注意实际有效的bit 位数是否是满字节不是满字节。示例代码:由于示例代码较长,请查考 app 源代码中 case R.id.btn_send 事件响应处理函数crcFlag : int 类型 校验位3.2接受北斗信息Bundle 数据:number : String 类型 报文发送方 msgcontent : byte 类型,信息容。msgtype : : int 类型 编码方式: 0 混发1 汉字android.intent.action.beidou.msg.received2 代码0 : 报文校验

3、正确1 : 报文校验错误bitLen 在 msgContent 中获取bitLen : 北斗报文中实际传输有效 bit 数 北斗报文解析步骤 :确定报文校验是否正确,再根据实际有效的数据长度 报文容。3.3请求读取北斗卡信息参数 :无示例代码 :private LocationManager mlocation; mlocation.sendExtraCommand(LocationManager.GPS_PROVIDER,request_bd_info, null); 备注 :详细见 app 工程中的源码的处理3.4请求获取北斗IC卡号android.intent.action.beidou

4、.msg.number.request备注 :此功能暂时未做3.5接受北斗 IC 号接收广播: android.intent.action.beidou.msg.number.receivedBundle 数据 ic_number : String 类型示例代码 :bundle = intent.getExtras();String number = bundle.getString(ic_number); tempStr = 北斗号 : + number; txt_sim_num_info.setText(tempStr);3.6短报文发送状态接受广播: android.intent.act

5、ion.beidou.feedbackinfo.received;Bundle 数据 : FeedBackTag : String 类型 FKXX 中返回的数据指令执行结果代码 (标准 4.0 协议的返 回)FeedBackExtraInfo: String 类型 FKXX 中附加信息详细使用方式见 :示例 app 源码中 ACTION_MSG_BD_FKXX_RECEIVED 事件的处理源码3.7北斗模块信息接受系统广播: android.intent.action.beidou.msg.bd.info.received Bundle 数据: service_frequency :服务频度c

6、ommunication_level:北斗卫星的通信等级number北斗模块 ICmodule_state :导航模块硬件信息1 仅有 GPS2 仅有北斗4 双模service_number :北斗服务中心version :北斗模块版本号3.8北斗功率请求android.intent.action.beidou.msg.bd.info.request_bd_power 参数 : 无示例代码 :A href= 手持终端 Intent powIntent = new Intent(ACTION_MSG_BD_POWER_INFO_REQUEST); sendBroadcast(powIntent)

7、;3.9北斗功率接收接受系统广播:android.intent.action.beidou.powerinfo.receivedBundle 数据 : m_p0 int 类型,波束 1 功率值m_p1 int 类型 m_p2 int 类型 m_p3 int 类型 m_p4 int 类型 m_p5 int 类型波束 2 功率值 波束 3 功率值 波束 4 功率值 波束 5 功率值 波束 6 功率值3.10允 许发送短信:允许发送消息:命令 bd_msg_enable Bundle bundle = new Bundle();bundle.putBoolean(op, enable);mlocat

8、ion.sendExtraCommand(LocationManager.GPS_PROVIDER, bd_msg_enable, bundle);获取允许发送北斗信息的接口:boolean msgEnable = Settings.System.getInt(getContentResolver(),BD_MSG_ENABLE, 1) 03.11设置服务中心:命令: set_service_numberBundle bundleSet = new Bundle();bundleSet.putString(set_service_number, edt_service_num.getText(

9、).toString() mlocation.sendExtraCommand(LocationManager.GPS_PROVIDER, set_service_number, bundleSet); 上述的接口的例子可见 TestBDReceiver 例子3.12定 位申请 (DWSQ)3.12.1申请发送广播: android.intent.action.beidou.msg.dwsq.requestBundle 参数 : A href= 手持机 freq Int 类型 定位频度 示例代码 :Intent dwIntent = new Intent(ACTION_MSG_BD_DWSQ_

10、REQUEST); / 申请一个 IntentBundle dwBundle = new Bundle();/ 申请 bundle60 分钟dwBundle.putInt(DWSQ_FREQ, freq); / 设置定位频度 0 单次定位。 根据北斗卡设置, 卡 , freq 请设置大于 60dwIntent.putExtras(dwBundle);/ 广播参数sendBroadcast(dwIntent);/ 启动定位申请3.12.2 定位信息接收 (DWXX)事件 : android.intent.action.beidou.msg.dwxx.receivedBundle 参数 : m_T

11、ype byte 类型 m_byHeightData short 类型 m_byHeightSymbol byte 类型 m_byHour int 类型 m_byMinute int 类型 m_bySecond1 int 类型 m_byLonDegree int 类型 m_byLonMinute int 类型 m_byLonSecond1 int 类型 m_byLonSecond2 int 类型 m_byLatDegree int 类型 m_byLatMinute int 类型 m_byLatSecond1 int 类型 m_byLatSecond2 int 类型高程值高程符号位 : 0 为正

12、 非零 为负 时间信息 : 小时 时间信息 :分钟时间信息 :秒经度信息 :度经度信息 : 分经度信息 :秒经度信息 : 小秒纬度信息 : 度纬度信息 : 分纬度信息 : 秒 纬度信息 : 小秒示例代码 : 由于示例代码较长,请参考 app 源码中ACTION_MSG_BD_DWXX_RECEIVED.equals(action) 事件处理的源代码3.13”北斗报文 ”中”获取坐标信息 ”使用 android.intent.action.beidou.msg.dwxx.received 示例代码 :hortm_byHeightData = bundle.getShort(m_byHeightD

13、ata);bytem_byHeightSymbol = bundle.getByte(m_byHeightSymbol)inttime_hour =(int)bundle.getByte(m_byHour);inttime_minute =bundle.getByte(m_byMinute);inttime_second =bundle.getByte(m_bySecond1);inttime_minsecond= bundle.getByte(m_bySecond2);intlonDegree =bundle.getByte(m_byLonDegree);intlonMinute =bund

14、le.getByte(m_byLonMinute);intlonSecond =bundle.getByte(m_byLonSecond1);intlonminSecond= bundle.getByte(m_byLonSecond2);intlatDegree =bundle.getByte(m_byLatDegree);intlatMinute =bundle.getByte(m_byLatMinute);intlatSecond =bundle.getByte(m_byLatSecond1);intlatminSecond= bundle.getByte(m_byLatSecond2);

15、3.14管 信注入 (ZBZR)请求 : android.intent.action.beidou.msg.gxzr.request参数 : GXZR_Content 类型 String 管信注入的管理信息 示例代码 :A href= 工业 PDA byte content = abcdefghabcdefghabcdefghabcdefgh.getBytes();Bundle gxbundle = new Bundle(); gxbundle.putByteArray(GXZR_Content, content); Intent gxIntent = new Intent(ACTION_MS

16、G_BD_GXZR_REQUEST); gxIntent.putExtras(gxbundle); sendBroadcast(gxIntent);3.15管 信读取 (GXDQ)请求 : android.intent.action.beidou.msg.gxdq.request 参数:无 示例代码 :Intent gxdqIntent = new Intent(ACTION_MSG_BD_GXDQ_REQUEST); sendBroadcast(gxdqIntent);3.16管 理信息 (GLXX)事件 : android.intent.action.beidou.msg.glxxInfo

17、.received参数: GLXXInfo类型 String 管理信息示例代码 :Bundle bundleglxx = intent.getExtras();byte glxxInfo = bundleglxx.getByteArray(GLXXInfo);3.17坐 标转换 (ZBZH)请求 : android.intent.action.beidou.msg.zbzh.request 参数 :ZBZH_LongitudeZBZH_Lat类型 String 类型 String经度数据纬度数据ZBZH_Heigth类型String高程值ZBZH_HeigthAnomaly类型String高程

18、异常值ZBZH_ChangeMode类型String坐标转换方式ZBZH_ChangeMode 取值: 0x01 表示将坐标转换为空间直角坐标,0x02 表示将坐标转换为高斯平面直角坐标,0x03 表示将坐标转换为麦卡托平面直角坐标示例代码 :byte Longitude = 12345678.getBytes();/ Longitude0对应经度数据中的 ”度”。/ Longitude1对应经度数据中的 ”分”。/ Longitude2对应经度数据中的 ”秒”。/ Longitude3对应经度数据中的 ”0.1秒”。byte Lat = 12345678.getBytes();/ Lat 0

19、对应纬度数据中的 ”度”。/ Lat 1对应纬度数据中的 ”分 ”。/ Lat 2对应纬度数据中的 ”秒 ”。/ Lat 3对应纬度数据中的 ”0.1秒”。int changeMode = 2;int height = 100;int heightAnomaly = 10;Bundle zbbundle = new Bundle();zbbundle.putByteArray(ZBZH_Longitude, Longitude); zbbundle.putByteArray(ZBZH_Lat, Lat);zbbundle.putInt(ZBZH_ChangeMode, changeMode);

20、zbbundle.putInt(ZBZH_Heigth, height); zbbundle.putInt(ZBZH_HeigthAnomaly, heightAnomaly); Intent zbIntent = new Intent(ACTION_MSG_BD_ZBZH_REQUEST); zbIntent.putExtras(zbbundle);sendBroadcast(zbIntent);备注 :在使用该接口时一定要保证经纬度信息中 “度”“分”秒”,”0.1秒”在数组中的对应位置 (参见示例代码中红色注释部分 )3.18坐 标输出 (ZBSC)事件 : android.intent

21、.action.beidou.msg.zbscInfo.received参数 : ZBSC_X类型StringZBSC_Y类型StringZBSC_Z类型StringZBSC_ChangeMode类型 String备注:ZBSC_ChangeMode =0x01.以空间直角坐标输出位置数据,ZBSC_X , ZBSC_Y ,ZBSC_Z为坐标ZBSC_ChangeMode =0x02. 以高斯平面直角坐标输出位置数据 ,此时ZBSC_X , ZBSC_Y为坐标,ZBSC_Z为高度值(int类型,带符号)ZBSC_ChangeMode =0x02. 以麦卡托平面直角坐标输出位置数据 ,此时ZBS

22、C_X , ZBSC_Y为坐标,ZBSC_Z为高度值(int类型,带符号)示例程序Bundle bundlezbsc = intent.getExtras(); int x = bundlezbsc.getInt(ZBSC_X); int y = bundlezbsc.getInt(ZBSC_Y); int z = bundlezbsc.getInt(ZBSC_Z);int changeMode = bundlezbsc.getInt(ZBSC_ChangeMode);4 北斗 2 代相关接口北斗 2 代的定位数据已经置到 android 自带 GPS 相关接口函数中。 通过请求 androi

23、d GPS 相关服务和调 用相关函数即可获取相关定位数据。 说明 : 在相关数据中,北斗卫星的编号为 160-197 ,GPS 卫星编号 为:0-324.1获取导航位置数据北斗导航系统设计之初就考虑了兼容现有的 android 地图和位置服务应用程序。故 导航编程接口和 google 位置服务编程接口几乎一样,只有稍许不同。以下代码片段例示了 如何通过 LocationManager 来获取北斗导航系统的位置信息。LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_

24、SERVICE);LocationListener locationListener = new LocationListener() / Define a listener that responds to location updatespublic void onLocationChanged(Location location) / Called when a new location is found by the gps location provider. makeUseOfNewLocation(location);public void onStatusChanged(Str

25、ing provider, int status, Bundle extras)public void onProviderEnabled(String provider) public void onProviderDisabled(String provider) ;/ Register the listener with the Location Manager to receive location updates locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationLis

26、tener);上述代码和 android 系统通过 GPS 导航是一致的。注意的是,北斗导航系统同样使用了 LocationManager.GPS_PROVIDER 。这是为了兼容于现有的 android 地图和位置服务程序。 北斗位置导航编程接口和 Android 的 GPS 导航接口是一样的。不同的地方在于GPS卫星和北斗卫星编号的不同,GPS卫星编号为1-32,现有的北斗卫星为 41-46 (或者160-197),以下代码片段例示了这种不同Overridepublic void onGpsStatusChanged(int event) GpsStatus gpsStatus = mLo

27、cationManager.getGpsStatus(null);case GpsStatus.GPS_EVENT_STARTED:mLocationManager.sendExtraCommand(LocationManager.GPS_PROVIDER, request_module_info, null);break;case GpsStatus.GPS_EVENT_STOPPED: break;case GpsStatus.GPS_EVENT_FIRST_FIX: break;case GpsStatus.GPS_EVENT_SATELLITE_STATUS: updateSatell

28、iteStatus(gpsStatus);break; default: break;private void updateSatelliteStatus(GpsStatus gpsStatus) / 更新卫星视图 int maxSatellites = gpsStatus.getMaxSatellites();/ Log.d(TAG , maxSatellites = + maxSatellites);Iterator statellites = gpsStatus.getSatellites() .iterator();int count = 0; mGpsStatusLayout.rem

29、oveAllViews(); mBdStatusLayout.removeAllViews();while (statellites.hasNext() & count = maxSatellites) GpsSatellite satellite = statellites.next();int number = satellite.getPrn(); if (number = 41 & number = 46) / for beidou SatelliteSNR bdSatellitesSNR = SatelliteSNR.fromXml( getContext(), mBdStatusL

30、ayout);bdSatellitesSNR.setSNR(satellite.getSnr(), number); mBdStatusLayout.addView(bdSatellitesSNR); count+;注意 : bd.device.version.1.3 版本, GPS 编号为: 1-32 , 北斗 1 的编号为 41-46 斗2实际的编号为1-32,但为了和GPS卫星作区分,系统会把北斗 2实际的卫星编号加 60,即系统上报的卫星编号为61 的卫星对应为北斗 2卫星编号为 1的卫星4.2获取系统北斗 2 状态LocationManager.GPS_PROVIDER ,参数为 : request_bd2_status示例: mlocation.sendExtraCommand(LocationManager.GPS_PROVIDER,request_bd2_status, null);接收广播: android.intent.action.beidou2.msg.status.received参数:bd2_status 类型 int 0 :关闭1:只开 GPS2:只开网络3:高精度,GPS,北斗,网络都打开4:只开北斗

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1