北斗手持机开发接口(北斗模块-2015.0421).doc_第1页
北斗手持机开发接口(北斗模块-2015.0421).doc_第2页
北斗手持机开发接口(北斗模块-2015.0421).doc_第3页
北斗手持机开发接口(北斗模块-2015.0421).doc_第4页
北斗手持机开发接口(北斗模块-2015.0421).doc_第5页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

北斗手持机函数接口说明1 北斗1代接口机制说明北斗短信接口主要是采用android的广播机制。2 北斗1代接口适用版本。 3 北斗1代接口函数说明3.1 发送北斗信息 ent.action.beidou.msg.sendBundle数据:number :String 类型 北斗报文发送的目的卡号 msgcontent : byte类型,信息内容。 type : int 类型: 编码方式 0 混发 1 汉字 2 代码 bitLen:int类型 :报文有效数据位数(bit总数)备注 :1.北斗4.0协议规范中规定,北斗报文长度以bit计算。“传输方式”为代码且“电文内容”不满整字节,传输时在电文最后补“0” 2.在“代码方式”发送和解码北斗报文时,需要注意实际有效的bit位数是否是满字节不是满字节。 示例代码: 由于示例代码较长,请查考app源代码中case R.id.btn_send事件响应处理函数 3.2 接受北斗信息 ent.action.beidou.msg.receivedBundle数据: number :String 类型 报文发送方号码 msgcontent :byte类型,信息内容。msgtype: :int 类型 编码方式: 0 混发 1 汉字 2 代码crcFlag :int 类型 校验位 0 :报文校验正确 1 :报文校验错误bitLen : 北斗报文中实际传输有效bit数 北斗报文解析步骤:确定报文校验是否正确,再根据实际有效的数据长度 bitLen 在msgContent中获取报文内容。3.3 请求读取北斗卡信息参数:无示例代码:private LocationManager mlocation; mlocation.sendExtraCommand(LocationManager.GPS_PROVIDER,request_bd_info, null); 备注:详细见app工程中的源码的处理3.4 请求获取北斗IC卡号ent.action.beidou.msg.number.request 备注:此功能暂时未做3.5 接受北斗IC 号接收广播:ent.action.beidou.msg.number.received Bundle数据 ic_number : String 类型示例代码: bundle = intent.getExtras();String number = bundle.getString(ic_number);tempStr = 北斗号: + number;txt_sim_num_info.setText(tempStr); 3.6 短报文发送状态接受广播:ent.action.beidou.feedbackinfo.received; Bundle数据 :FeedBackTag : String类型 FKXX中返回的数据指令执行结果代码(标准4.0协议的返回) FeedBackExtraInfo: String类型 FKXX中附加信息 详细使用方式见:示例app源码中ACTION_MSG_BD_FKXX_RECEIVED事件的处理源码 3.7 北斗模块信息 接受系统广播:.receivedBundle数据:service_frequency :服务频度 communication_level :北斗卫星的通信等级 number 北斗模块IC号码 module_state : 导航模块硬件信息 1仅有GPS 2 仅有北斗 4 双模service_number : 北斗服务中心号码version : 北斗模块版本号3.8 北斗功率请求.request_bd_power参数: 无示例代码:手持终端Intent powIntent = new Intent(ACTION_MSG_BD_POWER_INFO_REQUEST);sendBroadcast(powIntent);3.9 北斗功率接收 接受系统广播:ent.action.beidou.powerinfo.receivedBundle数据 :m_p0 int类型,波束1 功率值 m_p1 int类型 波束2 功率值 m_p2 int类型 波束3功率值 m_p3 int类型 波束4 功率值 m_p4 int类型 波束5 功率值 m_p5 int类型 波束6 功率值3.10 允许发送短信: 允许发送消息:命令 bd_msg_enableBundle bundle = new Bundle();bundle.putBoolean(op, enable); mlocation.sendExtraCommand(LocationManager.GPS_PROVIDER, bd_msg_enable, bundle); 获取允许发送北斗信息的接口:boolean msgEnable = Settings.System.getInt(getContentResolver(),BD_MSG_ENABLE, 1) 03.11 设置服务中心号码: 命令:set_service_number Bundle bundleSet = new Bundle();bundleSet.putString(set_service_number, edt_service_num.getText().toString()mlocation.sendExtraCommand(LocationManager.GPS_PROVIDER, set_service_number, bundleSet);上述的接口的例子可见TestBDReceiver 例子3.12 定位申请(DWSQ)3.12.1 申请发送广播:ent.action.beidou.msg.dwsq.requestBundle参数 :手持机freq Int类型 定位频度 示例代码: Intent dwIntent = new Intent(ACTION_MSG_BD_DWSQ_REQUEST); /申请一个 IntentBundle dwBundle = new Bundle(); /申请bundledwBundle.putInt(DWSQ_FREQ, freq); /设置定位频度 0 单次定位。 根据北斗卡设置,60分钟卡 ,freq请设置大于60dwIntent.putExtras(dwBundle); /广播参数sendBroadcast(dwIntent); /启动定位申请3.12.2 定位信息接收(DWXX)事件: ent.action.beidou.msg.dwxx.receivedBundle参数 : m_Type byte 类型 m_byHeightData short 类型 高程值 m_byHeightSymbol byte 类型 高程符号位: 0 为正 非零 为负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 类型 纬度信息: 小秒 示例代码: 由于示例代码较长,请参考app源码中 ACTION_MSG_BD_DWXX_RECEIVED.equals(action)事件处理的源代码3.13 ”北斗报文”中”获取坐标信息” 使用ent.action.beidou.msg.dwxx.received 示例代码:hortm_byHeightData=bundle.getShort(m_byHeightData);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=bundle.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); 3.14 管信注入(ZBZR) 请求: ent.action.beidou.msg.gxzr.request 参数: GXZR_Content 类型 String 管信注入的管理信息 示例代码:工业PDA byte content = abcdefghabcdefghabcdefghabcdefgh.getBytes(); Bundle gxbundle = new Bundle(); gxbundle.putByteArray(GXZR_Content, content); Intent gxIntent = new Intent(ACTION_MSG_BD_GXZR_REQUEST); gxIntent.putExtras(gxbundle); sendBroadcast(gxIntent);3.15 管信读取(GXDQ) 请求: ent.action.beidou.msg.gxdq.request 参数:无示例代码:Intent gxdqIntent = new Intent(ACTION_MSG_BD_GXDQ_REQUEST);sendBroadcast(gxdqIntent);3.16 管理信息(GLXX) 事件: ent.action.beidou.msg.glxxInfo.received参数: GLXXInfo 类型 String 管理信息示例代码: Bundle bundleglxx = intent.getExtras(); byte glxxInfo = bundleglxx.getByteArray(GLXXInfo);3.17 坐标转换(ZBZH) 请求: ent.action.beidou.msg.zbzh.request参数: ZBZH_Longitude 类型 String 经度数据 ZBZH_Lat 类型 String 纬度数据 ZBZH_Heigth 类型 String 高程值 ZBZH_HeigthAnomaly 类型 String 高程异常值 ZBZH_ChangeMode 类型 String 坐标转换方式 ZBZH_ChangeMode 取值: 0x01 表示将大地坐标转换为空间直角坐标, 0x02 表示将大地坐标转换为高斯平面直角坐标, 0x03 表示将大地坐标转换为麦卡托平面直角坐标 示例代码: byte Longitude = 12345678.getBytes(); / Longitude0 对应 经度数据中的”度”。 / Longitude1 对应 经度数据中的”分”。 / Longitude2 对应 经度数据中的”秒”。 / Longitude3 对应 经度数据中的”0.1秒”。byte Lat = 12345678.getBytes(); / Lat 0 对应 纬度数据中的”度”。 / 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);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) 事件: ent.action.beidou.msg.zbscInfo.received 参数: ZBSC_X 类型 String ZBSC_Y 类型 String ZBSC_Z 类型 String ZBSC_ChangeMode 类型 String 备注: ZBSC_ChangeMode =0x01. 以空间直角坐标输出位置数据, ZBSC_X , ZBSC_Y,ZBSC_Z为坐标 ZBSC_ChangeMode =0x02. 以高斯平面直角坐标输出位置数据, 此时ZBSC_X , ZBSC_Y为坐标, ZBSC_Z为高度值(int 类型,带符号) ZBSC_ChangeMode =0x02. 以麦卡托平面直角坐标输出位置数据, 此时ZBSC_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相关接口函数中。通过请求android GPS相关服务和调用相关函数即可获取相关定位数据。 说明: 在相关数据中,北斗卫星的编号为160-197 ,GPS卫星编号为:0-32 4.1 获取导航位置数据北斗导航系统设计之初就考虑了兼容现有的android地图和位置服务应用程序。故导航编程接口和google 位置服务编程接口几乎一样,只有稍许不同。以下代码片段例示了如何通过LocationManager来获取北斗导航系统的位置信息。LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);LocationListener locationListener = new LocationListener() / Define a listener that responds to location updates public void onLocationChanged(Location location) / Called when a new location is found by the gps location provider. makeUseOfNewLocation(location); public void onStatusChanged(String 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 updateslocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener); 上述代码和android系统通过GPS导航是一致的。注意的是,北斗导航系统同样使用了LocationManager.GPS_PROVIDER。这是为了兼容于现有的android地图和位置服务程序。北斗位置导航编程接口和Android的GPS导航接口是一样的。不同的地方在于GPS卫星和北斗卫星编号的不同, GPS卫星编号为1-32 , 现有的北斗卫星为41-46 (或者160-197) , 以下代码片段例示了这种不同Overridepublic void onGpsStatusChanged(int event) GpsStatus gpsStatus = mLocationManager.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:updateSatelliteStatus(gpsStatus);break;default:break;private void updateSatelliteStatus(GpsStatus gpsStatus) /更新卫星视图int maxSatellites = gpsStatus.getMaxSatellites();/ Log.d(TAG, maxSatellites = + maxSat

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论