//----------------------------------------------------------- // Misc. methods //----------------------------------------------------------- public ArrayList GetServiceList(eBTSVC eSvc) { int Cnt = 0; ArrayList SvcList = new ArrayList(); //Get list of svcs returned as 4-byte SvcID and 80-byte SvcName string IntPtr pList = BT_GetServiceList(DeviceAddr, eSvc, ref Cnt); IntPtr ptr = pList; //Create ArrayList of SvcListItems to return to callerfl for (int i = 0; i < Cnt; i++) { SvcListItem SvcItem = new SvcListItem(); SvcItem.eSvc = (eBTSVC)Marshal.ReadInt32(ptr); ptr = (IntPtr)((int)ptr + 4); SvcItem.SvcName = Marshal.PtrToStringUni(ptr); ptr = (IntPtr)((int)ptr + 160); SvcList.Add(SvcItem); } //Have to get DLL to do its own memory delete BT_DeleteServiceList(pList); return(SvcList); }
//--------------------------------------------------- // BtStack.SetSvcSecurityOptions //--------------------------------------------------- public eBTRC SetSvcSecurityOptions(eBTSVC eSvc, SvcSecOptions Opts) { eBTRC rc = BT_SetSvcSecurityOptions(eSvc, Opts.IsEnabled ? 1 : 0, Opts.IsAuthRequired ? 1 : 0, Opts.IsPINRequired ? 1 : 0, Opts.IsEncryptRequired ? 1 : 0); return(rc); }
//--------------------------------------------------- // BtStack.GetSvcSecurityOptions //--------------------------------------------------- public SvcSecOptions GetSvcSecurityOptions(eBTSVC eSvc) { SvcSecOptions Opts = new SvcSecOptions(); Int32 ia, ib, ic, id; BT_GetSvcSecurityOptions(eSvc, out ia, out ib, out ic, out id); Opts.IsEnabled = ia == 0 ? false : true; Opts.IsAuthRequired = ib == 0 ? false : true; Opts.IsPINRequired = ic == 0 ? false : true; Opts.IsEncryptRequired = id == 0 ? false : true; return(Opts); }
static extern eBTRC BT_SetSvcSecurityOptions(eBTSVC eSvc, Int32 IsEnabled, Int32 IsAuthRequired, Int32 IsPINRequired, Int32 IsEncryptRequired);
static extern void BT_GetSvcSecurityOptions(eBTSVC eSvc, out Int32 IsEnabled, out Int32 IsAuthRequired, out Int32 IsPINRequired, out Int32 IsEncryptRequired);
//--------------------------------------------------- // BtStack.SetSvcSecurityOptions //--------------------------------------------------- public eBTRC SetSvcSecurityOptions(eBTSVC eSvc, SvcSecOptions Opts) { eBTRC rc = BT_SetSvcSecurityOptions(eSvc, Opts.IsEnabled ? 1 : 0, Opts.IsAuthRequired ? 1 : 0, Opts.IsPINRequired ? 1 : 0, Opts.IsEncryptRequired ? 1 : 0); return rc; }
//--------------------------------------------------- // BtStack.GetSvcSecurityOptions //--------------------------------------------------- public SvcSecOptions GetSvcSecurityOptions(eBTSVC eSvc) { SvcSecOptions Opts = new SvcSecOptions(); Int32 ia, ib, ic, id; BT_GetSvcSecurityOptions(eSvc, out ia, out ib, out ic, out id); Opts.IsEnabled = ia==0 ? false : true; Opts.IsAuthRequired = ib==0 ? false : true; Opts.IsPINRequired = ic==0 ? false : true; Opts.IsEncryptRequired = id==0 ? false : true; return Opts; }
static extern IntPtr BT_GetServiceList(string DeviceAddr, eBTSVC eSvc, ref int Cnt);
//----------------------------------------------------------- // Misc. methods //----------------------------------------------------------- public ArrayList GetServiceList(eBTSVC eSvc) { int Cnt=0; ArrayList SvcList = new ArrayList(); //Get list of svcs returned as 4-byte SvcID and 80-byte SvcName string IntPtr pList = BT_GetServiceList(DeviceAddr, eSvc, ref Cnt); IntPtr ptr = pList; //Create ArrayList of SvcListItems to return to callerfl for (int i=0; i<Cnt; i++) { SvcListItem SvcItem = new SvcListItem(); SvcItem.eSvc = (eBTSVC) Marshal.ReadInt32(ptr); ptr = (IntPtr) ((int)ptr + 4); SvcItem.SvcName = Marshal.PtrToStringUni(ptr); ptr = (IntPtr) ((int)ptr + 160); SvcList.Add(SvcItem); } //Have to get DLL to do its own memory delete BT_DeleteServiceList(pList); return SvcList; }
private static string serviceTypeToString(eBTSVC svc) { string serviceType; switch (svc) { case eBTSVC.BTSVC_SENDFILE: serviceType = "FileTransfer"; break; case eBTSVC.BTSVC_GETBUSINESSCARD: serviceType = "BusCard"; break; case eBTSVC.BTSVC_EXCHANGECARDS: serviceType = "BusCard"; break; case eBTSVC.BTSVC_SENDBUSINESSCARD: serviceType = "BusCard"; break; case eBTSVC.BTSVC_SERIAL: serviceType = "SPP"; break; case eBTSVC.BTSVC_LAP: serviceType = "LAP"; break; case eBTSVC.BTSVC_DIALUP: serviceType = "DUN"; break; case eBTSVC.BTSVC_PANHOST: serviceType = "PAN Host"; break; case eBTSVC.BTSVC_PANUSER: serviceType = "PAN User"; break; default: serviceType = "Unknown"; break; } return serviceType; }