|
I cannot use this program between 6230 and window xp. My computer has built-in infrared port, I try to choose COM3 to communicate, the result is invalid command, and then choose COM6, the result is Failed to write request to device.
I want to know how establish the infrared connection. Do the connection need CTS and RTS signals?
|
|
|
|
|
I'm try to communicate between pc and mobile but i haven't any documents about it, please help me.
Thanks you.
huynh dinh nhien
ITK25B-HUEUNIVERSITY-VIETNAM
|
|
|
|
|
Please help...
I have a mobile phone (sonyericsson z200) with infrared port; I also have a desktop pc with an inbuilt IRDA and windows xp as os. Now, I am made to understand that unless the infrared port on my phone aligns with the port my pc both devices won't be able to communicate with each other. My question is: how can I locate an infrared port on my cpu? I don't know if someone understands what I am trying to say? "Both the infrared port and infrared device on my pc seems to be ok but they can't communicate with each other" Or do I need an adapter?
Please you can >email answers to me obi-akpere@mailcity.com
Thanks so very much in advance for the help.
|
|
|
|
|
Hi,
first off just wanna say that that is a great piece of work there, really helped me a lot.. thanks man.
secondly, need some help with the list command. When i set AT+CMGL="REC UNREAD", but there are no unread messages, what response do i get?
Lastly, when i try to read more than 10 messages, the 10th messages seems to be weirdly formatted, as in i get an entire blank line. Do you know what the problem might be?
I am using a nokia 6100 series handset.
Thanks
|
|
|
|
|
Daniel, i found more information about the bluetooth connection in my WM2003 at
[HKEY_LOCAL_MACHINE\Drivers\BuiltIn]
it's not a problem to run your bluetooth virtual com using the 'BTC:' port.
but theres some problem while connecting with Toshiba device because that key is not exist.. i'm looking around and find interesting key at
[HKEY_LOCAL_MACHINE\SOFTWARE\TOSHIBA\Bluetooth\RFPortE7]
"Index"=dword:00000007
"DeviceArrayIndex"=dword:00000000
"Dll"="rfporte7.dll"
"Prefix"="COM"
"ResetDelay"=dword:00000300
"Order"=dword:00000003
"Active"=dword:00000002
"DevConfig"=dword:00000000
"DeviceType"=dword:00000000
"FriendlyName"="Bluetooth Telephony"
"Tsp"="Unimodem.dll"
so i try to connect with "COM7:" from my e830 and its not working... any suggestion why it's not working ?
Riki Risnandar
|
|
|
|
|
I'm trying to use your sample code to command my computer with a remote control but it doesn't work... Is it possible ?
My configration is the following:
IR port on computer (not on USB), i've installed ir2k drivers to emulate this IR port (existing) on COM3... But the commmunication between my remote control and the IR port doesn't seems to work, for sample I try to push on button on my remote control, I suppose there is an information wich is received by the IR port and should be interpreted by the program but the program doesn't seems to receive any information... Is that normal? Is wath I'm tryng ton do impossible?
Thanks for reading...
Vesta
|
|
|
|
|
i have an Infrared port that wont send information to my samsung mobile, it keeps saying that the mobile device activly refuses it, i was wondering if there was anything i was doing wrong, i have tried sending all different file types. Could the codes you have made help.
|
|
|
|
|
I just want to know how to link a mobile say alcatel(311,332)or
nokia(3315)with a desktop pc using a data cable. Please any suggestions or information on source codes or relevant sites
will be appreciated.
thanks!!!!!!!!!
|
|
|
|
|
What I remember Nokia uses its own protocol, but take a look at the open source project Gnokii for a closer look!
Regards,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
|
|
|
|
|
Hi,
The sample works very fine. But I have a question, if the connections is broken when function Read is called, ReadFile will block the application for ever. Is there any function can check the in-buffer size, before call ReadFile? I try to call ClearCommError to get the cbInQue size, but it returns 0 any time. Is ClearCommError supported by IrDA Comm port? And it seems WaitCommEvent is not supported by IrDA Comm Port?
Thanks,
Chris
|
|
|
|
|
There is no reason why WaitCommEvent should not be supported! You can try to change the timeout values:
<br />
<br />
COMMTIMEOUTS timeouts;<br />
<br />
VERIFY(GetCommTimeouts(m_hPort, &timeouts));<br />
<br />
timeouts.ReadIntervalTimeout = MAXDWORD;<br />
timeouts.ReadTotalTimeoutMultiplier = 0;<br />
timeouts.ReadTotalTimeoutConstant = 0;<br />
timeouts.WriteTotalTimeoutMultiplier = 100;<br />
timeouts.WriteTotalTimeoutConstant = 0;<br />
<br />
VERIFY(SetCommTimeouts(m_hPort, &timeouts));<br />
Regards,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
|
|
|
|
|
hi daniel. i try your nice ir class with bluetooth on Sony ericsson T610 and the connection is working but i have a trouble when connecting to ericsson R520m and SE T68i with the bluetooth, while using the IR is not a problem. as far as i know theres no differences between AT command t610 and t68i. is there any other way to connect to these phones? i'm using embedded visual c++ 4.0.
i also try to make a serial connection between my ipaq with these phones using bluetooth manager and it can connect each other.
|
|
|
|
|
Ok... try the following: Pair your Pocket PC and mobile phone with the bluetooth connection manager. After that create a simple virtual serial port connection, also with the bluetooth connection manager and use this com port in the original IrdaMobile application (without any changes). It should work!
Regards,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
|
|
|
|
|
yes it works. the process for creating the virtual port in T610 is automatically while the others dont use BTC. its the issue about bluetooth virtual port so i still searching the doc about activating that virtual port then connect it with the COM (not BTC). thanks daniel
|
|
|
|
|
Hi,
I'm working on an application in which I have to upload java games onto mobile handsets. What are the different methods of doing this?
Also what are the different parameters that I should consider while development (like handset types etc.)?
Regards,
B Vidyadhar Joshi.
|
|
|
|
|
|
Here is also some code I have written two years ago to send files from my Pocket PC to my Desktop PC and vise versa:
// IrObexDlg.h : header file
//
#if !defined(AFX_IROBEXDLG_H__7B1476C2_4204_4279_856C_E5F8CEF4ED2D__INCLUDED_)
#define AFX_IROBEXDLG_H__7B1476C2_4204_4279_856C_E5F8CEF4ED2D__INCLUDED_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include <af_irda.h> // need for IrSock functions
#include "MyProgressCtrl.h"
/////////////////////////////////////////////////////////////////////////////
// CIrObexDlg dialog
class CIrObexDlg : public CDialog
{
// Construction
public:
CIrObexDlg(IStream* pStream, const CString& strName,
const int nPacketSize = 1024, CWnd* pParent = NULL);
// Dialog Data
//{{AFX_DATA(CIrObexDlg)
enum { IDD = IDD_IROBEX };
CMyProgressCtrl m_prgProgress;
//}}AFX_DATA
// Class enumerations
public:
enum
{
EOk = 0,
EAbort,
EInvalidFileSize,
ENetwork,
ENoDeviceFound,
EServiceNotSupported,
EInvalidPacketSize,
EConnectFailed,
EObexConnectFailed,
EObexPutFailed,
EObexDisconnectFailed
};
// Attributes
public:
static const int MAX_NAME_LENGTH; // maximale Länge des Dateinamen
static const int MIN_PACKET_SIZE; // minimale Packetlänge
static const int MAX_PACKET_SIZE; // maximale Packetlänge
// Operations
public:
static const CString GetErrorMessage(int nError);
// Internal attributes
private:
static const UINT MY_WM_TEXT_STATUS;
static const UINT MY_WM_PROG_STATUS;
static const UINT MY_WM_END;
CBrush m_brBackground;
volatile SOCKET m_socket;
volatile bool m_bAbort;
CWinThread* m_pSendDataThread;
const int m_nPacketSize;
int m_nDataSize;
IStream* m_pStream;
const CString m_strName;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CIrObexDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
static UINT SendData(LPVOID pParam);
void SendData();
bool Send(const char* pData, int nLength);
bool Receive(char* pData, int nLength);
bool RecvOpt(int nLength);
bool Connect();
bool Disconnect();
bool Put();
// Generated message map functions
//{{AFX_MSG(CIrObexDlg)
virtual BOOL OnInitDialog();
afx_msg void OnClose();
afx_msg void OnDestroy();
afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor);
afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);
afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
//}}AFX_MSG
afx_msg LRESULT OnTextStatus(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnProgStatus(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnEnd(WPARAM wParam, LPARAM lParam);
afx_msg void OnRecognizeGesture(NMHDR* pNMHDR, LRESULT* pResult);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_IROBEXDLG_H__7B1476C2_4204_4279_856C_E5F8CEF4ED2D__INCLUDED_)
// IrObexDlg.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "IrObexDlg.h"
#include "LogFile.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CIrObexDlg defines
#ifndef SD_BOTH
#define SD_BOTH 0x02 // need for "shutdown" socket function
#endif // SD_BOTH
/////////////////////////////////////////////////////////////////////////////
// CIrObexDlg constants and static variables
static const BYTE OBEX_CONNECT = 0x80;
static const BYTE OBEX_DISCONNECT = 0x81;
static const BYTE OBEX_VERSION = 0x10;
static const BYTE OBEX_CONNECT_FLAGS = 0x00;
static const BYTE OBEX_SUCCESS = 0xA0;
static const BYTE OBEX_CONTINUE = 0x90;
static const BYTE OBEX_PUT = 0x02;
static const BYTE OBEX_PUT_FINAL = 0x82;
static const BYTE OBEX_NAME = 0x01;
static const BYTE OBEX_LENGTH = 0xC3;
static const BYTE OBEX_BODY = 0x48;
static const BYTE OBEX_END_OF_BODY = 0x49;
static const int MAX_CLIENT_PACKET_SIZE = 1024;
static const DWORD TIMEOUT = 10000; // 10 seconds timeout
enum
{
ESocket = 0,
EFindDevice,
EVerifyService,
EConnect,
EObexConnect,
EObexPut,
EObexDisconnect,
EReady
};
static LPCTSTR ERROR_MESSAGES[] =
{
_T("Übertragung erfolgreich beendet."), // EOk
_T("Abbruch durch Benutzer."), // EAbort
_T("Datei überschreitet die maximale Grösse."), // EInvalidFileSize
_T("Undefinierter Netzwerkfehler."), // ENetwork
_T("Kein kompatibles Gerät gefunden."), // ENoDeviceFound
_T("OBEX Service wird nicht unterstützt."), // EServiceNotSupported
_T("Ungültige Packetgrösse."), // EInvalidPacketSize
_T("IrDA Verbindungsaufbau fehlgeschlagen."), // EConnectFailed
_T("OBEX Verbindung fehlgeschlagen."), // EObexConnectFailed
_T("OBEX Datentransfer fehlgeschlagen."), // EObexPutFailed
_T("OBEX Trennung fehlgeschlagen.") // EObexDisconnectFailed
};
static LPCTSTR STATUS_MESSAGES[] =
{
_T("Socket Verbindung aufbauen..."), // ESocket
_T("Suche nach kompatiblen Geräten..."), // EFindDevice
_T("Überprüfe OBEX Service..."), // EVerifyService
_T("IrDA Verbindung aufbauen..."), // EConnect
_T("Verbindungsaufbau zu OBEX Server..."), // EObexConnect
_T("Daten werden übertragen..."), // EObexPut
_T("Von OBEX Server trennen..."), // EObexDisconnect
_T("Übertragung beendet."), // EReady
};
/////////////////////////////////////////////////////////////////////////////
// CIrObexDlg constants
const int CIrObexDlg::MAX_NAME_LENGTH = 20;
const int CIrObexDlg::MIN_PACKET_SIZE = 255;
const int CIrObexDlg::MAX_PACKET_SIZE = 65535; // 64K bytes - 1
/////////////////////////////////////////////////////////////////////////////
// CIrObexDlg dialog
CIrObexDlg::CIrObexDlg(IStream* pStream, const CString& strName,
const int nPacketSize /*= 1024*/, CWnd* pParent /*= NULL*/)
: CDialog(CIrObexDlg::IDD, pParent),
m_socket(INVALID_SOCKET),
m_bAbort(false),
m_pSendDataThread(NULL),
m_nPacketSize(nPacketSize),
m_nDataSize(0),
m_pStream(pStream),
m_strName(strName.Left(MAX_NAME_LENGTH))
{
// Check pre-conditions
ASSERT(m_pStream != NULL);
ASSERT(AfxIsValidString(m_strName));
ASSERT(m_strName.GetLength() > 0);
ASSERT(m_strName.GetLength() <= MAX_NAME_LENGTH);
ASSERT(m_nPacketSize >= MIN_PACKET_SIZE);
ASSERT(m_nPacketSize <= MAX_PACKET_SIZE);
//{{AFX_DATA_INIT(CIrObexDlg)
//}}AFX_DATA_INIT
VERIFY(m_brBackground.CreateSysColorBrush(COLOR_BTNFACE));
m_bFullScreen = FALSE;
}
void CIrObexDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CIrObexDlg)
DDX_Control(pDX, IDC_IROBEX_PROGRESS, m_prgProgress);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
// Message table
const UINT CIrObexDlg::MY_WM_TEXT_STATUS =
RegisterWindowMessage(_T("MY_WM_TEXT_STATUS-{72472B44-7554-11d7-9AA6-0002B32C4875}"));
const UINT CIrObexDlg::MY_WM_PROG_STATUS =
RegisterWindowMessage(_T("MY_WM_PROG_STATUS-{72472B46-7554-11d7-9AA6-0002B32C4875}"));
const UINT CIrObexDlg::MY_WM_END =
RegisterWindowMessage(_T("MY_WM_END-{72472B49-7554-11d7-9AA6-0002B32C4875}"));
BEGIN_MESSAGE_MAP(CIrObexDlg, CDialog)
//{{AFX_MSG_MAP(CIrObexDlg)
ON_WM_CLOSE()
ON_WM_DESTROY()
ON_WM_CTLCOLOR()
ON_WM_ACTIVATE()
ON_WM_SETTINGCHANGE()
//}}AFX_MSG_MAP
ON_REGISTERED_MESSAGE(MY_WM_TEXT_STATUS, OnTextStatus)
ON_REGISTERED_MESSAGE(MY_WM_PROG_STATUS, OnProgStatus)
ON_REGISTERED_MESSAGE(MY_WM_END, OnEnd)
// NM_RECOGNIZEGESTURE for PocketPC 2002
ON_NOTIFY_REFLECT((NM_FIRST-16), OnRecognizeGesture)
// NM_RECOGNIZEGESTURE for PocketPC 2003
ON_NOTIFY_REFLECT((NM_FIRST-50), OnRecognizeGesture)
ON_WM_LBUTTONDOWN()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIrObexDlg message handlers
BOOL CIrObexDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// Get the size of the stream
STATSTG stg;
VERIFY(m_pStream->Stat(&stg, STATFLAG_NONAME) == S_OK);
if (stg.cbSize.HighPart > 0 || stg.cbSize.LowPart <= 0)
{
LOGERROR(_T("Invalid file size (%I64d bytes)."),
stg.cbSize.QuadPart);
EndDialog(EInvalidFileSize);
}
else
{
// Save the size of the stream
m_nDataSize = stg.cbSize.LowPart;
// Set the properties of the progress bar
m_prgProgress.SetRange32(0, m_nDataSize);
m_prgProgress.SetPos(0);
// Initialize Winsock
WSADATA wsaData;
const int nError = WSAStartup(MAKEWORD(2,0), &wsaData);
if (nError != 0)
{
LOGERROR(_T("The function \"WSAStartup\" failed; ")\
_T("error = %d. Could't start network service."),
nError);
EndDialog(ENetwork);
}
else
{
// Create the thread and start it
m_pSendDataThread = AfxBeginThread(SendData, this, THREAD_PRIORITY_NORMAL,
0, CREATE_SUSPENDED);
ASSERT(m_pSendDataThread != NULL);
ASSERT(AfxIsValidAddress(m_pSendDataThread, sizeof(CWinThread), TRUE));
ASSERT_VALID(m_pSendDataThread);
m_pSendDataThread->m_bAutoDelete = FALSE;
LOGNOTIFY(_T("OBEX transmission thread started successfully."));
m_pSendDataThread->ResumeThread(); // start the thread
}
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CIrObexDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
m_bAbort = true; // abort the transmission process
EndDialog(EAbort);
LOGNOTIFY(_T("Abort the OBEX transmission process."));
// CDialog::OnClose();
}
void CIrObexDlg::OnDestroy()
{
// TODO: Add your message handler code here
if (m_pSendDataThread != NULL)
{
// Shutdown and close the socket
if (m_socket != INVALID_SOCKET)
{
shutdown(m_socket,SD_BOTH);
closesocket(m_socket);
}
// Wait until the thread is terminated
WaitForSingleObject(m_pSendDataThread->m_hThread, INFINITE);
delete m_pSendDataThread;
m_pSendDataThread = NULL;
WSACleanup();
LOGNOTIFY(_T("OBEX transmission process terminated normaly."));
}
CDialog::OnDestroy();
}
HBRUSH CIrObexDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
if (nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetBkMode(TRANSPARENT);
return m_brBackground;
}
else if (pWnd == this)
{
return m_brBackground;
}
return hbr;
}
void CIrObexDlg::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CWnd::OnActivate(nState, pWndOther, bMinimized);
}
void CIrObexDlg::OnSettingChange(UINT uFlags, LPCTSTR lpszSection)
{
CWnd::OnSettingChange(uFlags, lpszSection);
}
void CIrObexDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
Default(); // call default message handler
}
void CIrObexDlg::OnRecognizeGesture(NMHDR* pNMHDR, LRESULT* pResult)
{
*pResult = TRUE; // cancel the red dot animation
}
LRESULT CIrObexDlg::OnTextStatus(WPARAM wParam, LPARAM lParam)
{
ASSERT(wParam >= 0 && wParam < _countof(STATUS_MESSAGES));
SetDlgItemText(IDC_IROBEX_STATUS, STATUS_MESSAGES[wParam]);
return 0L;
}
LRESULT CIrObexDlg::OnProgStatus(WPARAM wParam, LPARAM lParam)
{
const int nPos = static_cast<int>(wParam);
ASSERT(nPos >= 0 && nPos <= m_nDataSize);
m_prgProgress.SetPos(nPos);
return 0L;
}
LRESULT CIrObexDlg::OnEnd(WPARAM wParam, LPARAM lParam)
{
if (!m_bAbort)
EndDialog(wParam);
return 0L;
}
UINT CIrObexDlg::SendData(LPVOID pParam)
{
CIrObexDlg* pDialog = reinterpret_cast<CIrObexDlg*>(pParam);
ASSERT(pDialog != NULL); // don't use ASSERT_VALID here!
ASSERT(AfxIsValidAddress(pDialog, sizeof(CIrObexDlg), TRUE));
if (pDialog)
pDialog->SendData(); // send the data to the server (host)
return 0;
}
void CIrObexDlg::SendData()
{
// Set the seek pointer to the beginning of the stream
LARGE_INTEGER pos;
pos.QuadPart = 0;
VERIFY(m_pStream->Seek(pos, STREAM_SEEK_SET, NULL) == S_OK);
// Open socket
PostMessage(MY_WM_TEXT_STATUS, ESocket);
m_socket = socket(AF_IRDA, SOCK_STREAM, 0);
if (m_socket == INVALID_SOCKET)
{
LOGERROR(_T("The function \"socket\" failed; error = %d. ")\
_T("Could't start network service."), WSAGetLastError());
PostMessage(MY_WM_END, ENetwork);
return;
}
// Try several times to find a device
PostMessage(MY_WM_TEXT_STATUS, EFindDevice);
DEVICELIST deviceList = {0};
DWORD dwStart = GetTickCount();
for (;;)
{
if (GetTickCount() - dwStart >= TIMEOUT)
break;
int cbDevices = sizeof(deviceList);
// Obtain the available devices
deviceList.numDevice = 0;
if (getsockopt(m_socket, SOL_IRLMP, IRLMP_ENUMDEVICES,
reinterpret_cast<char*>(&deviceList), &cbDevices) == SOCKET_ERROR)
{
LOGERROR(_T("The function \"getsockopt\" failed; error = %d. ")\
_T("Could't obtain the available devices."), WSAGetLastError());
PostMessage(MY_WM_END, ENetwork);
return;
}
// Abort if we have found a device
if (deviceList.numDevice > 0)
break;
// Wait
::Sleep(100);
} // for (;;)
// Check if all retries have been finished
if (deviceList.numDevice == 0)
{
LOGWARNING(_T("No IrDA device found."));
PostMessage(MY_WM_END, ENoDeviceFound);
return;
}
LOGNOTIFY(_T("IrDA device found; device identifier: %02x.%02x.%02x.%02x"),
deviceList.Device[0].irdaDeviceID[0],
deviceList.Device[0].irdaDeviceID[1],
deviceList.Device[0].irdaDeviceID[2],
deviceList.Device[0].irdaDeviceID[3]);
// Try several times to verify the OBEX service
PostMessage(MY_WM_TEXT_STATUS, EVerifyService);
IAS_QUERY iasq = {0};
memset(&iasq, 0, sizeof(iasq));
memcpy(iasq.irdaDeviceID, deviceList.Device[0].irdaDeviceID, sizeof(iasq.irdaDeviceID));
strcpy(iasq.irdaClassName, "OBEX");
strcpy(iasq.irdaAttribName, "IrDA:TinyTP:LsapSel");
int iasqlen = sizeof(iasq);
dwStart = GetTickCount();
for (;;)
{
if (GetTickCount() - dwStart >= TIMEOUT)
{
LOGERROR(_T("Could't verify the OBEX service."));
PostMessage(MY_WM_END, ENetwork);
return;
}
// Do the query for the OBEX service
if (getsockopt(m_socket, SOL_IRLMP, IRLMP_IAS_QUERY,
reinterpret_cast<char*>(&iasq), &iasqlen) == SOCKET_ERROR)
{
LOGWARNING(_T("The function \"getsockopt\" failed; error = %d."),
WSAGetLastError());
}
else
{
break;
}
// Wait
::Sleep(100);
} // for (;;)
// Check the query result
if (iasq.irdaAttribType == IAS_ATTRIB_NO_CLASS || // Class not found?
iasq.irdaAttribType == IAS_ATTRIB_NO_ATTRIB) // Attribute not found?
{
LOGWARNING(_T("OBEX service not supported."));
PostMessage(MY_WM_END, EServiceNotSupported);
return;
}
// Try to connect to the server
PostMessage(MY_WM_TEXT_STATUS, EConnect);
SOCKADDR_IRDA sa = {0};
// Setup the IrDA address
sa.irdaAddressFamily = AF_IRDA;
sprintf(sa.irdaServiceName, "LSAP-SEL%d", iasq.irdaAttribute.irdaAttribInt);
memcpy(sa.irdaDeviceID, deviceList.Device[0].irdaDeviceID, sizeof(sa.irdaDeviceID));
// Do the connect to the OBEX server
if (connect(m_socket, reinterpret_cast<SOCKADDR*>(&sa), sizeof(sa)) == SOCKET_ERROR)
{
LOGERROR(_T("The function \"connect\" failed; error = %d. ")\
_T("Connect to founded device failed."), WSAGetLastError());
PostMessage(MY_WM_END, EConnectFailed);
return;
}
ASSERT(m_socket != INVALID_SOCKET);
// Send the OBEX connect request
PostMessage(MY_WM_TEXT_STATUS, EObexConnect);
if (!Connect())
return;
// Send the OBEX put request with the data
PostMessage(MY_WM_TEXT_STATUS, EObexPut);
if (!Put())
return;
// Send the OBEX disconnect request
PostMessage(MY_WM_TEXT_STATUS, EObexDisconnect);
if (!Disconnect())
return;
// Send READY message to the dialog
PostMessage(MY_WM_TEXT_STATUS, EReady);
PostMessage(MY_WM_END, EOk);
}
bool CIrObexDlg::Connect()
{
ASSERT(m_socket != INVALID_SOCKET);
// Create the client request
BYTE request[7] = {0};
request[0] = OBEX_CONNECT;
request[1] = static_cast<BYTE>((htons(7) & 0x00FF) >> 0);
request[2] = static_cast<BYTE>((htons(7) & 0xFF00) >> 8);
request[3] = OBEX_VERSION;
request[4] = OBEX_CONNECT_FLAGS;
request[5] = static_cast<BYTE>((htons(MAX_CLIENT_PACKET_SIZE) & 0x00FF) >> 0);
request[6] = static_cast<BYTE>((htons(MAX_CLIENT_PACKET_SIZE) & 0xFF00) >> 8);
// Send the client request
if (!Send(reinterpret_cast<const char*>(request), sizeof(request)))
{
PostMessage(MY_WM_END, EObexConnectFailed);
return false;
}
// Read the response code
BYTE response = 0;
if (!Receive(reinterpret_cast<char*>(&response), sizeof(response)))
{
PostMessage(MY_WM_END, EObexConnectFailed);
return false;
}
// Check the response code
if (response != OBEX_SUCCESS)
{
PostMessage(MY_WM_END, EObexConnectFailed);
return false;
}
// Read the packet length
WORD packetLength = 0;
if (!Receive(reinterpret_cast<char*>(&packetLength), sizeof(packetLength)))
{
PostMessage(MY_WM_END, EObexConnectFailed);
return false;
}
packetLength = ntohs(packetLength);
// Check the packet length
if (packetLength < 7)
{
PostMessage(MY_WM_END, EObexConnectFailed);
return false;
}
// Read the OBEX version number
BYTE version = 0;
if (!Receive(reinterpret_cast<char*>(&version), sizeof(version)))
{
PostMessage(MY_WM_END, EObexConnectFailed);
return false;
}
// Read the connect flags
BYTE flags = 0;
if (!Receive(reinterpret_cast<char*>(&flags), sizeof(flags)))
{
PostMessage(MY_WM_END, EObexConnectFailed);
return false;
}
// Read the maximum OBEX packet length
WORD maxPacketLength = 0;
if (!Receive(reinterpret_cast<char*>(&maxPacketLength), sizeof(maxPacketLength)))
{
PostMessage(MY_WM_END, EObexConnectFailed);
return false;
}
maxPacketLength = ntohs(maxPacketLength);
// Check the maximum packet size that the server can accept
if (m_nPacketSize > static_cast<int>(maxPacketLength))
{
PostMessage(MY_WM_END, EInvalidPacketSize);
return false;
}
// Read the optional headers
if (!RecvOpt(packetLength - 7))
{
PostMessage(MY_WM_END, EObexConnectFailed);
return false;
}
return true;
}
bool CIrObexDlg::Disconnect()
{
ASSERT(m_socket != INVALID_SOCKET);
// Create the client request
BYTE request[3] = {0};
request[0] = OBEX_DISCONNECT;
request[1] = static_cast<BYTE>((htons(3) & 0x00FF) >> 0);
request[2] = static_cast<BYTE>((htons(3) & 0xFF00) >> 8);
// Send the client request
if (!Send(reinterpret_cast<const char*>(request), sizeof(request)))
{
PostMessage(MY_WM_END, EObexDisconnectFailed);
return false;
}
// Read the response code
BYTE response = 0;
if (!Receive(reinterpret_cast<char*>(&response), sizeof(response)))
{
PostMessage(MY_WM_END, EObexDisconnectFailed);
return false;
}
// Check the response code
if (response != OBEX_SUCCESS)
{
PostMessage(MY_WM_END, EObexDisconnectFailed);
return false;
}
// Read the packet length
WORD packetLength = 0;
if (!Receive(reinterpret_cast<char*>(&packetLength), sizeof(packetLength)))
{
PostMessage(MY_WM_END, EObexDisconnectFailed);
return false;
}
packetLength = ntohs(packetLength);
// Check the packet length
if (packetLength < 3)
{
PostMessage(MY_WM_END, EObexDisconnectFailed);
return false;
}
// Read the optional headers
if (!RecvOpt(packetLength - 3))
{
PostMessage(MY_WM_END, EObexDisconnectFailed);
return false;
}
return true;
}
bool CIrObexDlg::Put()
{
// Check pre-conditions
ASSERT(m_socket != INVALID_SOCKET);
ASSERT(m_nDataSize > 0);
ASSERT(AfxIsValidString(m_strName));
ASSERT(m_strName.GetLength() > 0);
ASSERT(m_strName.GetLength() <= MAX_NAME_LENGTH);
ASSERT(m_nPacketSize >= MIN_PACKET_SIZE);
ASSERT(m_nPacketSize <= MAX_PACKET_SIZE);
// Create some temporary variables
int dataSize = m_nDataSize;
CTtoW lpwszName(m_strName); // convert string from TCHAR to WCHAR
LPBYTE request = new BYTE[m_nPacketSize];
ASSERT(request != NULL);
ASSERT(AfxIsValidAddress(request, sizeof(BYTE) * m_nPacketSize, TRUE));
// Some calculations
int namelen = (lpwszName.GetLength() + 1) * sizeof(WCHAR);
int restlen = m_nPacketSize - (14 + namelen);
int bodlen = dataSize > restlen ? restlen : dataSize;
// Create the client request
request[0] = (dataSize - bodlen) > 0 ? OBEX_PUT : OBEX_PUT_FINAL;
request[1] = static_cast<BYTE>((htons(bodlen + 14 + namelen) & 0x00FF) >> 0);
request[2] = static_cast<BYTE>((htons(bodlen + 14 + namelen) & 0xFF00) >> 8);
request[3] = OBEX_NAME;
request[4] = static_cast<BYTE>((htons(namelen + 3) & 0x00FF) >> 0);
request[5] = static_cast<BYTE>((htons(namelen + 3) & 0xFF00) >> 8);
for (unsigned int n = 0; n < lpwszName.GetLength() + 1; ++n)
{
request[6 + n * 2 + 0] = static_cast<BYTE>((htons(lpwszName[n]) & 0x00FF) >> 0);
request[6 + n * 2 + 1] = static_cast<BYTE>((htons(lpwszName[n]) & 0xFF00) >> 8);
}
request[6 + namelen + 0] = OBEX_LENGTH;
request[6 + namelen + 1] = static_cast<BYTE>((htonl(dataSize) & 0x000000FF) >> 0);
request[6 + namelen + 2] = static_cast<BYTE>((htonl(dataSize) & 0x0000FF00) >> 8);
request[6 + namelen + 3] = static_cast<BYTE>((htonl(dataSize) & 0x00FF0000) >> 16);
request[6 + namelen + 4] = static_cast<BYTE>((htonl(dataSize) & 0xFF000000) >> 24);
request[6 + namelen + 5] = (dataSize - bodlen) > 0 ? OBEX_BODY : OBEX_END_OF_BODY;
request[6 + namelen + 6] = static_cast<BYTE>((htons(bodlen + 3) & 0x00FF) >> 0);
request[6 + namelen + 7] = static_cast<BYTE>((htons(bodlen + 3) & 0xFF00) >> 8);
// Copy the data in the packet
VERIFY(m_pStream->Read(&request[6 + namelen + 8], bodlen, NULL) == S_OK);
// Send the client request
if (!Send(reinterpret_cast<const char*>(request), bodlen + 14 + namelen))
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
// ASSERT(false);
return false;
}
// Read the response code
BYTE response = 0;
if (!Receive(reinterpret_cast<char*>(&response), sizeof(response)))
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
return false;
}
// Check the response
if (((dataSize - bodlen) > 0 && response != OBEX_CONTINUE) ||
((dataSize - bodlen) <= 0 && response != OBEX_SUCCESS))
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
// ASSERT(false);
return false;
}
// Read the packet length
WORD packetLength = 0;
if (!Receive(reinterpret_cast<char*>(&packetLength), sizeof(packetLength)))
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
return false;
}
packetLength = ntohs(packetLength);
// Check the packet length
if (packetLength < 3)
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
return false;
}
// Read the optional headers
if (!RecvOpt(packetLength - 3))
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
return false;
}
dataSize -= bodlen;
// Update the progress bar
PostMessage(MY_WM_PROG_STATUS, m_nDataSize - dataSize);
while (dataSize > 0)
{
// Some calculations
restlen = m_nPacketSize - 6;
bodlen = dataSize > restlen ? restlen : dataSize;
// Create the client request
request[0] = (dataSize - bodlen) > 0 ? OBEX_PUT : OBEX_PUT_FINAL;
request[1] = static_cast<BYTE>((htons(bodlen + 6) & 0x00FF) >> 0);
request[2] = static_cast<BYTE>((htons(bodlen + 6) & 0xFF00) >> 8);
request[3] = (dataSize - bodlen) > 0 ? OBEX_BODY : OBEX_END_OF_BODY;
request[4] = static_cast<BYTE>((htons(bodlen + 3) & 0x00FF) >> 0);
request[5] = static_cast<BYTE>((htons(bodlen + 3) & 0xFF00) >> 8);
// Copy the data in the packet
VERIFY(m_pStream->Read(&request[6], bodlen, NULL) == S_OK);
// Send the client request
if (!Send(reinterpret_cast<const char*>(request), bodlen + 6))
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
// ASSERT(false);
return false;
}
// Read the response code
if (!Receive(reinterpret_cast<char*>(&response), sizeof(response)))
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
return false;
}
// Check the response
if (((dataSize - bodlen) > 0 && response != OBEX_CONTINUE) ||
((dataSize - bodlen) <= 0 && response != OBEX_SUCCESS))
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
// ASSERT(false);
return false;
}
// Read the packet length
if (!Receive(reinterpret_cast<char*>(&packetLength), sizeof(packetLength)))
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
return false;
}
packetLength = ntohs(packetLength);
// Check the packet length
if (packetLength < 3)
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
return false;
}
// Read the optional headers
if (!RecvOpt(packetLength - 3))
{
delete [] request;
PostMessage(MY_WM_END, EObexPutFailed);
return false;
}
dataSize -= bodlen;
// Update the progress bar
PostMessage(MY_WM_PROG_STATUS, m_nDataSize - dataSize);
}
ASSERT(dataSize == 0);
delete [] request;
return true;
}
const CString CIrObexDlg::GetErrorMessage(int nError)
{
// Check pre-conditions
ASSERT(nError >= 0 && nError < _countof(ERROR_MESSAGES));
if (nError >= 0 && nError < _countof(ERROR_MESSAGES))
return CString(ERROR_MESSAGES[nError]);
return CString(_T("Undefinierter Fehler."));
}
bool CIrObexDlg::Send(const char* pData, int nLength)
{
// Check pre-conditions
ASSERT(m_socket != INVALID_SOCKET);
ASSERT(pData != NULL);
ASSERT(AfxIsValidAddress(pData, nLength, FALSE));
ASSERT(nLength > 0);
while (nLength > 0)
{
const int nResult = send(m_socket, pData, nLength, 0);
if (nResult == SOCKET_ERROR || nResult == 0)
return false;
nLength -= nResult;
pData += nResult;
}
return true;
}
bool CIrObexDlg::Receive(char* pData, int nLength)
{
// Check pre-conditions
ASSERT(m_socket != INVALID_SOCKET);
ASSERT(pData != NULL);
ASSERT(AfxIsValidAddress(pData, nLength, TRUE));
ASSERT(nLength > 0);
while (nLength > 0)
{
const int nResult = recv(m_socket, pData, nLength, 0);
if (nResult == SOCKET_ERROR || nResult == 0)
return false;
nLength -= nResult;
pData += nResult;
}
return true;
}
bool CIrObexDlg::RecvOpt(int nLength)
{
// Check pre-conditions
ASSERT(m_socket != INVALID_SOCKET);
ASSERT(nLength >= 0);
while (nLength > 0)
{
BYTE tmp = 0;
int nResult = recv(m_socket, reinterpret_cast<char*>(&tmp), sizeof(tmp), 0);
if (nResult == SOCKET_ERROR || nResult == 0)
return false;
nLength -= nResult;
}
return true;
}
Regards,
Daniel.
|
|
|
|
|
Hi Daniel,
Thanks a lot!
Can you mail me this application (joshivi@yahoo.com)? Also, the IR device attached to my PC is of USB infrared type. Does that be a problem?
Thanks a lot again.
B Vidyadhar Joshi
|
|
|
|
|
Sorry, but I can't mail you the application because the OBEX sample code is part of a big software I have written for company, so I am not allowed to send you the hole application!
Regards,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
|
|
|
|
|
Hi Daniel,
Thanks for the help. I just wanted a small app which can just pick a file and put it in the mobile phone using OBEX (I'm not a C++ programmer ).
My other issue is - I tried your application with my PC (Win2000 server) and Nokia 6600. It didn't work. It gives an error message "Failed to open IrDA port". My PC has a USB IrDA device (Edisonsoft ES-620 USB infrared Adapter). I can't see any serial port assigned to this device. However, when I switch on the infrared on my mobile and align it with the USB device, an infrared modem is created in the Device Manager with COM12 assigned to it.
How do I get through this problem?
Regards,
B Vidyadhar Joshi.
|
|
|
|
|
Got IRCOMM2K installed and now, I have a virtual serial port on COM20. I used the "irda2kdump" utility to monitor the Ir traffic and it seems to work fine. I transferred a file from the PC to my Nokia 6600 through irftp and for monitoring purposes.
But when I use your application with my mobile phone (IR on my mobile is activated), it refuses to work. It throws a message "Failed to open IrDA port". I changed the serial port to COM3 and then tried the application. Still I get the error message "Failed to write request to device". Please help!
|
|
|
|
|
hi again daniel, i need help to convert the TCHAR to WCHAR at line :
CTtoW lpwszName(m_strName); // convert string from TCHAR to WCHAR
can it be done using the 'MultiByteToWideChar' ?
thanks before
* a lot of people fail not because they lack knowledge of talent but because they quit *
|
|
|
|
|
Yes of course!
Just take a look at the following article for more information:
Strings on Pocket PC, Unicode and ANSI
The CTtoW class is a class I have written for simple string conversion.
Here is the full source code:
#if !defined(_STRCONV_H_)
#define _STRCONV_H_
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
class CBSTRtoT : public CString
{
public:
CBSTRtoT(BSTR bstr) : CString(bstr == NULL ? L"" : bstr)
{}
};
class CTtoA
{
LPSTR m_psz;
public:
CTtoA(LPCTSTR ptsz) : m_psz(NULL)
{
ASSERT(ptsz != NULL);
ASSERT(AfxIsValidString(ptsz));
#if defined(_UNICODE) // for UNICODE build
const int size = WideCharToMultiByte(CP_ACP, 0, ptsz, -1,
NULL, 0, NULL, NULL);
#ifdef _DEBUG
if (size == 0) {
ASSERT(!_T("Function \"WideCharToMultiByte\" failed."));
}
#endif // _DEBUG
ASSERT(size > 0);
m_psz = (LPSTR) malloc(sizeof(CHAR)*size);
ASSERT(m_psz != NULL);
ASSERT(AfxIsValidAddress(m_psz, sizeof(CHAR)*size, TRUE));
#ifdef _DEBUG
memset(m_psz, 0, sizeof(CHAR)*size);
#endif // _DEBUG
VERIFY(WideCharToMultiByte(CP_ACP, 0, ptsz, -1,
m_psz, size, NULL, NULL) != 0);
#else // for non-UNICODE build
m_psz = _strdup(ptsz);
ASSERT(m_psz != NULL);
#endif // defined(_UNICODE)
ASSERT(AfxIsValidString(m_psz));
}
CTtoA(const CTtoA& rhs) : m_psz(_strdup(rhs.m_psz))
{
ASSERT(m_psz != NULL);
ASSERT(AfxIsValidString(m_psz));
}
CTtoA& operator=(const CTtoA& rhs)
{
if (this != &rhs)
{
free(m_psz);
m_psz = _strdup(rhs.m_psz);
ASSERT(m_psz != NULL);
ASSERT(AfxIsValidString(m_psz));
}
return *this;
}
~CTtoA()
{
free(m_psz);
}
size_t GetLength() const { return strlen(m_psz); }
operator LPCSTR() const { return m_psz; }
};
class CTtoW
{
LPWSTR m_pwsz;
public:
CTtoW(LPCTSTR ptsz) : m_pwsz(NULL)
{
ASSERT(ptsz != NULL);
ASSERT(AfxIsValidString(ptsz));
#if defined(_UNICODE) // for UNICODE build
m_pwsz = _wcsdup(ptsz);
ASSERT(m_pwsz != NULL);
#else // for non-UNICODE build
const int size = MultiByteToWideChar(CP_ACP, 0, ptsz, -1, NULL, 0);
#ifdef _DEBUG
if (size == 0) {
ASSERT(!_T("Function \"MultiByteToWideChar\" failed."));
}
#endif // _DEBUG
ASSERT(size > 0);
m_pwsz = (LPWSTR) malloc(sizeof(WCHAR)*size);
ASSERT(m_pwsz != NULL);
ASSERT(AfxIsValidAddress(m_pwsz, sizeof(WCHAR)*size, TRUE));
#ifdef _DEBUG
memset(m_pwsz, 0, sizeof(WCHAR)*size);
#endif // _DEBUG
VERIFY(MultiByteToWideChar(CP_ACP, 0, ptsz, -1, m_pwsz, size) != 0);
#endif // defined(_UNICODE)
ASSERT(AfxIsValidString(m_pwsz));
}
CTtoW(const CTtoW& rhs) : m_pwsz(_wcsdup(rhs.m_pwsz))
{
ASSERT(m_pwsz != NULL);
ASSERT(AfxIsValidString(m_pwsz));
}
CTtoW& operator=(const CTtoW& rhs)
{
if (this != &rhs)
{
free(m_pwsz);
m_pwsz = _wcsdup(rhs.m_pwsz);
ASSERT(m_pwsz != NULL);
ASSERT(AfxIsValidString(m_pwsz));
}
return *this;
}
~CTtoW()
{
free(m_pwsz);
}
size_t GetLength() const { return wcslen(m_pwsz); }
operator LPCWSTR() const { return m_pwsz; }
};
#endif // !defined(_STRCONV_H_)
Regards,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
|
|
|
|
|
great !! usefull function, u should publish that in tip and tricks article...
One obstacle when i try your class, in your construction theres an IStream that should be passed.
-------------------------------------------------------
CIrObexDlg(IStream* pStream, const CString& strName....
-------------------------------------------------------
All i know is that the IR communication using the HANDLE to send/read data. How can i open that IStream to transfer the packet ??
i'm using evc 4.0 and theres no documentation about IStream in the help section.
vielen Dank,
Riki Risnandar
* a lot of people fail not because they lack knowledge of talent but because they quit *
|
|
|
|
|
I use a stream object, because I save my application data as XML, so I can write the XML data to the stream and send that via OBEX to the Desktop PC.
void CLmsPPCDoc::OnSend()
{
LOGMARKER(_T("CLmsPPCDoc::OnSend"));
ProcessMessages();
CWaitStatusBar wsb(_T("Übertragung läuft..."));
BeginWaitCursor();
LOGNOTIFY(_T("Try to save measure data to memory stream."));
CComPtr<MSXML::IXMLDOMDocument> pDoc;
HRESULT hResult = pDoc.CoCreateInstance(MSXML::CLSID_DOMDocument, NULL, CLSCTX_INPROC_SERVER);
if (FAILED(hResult) || pDoc == NULL)
{
EndWaitCursor();
LOGERROR(_T("The function \"CComPtr<MSXML::IXMLDOMDocument>::CoCreateInstance\" failed; ")\
_T("could't create XML document."));
AfxMessageBox(_T("Das für den Datentransfer benötigte XML Dokument ")\
_T("konnte nicht erstellt werden."), MB_OK | MB_ICONWARNING);
return;
}
if (pDoc->put_preserveWhiteSpace(VARIANT_TRUE) != S_OK)
{
pDoc = NULL;
EndWaitCursor();
LOGERROR(_T("The function \"IXMLDOMDocument::put_preserveWhiteSpace\" failed; ")\
_T("could't set \"PreserveWhitespace\" property."));
AfxMessageBox(_T("Das für den Datentransfer benötigte XML Dokument ")\
_T("konnte nicht erstellt werden."), MB_OK | MB_ICONWARNING);
return;
}
CComPtr<MSXML::IXMLDOMProcessingInstruction> pProcInst;
if (pDoc->createProcessingInstruction(CComBSTR(L"xml"),
CComBSTR(L"version='1.0' encoding='UTF-8'"), &pProcInst) != S_OK ||
pProcInst == NULL)
{
pDoc = NULL;
EndWaitCursor();
LOGERROR(_T("The function \"IXMLDOMDocument::createProcessingInstruction\" failed; ")\
_T("could't create processing instruction."));
AfxMessageBox(_T("Das für den Datentransfer benötigte XML Dokument ")\
_T("konnte nicht erstellt werden."), MB_OK | MB_ICONWARNING);
return;
}
if (pDoc->appendChild(pProcInst, NULL) != S_OK)
{
pDoc = NULL;
EndWaitCursor();
LOGERROR(_T("The function \"IXMLDOMDocument::appendChild\" failed; ")\
_T("could't add processing instruction to XML document."));
AfxMessageBox(_T("Das für den Datentransfer benötigte XML Dokument ")\
_T("konnte nicht erstellt werden."), MB_OK | MB_ICONWARNING);
return;
}
if (!m_measureData.SaveAsXML(pDoc))
{
pDoc = NULL;
EndWaitCursor();
LOGERROR(_T("The function \"CMeasureData::SaveAsXML\" failed; ")\
_T("could't add measure data to XML document."));
AfxMessageBox(_T("Das für den Datentransfer benötigte XML Dokument ")\
_T("konnte nicht erstellt werden."), MB_OK | MB_ICONWARNING);
return;
}
CComPtr<IStream> pStream;
if (::CreateStreamOnHGlobal(NULL, TRUE, &pStream) != S_OK || pStream == NULL)
{
pDoc = NULL;
EndWaitCursor();
LOGERROR(_T("The function \"::CreateStreamOnHGlobal\" failed; ")\
_T("could't create stream object to save XML document."));
AfxMessageBox(_T("Das für den Datentransfer benötigte XML Dokument ")\
_T("konnte nicht erstellt werden."), MB_OK | MB_ICONWARNING);
return;
}
if (pDoc->save(CComVariant(pStream.p)) != S_OK)
{
pStream = NULL;
pDoc = NULL;
EndWaitCursor();
LOGERROR(_T("The function \"IXMLDOMDocument::save\" failed; ")\
_T("could't save XML document."));
AfxMessageBox(_T("Das für den Datentransfer benötigte XML Dokument ")\
_T("konnte nicht erstellt werden."), MB_OK | MB_ICONWARNING);
return;
}
LOGNOTIFY(_T("Saved measure data successfully to memory stream."));
EndWaitCursor();
CIrObexDlg dlg(pStream.p,
m_measureData.GetDescription().Left(CIrObexDlg::MAX_NAME_LENGTH - 4)
+ _T(".lms"));
const int nError = dlg.DoModal();
if (nError != CIrObexDlg::EOk && nError != CIrObexDlg::EAbort)
{
AfxMessageBox(CIrObexDlg::GetErrorMessage(nError),
MB_OK | MB_ICONWARNING);
}
}
Regards,
Daniel.
--
FIND A JOB YOU LOVE, AND YOU'LL NEVER HAVE TO WORK A DAY OF YOUR LIFE.
|
|
|
|
|