Beispiel #1
0
/***********************************************************************\
 * Input : none                                                          *
 * Output: None                                                          *
 * Function: Monitor Devices and process events                          *
 \***********************************************************************/
void Control(void) {
  int deviceID = 0;
  double eventStartTime, eventResponseTime, eventTurnAroundTime;
  Event e;
  //Set up DeviceEventsInfo structs
  // So we end up getting the same performance
  // even if Initialize() isn't called..
  InitializeDeviceEventsInfo();

  while (1) {
    // Find an device that has an event that needs processing
    while ((BufferLastEvent[deviceID].When == 0) || (eventInfoArray[deviceID].processedEventID[BufferLastEvent[deviceID].EventID])) {
      deviceID++;
      deviceID = deviceID % MAX_NUMBER_DEVICES;
    }

    //eventStartTime = Now(); // avg response = 0.000039, avg turn = 0.030
    // Copy the event into our memory before it changes
    e = BufferLastEvent[deviceID];
    eventStartTime = e.When; // avg response = 0.007799, avg turn = 0.037910

    DisplayEvent('a', &e);
    eventResponseTime = Now() - eventStartTime;

    // Serve the event
    Server(&e);
    eventTurnAroundTime = Now() - eventStartTime;

    // Set as processed
    eventInfoArray[e.DeviceID].processedEventID[e.EventID] = 1;
    setEventInfo(e.DeviceID, e.EventID, 
                 eventResponseTime, eventTurnAroundTime);
  }

}
Beispiel #2
0
/***********************************************************************\
* Input : None                                                          *
* Output: None                                                          *
* Function: This routine is run whenever an event occurs on a device    *
*           The id of the device is encoded in the variable flag        *
\***********************************************************************/
void InterruptRoutineHandlerDevice(void){
    printf("An event occured at %f  Flags = %d \n", Now(), Flags);
    Event* event = NULL;
    Status tempFlags = Flags;
    int deviceNum = 0;

    Flags = 0;

    // Grab all events in sequential order
    while(tempFlags)
    {
        if(tempFlags & 1)
        {
            // Copy event from volatile memory and make it get in line
            event = &BufferLastEvent[deviceNum];

            if(!isFull(deviceNum)) {
              event = enqueue(event, deviceNum);
            }
            devices[deviceNum].responseTotal += Now() - event->When;
            devices[deviceNum].responses++;
            DisplayEvent('c', event);
        }

        tempFlags = tempFlags >> 1;
        deviceNum++;
    }

}
Beispiel #3
0
void CChildView::OnCommandSendFile() 
{
	// Select the file
	CFileDialog dlgFileOpen(TRUE,NULL,NULL,OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST,_T("All files (*.*)|*.*||"),this);
	if (dlgFileOpen.DoModal() != IDOK)
		return;

	// Open the file
	HANDLE hFile = ::CreateFile(dlgFileOpen.GetPathName(),GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,NULL);
	if (hFile != INVALID_HANDLE_VALUE)
	{
		// Obtain file length
		DWORD dwDataLen = ::GetFileSize(hFile,0);

		// Map the file into memory
		HANDLE hMap = ::CreateFileMapping(hFile,NULL,PAGE_READONLY,0,0,NULL);
		if (hMap != NULL)
		{
			LPVOID lpData = ::MapViewOfFile(hMap,FILE_MAP_READ,0,0,0);
			if (lpData)
			{
				// Write all data
				DWORD dwWritten = 0;
				m_serial.Write(lpData,dwDataLen,&dwWritten);

				// Display event
				CString strEvent;
				strEvent.Format(_T("Written %d bytes."), dwWritten);
				DisplayEvent(strEvent);

				// Unmap the view
				::UnmapViewOfFile(lpData);
			}

			// Close mapping
			::CloseHandle(hMap);
		}

		// Close file
		::CloseHandle(hFile);
	}
}
Beispiel #4
0
/***********************************************************************\
* Input : None                                                          *
* Output: None                                                          *
* Function: This routine is run whenever an event occurs on a device    *
*           The id of the device is encoded in the variable flag        *
\***********************************************************************/
void InterruptRoutineHandlerDevice(void){
 	printf("An event occured at %f  Flags = %d \n", Now(), Flags);
	// Put Here the most urgent steps that cannot wait
	Status CurrentStatus = Flags;  //snapShot of Flag status
	Flags = 0; //rest Flags
	Event event;
	int position = 0;	

	while(CurrentStatus){
		if(CurrentStatus & 1){
			event = BufferLastEvent[position];
			enqueue(event);
			RT[event.DeviceID] += Now() - event.When;
			DisplayEvent('x', &event);
			EventCount[event.DeviceID] = EventCount[event.DeviceID] + 1;

		} // end if

		position++;
		CurrentStatus = CurrentStatus >> 1;

	} //end While CurrentStatus
}
Beispiel #5
0
/*===========================================================================

FUNCTION: CallDemoAppUsage

DESCRIPTION
    This function executes the usage example selected from the main menu by the
  user.  It takes as input the app data pointer and the ID of the example the
  user selected.  After clearing the screen, the selected example is executed.
  Each example is a self-contained code block that contains any local variables
  needed to execute the example.  Each code block also creates and releases any
  BREW interfaces that are required, and will exit if any errors are detected.  
  Once the example has been executed, this function prints a heading at the top 
  of the screen to indicate which example was selected, 
  and a message at the bottom of the screen instructing the user how to return to
  the main menu to execute another example.
    
PROTOTYPE:
   static void IFileUsage(CallDemoApp * pMe, uint16 wParam)

PARAMETERS:
   pMe:   [in]: Contains a pointer to the usage app data structure.
   wParam: [in]: Identifier of the selected example (example IDs are specified when the
                 main usage app menu is created).

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None

===========================================================================*/
static void CallDemoAppUsage (CallDemoApp * pMe, uint16 wParam)
{

    
   // Make sure the pointers we'll be using are valid
   if (pMe == NULL || pMe->a.m_pIShell == NULL || pMe->a.m_pIDisplay == NULL)
     return;

   // Erase screen first for display output purposes.
   DisplayEvent (pMe, USAGE_ERASE_SCREEN);
  IMENUCTL_SetProperties(pMe->m_pIMenu, MP_NO_REDRAW);
  IMENUCTL_SetActive(pMe->m_pIMenu, FALSE);

   // Initialize line number where we will start the output 
   // of each test
   pMe->m_cLineNum = 1;

   switch (wParam)
   {
        case USAGE_CALL_ORIG:
        {
           AECHAR szwStr[32];
           char szNumber[32];
           boolean Result;

           // get telephone number from resource file
           ISHELL_LoadResString(pMe->a.m_pIShell, CALLDEMO_RES_FILE, IDS_STRING_TELEPHONE_NUMBER, szwStr, sizeof(szwStr));
           WSTRTOSTR(szwStr, szNumber, sizeof(szNumber));

                  
          LISTENER_Init(&pMe->callListener, (PFNLISTENER) OriginateListener, pMe);
          Result = ICALLMGR_Originate(pMe->m_pCallMgr, AEET_CALL_TYPE_VOICE, szNumber, NULL, &pMe->m_pOutgoingCall, &pMe->callListener);
          if (Result != SUCCESS)
          {
             DBGPRINTF("ICALLMGR_Originate failed with res=%d", Result);
             break;
          }
          WriteLine(pMe, "Call Originate -->", NULL, FALSE);          
        }
        break;

        case USAGE_CALL_OUTGOING_END:
            {
                if (Telephone_EndCall(pMe) != SUCCESS) 
                {
                    if (pMe->m_pOutgoingCall) 
                    {
                        ICALL_Release(pMe->m_pOutgoingCall);
                        pMe->m_pOutgoingCall = NULL;
                    }
                }
                WriteLine(pMe, "Call End -->", NULL, FALSE);                
            }
            break;
            
        case USAGE_CALL_INCOMING_END:
            {
                int iResult = EFAILED;

                if (pMe->m_pIncomingCall != NULL)
                {
                    iResult = ICALL_End(pMe->m_pIncomingCall);
                    if (iResult == SUCCESS)
                    {
                        ICALL_Release(pMe->m_pIncomingCall);
                        pMe->m_pIncomingCall = NULL;
                    }
                }
                
                WriteLine(pMe, "Call End -->", NULL, FALSE);                
            }
            break;

        case USAGE_CALL_DTMF:
        {
           AECHAR szwStr[32];
           char szNumber[32];
           boolean Result;

           // get telephone number (main) from resource file
           ISHELL_LoadResString(pMe->a.m_pIShell, CALLDEMO_RES_FILE, IDS_STRING_TELEPHONE_NUMBER_MAIN, szwStr, sizeof(szwStr));
           WSTRTOSTR(szwStr, szNumber, sizeof(szNumber));

                  
          LISTENER_Init(&pMe->callListener, (PFNLISTENER) OriginateListener, pMe);
          Result = ICALLMGR_Originate(pMe->m_pCallMgr, AEET_CALL_TYPE_VOICE, szNumber, NULL, &pMe->m_pOutgoingCall, &pMe->callListener);
          if (Result != SUCCESS)
          {
             DBGPRINTF("ICALLMGR_Originate failed with res=%d", Result);
             break;
          }
          WriteLine(pMe, "Call Originate -->", NULL, FALSE);  
          WriteLine(pMe, "Press 2 to DTMF", NULL, FALSE);  
          pMe->m_isDTMFItem = TRUE;
        }
        break;

        case USAGE_CALL_PARTY3:
        {
           AECHAR szwStr[32];
           char szNumber[32];
           boolean Result;

           // get telephone number (main) from resource file
           ISHELL_LoadResString(pMe->a.m_pIShell, CALLDEMO_RES_FILE, IDS_STRING_TELEPHONE_NUMBER_A, szwStr, sizeof(szwStr));
           WSTRTOSTR(szwStr, szNumber, sizeof(szNumber));

                  
          LISTENER_Init(&pMe->callListener, (PFNLISTENER) OriginateListener, pMe);
          Result = ICALLMGR_Originate(pMe->m_pCallMgr, AEET_CALL_TYPE_VOICE, szNumber, NULL, &pMe->m_pOutgoingCall, &pMe->callListener);
          if (Result != SUCCESS)
          {
             DBGPRINTF("ICALLMGR_Originate failed with res=%d", Result);
             break;
          }
          WriteLine(pMe, "Call Originate A-->", NULL, FALSE);  
          WriteLine(pMe, "Press 3 to call B", NULL, FALSE);  
          pMe->m_isParty3Item = TRUE;
        }
        break;

        case USAGE_CALL_ANSWER:
            pMe->m_isRedirectItem = FALSE;
            break;
        
        case USAGE_CALL_REDIRECT:
            pMe->m_isRedirectItem = TRUE;
            break;
        
        default:
             return;
    }
            
    // Display above event. 
    DisplayEvent (pMe, wParam);

    return;
}
//==================================================================================================
void TestDialog_2::DisplayEventSetting (LPCTSTR lpszMsg, LPCTSTR lpszSetting, bool fOn)
{
	TCHAR tszMsg[200];
	wsprintf(tszMsg,_T("%s (%s=%s)"), lpszMsg, lpszSetting, (fOn?_T("on"):_T("off")));
	DisplayEvent(tszMsg);
}
//==================================================================================================
LRESULT TestDialog_2::OnSerialMsg (WPARAM wParam, LPARAM /*lParam*/)
{
	CSerial::EEvent eEvent = CSerial::EEvent(LOWORD(wParam));
	CSerial::EError eError = CSerial::EError(HIWORD(wParam));

	if (eError)
		DisplayEvent(_T("An internal error occurred."));

	if (eEvent & CSerial::EEventBreak)
		DisplayEvent(_T("Break detected on input."));

	if (eEvent & CSerial::EEventError)
		DisplayEvent(_T("A line-status error occurred."));
	
	if (eEvent & CSerial::EEventRcvEv)
		DisplayEvent(_T("Event character has been received."));

	if (eEvent & CSerial::EEventRing)
		DisplayEvent(_T("Ring detected"));
	
	if (eEvent & CSerial::EEventSend)
		DisplayEvent(_T("All data is send"));
	
	if (eEvent & CSerial::EEventCTS)
		DisplayEventSetting(_T("CTS signal change"), _T("CTS"), serial.GetCTS());
	
	if (eEvent & CSerial::EEventDSR)
		DisplayEventSetting(_T("DSR signal change"), _T("DSR"), serial.GetDSR());
	
	if (eEvent & CSerial::EEventRLSD)
		DisplayEventSetting(_T("RLSD signal change"), _T("RLSD"), serial.GetRLSD());
	
	if (eEvent & CSerial::EEventRecv)
	{
		// Create a clean buffer
		DWORD dwRead;
		char szData[101];
		const int nBuflen = sizeof(szData)-1;

		// Obtain the data from the serial port
		do
		{
			serial.Read(szData,nBuflen,&dwRead);
			szData[dwRead] = '\0';

			// Scan the string for unwanted characters
			for (DWORD dwChar=0; dwChar<dwRead; dwChar++)
			{
				if (!isprint(szData[dwChar]) && !isspace(szData[dwChar]))
				{
					szData[dwChar] = '.';
				}
			}

#ifdef _UNICODE
			// Convert the ANSI data to Unicode
			LPTSTR lpszData = LPTSTR(_alloca((dwRead+1)*sizeof(TCHAR)));
			if (!::MultiByteToWideChar(CP_ACP, 0, szData, -1, lpszData, dwRead+1))
				return 0;

			// Display the fetched string
			DisplayData(lpszData);
#else
			// Display the fetched string
			DisplayData(szData);
#endif
		} while (dwRead == nBuflen);
	}

	return 0;
}
//</SnippetListSupportedFormats1>
//<SnippetListSupportedEvents1>
// List all supported events on the service
void ListSupportedEvents(
    _In_ IPortableDeviceService* service)
{
    ComPtr<IPortableDeviceServiceCapabilities>     capabilities;
    ComPtr<IPortableDevicePropVariantCollection>   events;
    DWORD   numEvents = 0;

    // Get an IPortableDeviceServiceCapabilities interface from the IPortableDeviceService interface to
    // access the service capabilities-specific methods.
    HRESULT hr = service->Capabilities(&capabilities);
    if (FAILED(hr))
    {
        wprintf(L"! Failed to get IPortableDeviceServiceCapabilities from IPortableDeviceService, hr = 0x%lx\n", hr);
    }

    // Get all events supported by the service.
    if (SUCCEEDED(hr))
    {
        hr = capabilities->GetSupportedEvents(&events);
        if (FAILED(hr))
        {
            wprintf(L"! Failed to get supported events from the service, hr = 0x%lx\n", hr);
        }
    }

    // Get the number of supported events found on the service.
    if (SUCCEEDED(hr))
    {
        hr = events->GetCount(&numEvents);
        if (FAILED(hr))
        {
            wprintf(L"! Failed to get number of supported events, hr = 0x%lx\n", hr);
        }
    }

    // Loop through each event and display it
    if (SUCCEEDED(hr))
    {
        wprintf(L"\n%u Supported Events Found on the service\n\n", numEvents);

        for (DWORD index = 0; index < numEvents; index++)
        {
            PROPVARIANT event = {0};
            hr = events->GetAt(index, &event);

            if (SUCCEEDED(hr))
            {
                // We have an event.  It is assumed that
                // events are returned as VT_CLSID VarTypes.
                if (event.vt    == VT_CLSID && 
                    event.puuid != nullptr)
                {
                    DisplayEvent(capabilities.Get(), *event.puuid);
                    wprintf(L"\n");
                }
            }

            PropVariantClear(&event);
        }
    }
}
Beispiel #9
0
// Message handler for event details box.
INT_PTR CALLBACK
EventDetails(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    UNREFERENCED_PARAMETER(lParam);

    switch (message)
    {
        case WM_INITDIALOG:
            InitDetailsDlg(hDlg);

            // Show event info on dialog box
            DisplayEvent(hDlg);
            return (INT_PTR)TRUE;

        case WM_COMMAND:
            switch (LOWORD(wParam))
            {
                case IDOK:
                case IDCANCEL:
                    EndDialog(hDlg, LOWORD(wParam));
                    return (INT_PTR)TRUE;

                case IDC_PREVIOUS:
                    SendMessage(hwndListView, WM_KEYDOWN, VK_UP, 0);

                    // Show event info on dialog box
                    DisplayEvent(hDlg);
                    return (INT_PTR)TRUE;

                case IDC_NEXT:
                    SendMessage(hwndListView, WM_KEYDOWN, VK_DOWN, 0);

                    // Show event info on dialog box
                    DisplayEvent(hDlg);
                    return (INT_PTR)TRUE;

                case IDC_COPY:
                    CopyEventEntry(hDlg);
                    return (INT_PTR)TRUE;

                case IDC_BYTESRADIO:
                    return (INT_PTR)TRUE;

                case IDC_WORDRADIO:
                    return (INT_PTR)TRUE;

                case IDHELP:
                    MessageBoxW(hDlg,
                               L"Help not implemented yet!",
                               L"Event Log",
                               MB_OK | MB_ICONINFORMATION);
                    return (INT_PTR)TRUE;

                default:
                    break;
            }
            break;
    }

    return (INT_PTR)FALSE;
}
Beispiel #10
0
/*===========================================================================

FUNCTION: IFileUsage

DESCRIPTION
    This function executes the usage example selected from the main menu by the
  user.  It takes as input the app data pointer and the ID of the example the
  user selected.  After clearing the screen, the selected example is executed.
  Each example is a self-contained code block that contains any local variables
  needed to execute the example.  Each code block also creates and releases any
  BREW interfaces that are required, and will exit if any errors are detected.
  Once the example has been executed, this function prints a heading at the top
  of the screen to indicate which example was selected,
  and a message at the bottom of the screen instructing the user how to return to
  the main menu to execute another example.

PROTOTYPE:
   static void IFileUsage(ISmsApp * pMe, uint16 wParam)

PARAMETERS:
   pMe:   [in]: Contains a pointer to the usage app data structure.
   wParam: [in]: Identifier of the selected example (example IDs are specified when the
                 main usage app menu is created).

DEPENDENCIES
  None

RETURN VALUE
  None

SIDE EFFECTS
  None

===========================================================================*/
static void ISmsAppUsage (ISmsApp * pMe, uint16 wParam)
{


    // Make sure the pointers we'll be using are valid
    if (pMe == NULL || pMe->a.m_pIShell == NULL || pMe->a.m_pIDisplay == NULL)
        return;

    // Erase screen first for display output purposes.
    DisplayEvent (pMe, USAGE_ERASE_SCREEN);
    IMENUCTL_SetProperties(pMe->m_pIMenu, MP_NO_REDRAW);
    IMENUCTL_SetActive(pMe->m_pIMenu, FALSE);

    // Initialize line number where we will start the output
    // of each test
    pMe->m_cLineNum = 1;

    switch (wParam)
    {
    case USAGE_SMS_TX_ASCII:
    {
        int nErr;
        WebOpt awo[6]; /* ***IMPORTANT**** grow this if you add more
                             WebOpts here, or shrink it and call AddOpt() multiple times */
        int    i = 0;
        uint32 nReturn=0;


        nErr =ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SMSMSG, (void **)&pMe->m_pISMSMsg);
        DBGPRINTF("CreateInstance of AEECLSID_SMSMSG ret %d", nErr);
        if(nErr != AEE_SUCCESS)
        {
            break;
        }

        /* NULL terminated string providing destination device number.
            '+' as first character signifies international number.  */
        awo[i].nId  = MSGOPT_TO_DEVICE_SZ ;
        awo[i].pVal = (void *)DESTINATION_NUMBER;
        i++;

        /* ascii text to be send */
        awo[i].nId  = MSGOPT_PAYLOAD_SZ ;
        awo[i].pVal = (void *)MO_TEXT_ASCII;
        i++;

        /* encoding */
        awo[i].nId  = MSGOPT_PAYLOAD_ENCODING;
        awo[i].pVal = (void *)AEE_ENC_ISOLATIN1;
        i++;

        awo[i].nId  = MSGOPT_MOSMS_ENCODING;
        awo[i].pVal = (void *)AEESMS_ENC_ASCII;
        i++;
#if 0
        /* user ack */
        awo[i].nId  = MSGOPT_USER_ACK;
        awo[i].pVal = (void *)TRUE;
        i++;
#endif
        /* this is absolutely necessary, do not remove, marks the end of the
           array of WebOpts */
        awo[i].nId  = WEBOPT_END;

        /* add 'em */
        nErr =ISMSMSG_AddOpt(pMe->m_pISMSMsg, awo);
        DBGPRINTF("ISMSMSG_AddOpt ret %d", nErr);

        CALLBACK_Init(&pMe->m_cb, SMSCallBack_Send, pMe);
        ISMS_SendMsg(pMe->m_pISMS, pMe->m_pISMSMsg, &pMe->m_cb, &nReturn);

        // Higher 16 bits specify error type specified as AEESMS_ERRORTYPE_XXX
        // lower  16 bits specify error specified as AEESMS_ERROR_XXX
        DBGPRINTF("ISMS_SendMsg ret 0x%x", nReturn);
    }
    break;

    case USAGE_SMS_TX_UNICODE:
    {
        int nErr;
        WebOpt awo[6]; /* ***IMPORTANT**** grow this if you add more
                             WebOpts here, or shrink it and call AddOpt() multiple times */
        int    i = 0;
        uint32 nReturn=0;
        AECHAR pszBuf[100];

        nErr =ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SMSMSG, (void **)&pMe->m_pISMSMsg);
        DBGPRINTF("CreateInstance of AEECLSID_SMSMSG ret %d", nErr);
        if(nErr != AEE_SUCCESS)
        {
            break;
        }

        /* NULL terminated string providing destination device number.
            '+' as first character signifies international number.  */
        awo[i].nId  = MSGOPT_TO_DEVICE_SZ ;
        awo[i].pVal = (void *)DESTINATION_NUMBER;
        i++;

        /* unicode text to be send */
        awo[i].nId  = MSGOPT_PAYLOAD_WSZ ;
        ISHELL_LoadResString(pMe->a.m_pIShell, ISMS_RES_FILE, IDS_MO_TEXT_UNICODE, pszBuf, sizeof(pszBuf));
        awo[i].pVal = (void *)pszBuf;
        i++;

        /* encoding */
        awo[i].nId  = MSGOPT_PAYLOAD_ENCODING;
        awo[i].pVal = (void *)AEE_ENC_UNICODE ;
        i++;

        awo[i].nId  = MSGOPT_MOSMS_ENCODING;
        awo[i].pVal = (void *)AEESMS_ENC_UNICODE;
        i++;

#if 0
        /* user ack */
        awo[i].nId  = MSGOPT_READ_ACK;
        awo[i].pVal = (void *)TRUE;
        i++;
#endif

        /* this is absolutely necessary, do not remove, marks the end of the
           array of WebOpts */
        awo[i].nId  = MSGOPT_END;

        /* add 'em */
        nErr =ISMSMSG_AddOpt(pMe->m_pISMSMsg, awo);
        DBGPRINTF("ISMSMSG_AddOpt ret %d", nErr);

        CALLBACK_Init(&pMe->m_cb, SMSCallBack_Send, pMe);
        ISMS_SendMsg(pMe->m_pISMS, pMe->m_pISMSMsg, &pMe->m_cb, &nReturn);

        // Higher 16 bits specify error type specified as AEESMS_ERRORTYPE_XXX
        // lower  16 bits specify error specified as AEESMS_ERROR_XXX
        DBGPRINTF("ISMS_SendMsg ret 0x%x", nReturn);
    }
    break;

    case USAGE_SMS_TX_UTF8:
    {
        int nErr;
        WebOpt awo[6]; /* ***IMPORTANT**** grow this if you add more
                             WebOpts here, or shrink it and call AddOpt() multiple times */
        int    i = 0;
        uint32 nReturn=0;
        char utf8_Buf_Sending[302];
        uint16 count;
        // in utf-8 "数组19英文English混合" with heading of two bytes for length -0x0010
        // The length is little-endian, low byte first.
        char cTextUTF8[142]= {0xFF, 0xFE,
                              0x70, 0x65,0x57, 0x5B, 0x31, 0x0, 0x39, 0x0, 0xF1, 0x82, 0x87, 0x65, 0x45, 0x0,
                              0x6E, 0x0,  0x67, 0x0, 0x6c, 0x0, 0x69, 0x0, 0x73, 0x0, 0x68, 0x0, 0xF7, 0x6D, 0x08, 0x54, 0x0, 0x0
                             };
        //char cTextUTF8[142]={0x1e, 0x0,
        //                                    0xEF, 0xBB, 0xBF, 0xE6,0x95, 0xB0, 0xE7, 0xBB, 0x84, 0x31, 0x39, 0xE8, 0x8B, 0x8B, 0xB1, 0xE6, 0x96,
        //                                     0x87, 0x45,  0x6E, 0x67, 0x6c, 0x69, 0x73, 0x68, 0xE6, 0xB7, 0xB7, 0xE5, 0x90, 0x88 };

        nErr =ISHELL_CreateInstance(pMe->a.m_pIShell, AEECLSID_SMSMSG, (void **)&pMe->m_pISMSMsg);
        DBGPRINTF("CreateInstance of AEECLSID_SMSMSG ret %d", nErr);
        if(nErr != AEE_SUCCESS)
        {
            break;
        }

        /* NULL terminated string providing destination device number.
            '+' as first character signifies international number.  */
        awo[i].nId  = MSGOPT_TO_DEVICE_SZ ;
        awo[i].pVal = (void *)DESTINATION_NUMBER;
        i++;

        /* unicode text to be send */
        awo[i].nId  = MSGOPT_PAYLOAD_BINARY;
        MEMSET(utf8_Buf_Sending, 0, sizeof(utf8_Buf_Sending));
        WSTRTOUTF8((AECHAR *)cTextUTF8, WSTRLEN((AECHAR *)cTextUTF8), (byte *)&(utf8_Buf_Sending[2]), 300);
        count = STRLEN(&(utf8_Buf_Sending[2]));
        DBGPRINTF("WLen(%d)===> count=%d", WSTRLEN((AECHAR *)cTextUTF8),count);
        DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[0], utf8_Buf_Sending[1], utf8_Buf_Sending[2], utf8_Buf_Sending[3] );
        DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[4], utf8_Buf_Sending[5], utf8_Buf_Sending[6], utf8_Buf_Sending[7] );
        DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[8], utf8_Buf_Sending[9], utf8_Buf_Sending[10], utf8_Buf_Sending[11] );
        DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[12], utf8_Buf_Sending[13], utf8_Buf_Sending[14], utf8_Buf_Sending[15] );
        DBGPRINTF("0x%2x, %2x, %2x, %2x", utf8_Buf_Sending[16], utf8_Buf_Sending[17], utf8_Buf_Sending[18], utf8_Buf_Sending[19] );
        utf8_Buf_Sending[0]=count & 0xff;
        utf8_Buf_Sending[1]=(count>>8) & 0xff;
        awo[i].pVal = (void *)utf8_Buf_Sending;
        i++;

        /* encoding */
        awo[i].nId  = MSGOPT_PAYLOAD_ENCODING;
        awo[i].pVal = (void *)AEE_ENC_UTF8 ;
        i++;

        awo[i].nId  = MSGOPT_MOSMS_ENCODING;
        awo[i].pVal = (void *)AEESMS_ENC_OCTET;
        i++;

#if 0
        /* user ack */
        awo[i].nId  = MSGOPT_READ_ACK;
        awo[i].pVal = (void *)TRUE;
        i++;
#endif

        /* this is absolutely necessary, do not remove, marks the end of the
           array of WebOpts */
        awo[i].nId  = MSGOPT_END;

        /* add 'em */
        nErr =ISMSMSG_AddOpt(pMe->m_pISMSMsg, awo);
        DBGPRINTF("ISMSMSG_AddOpt ret %d", nErr);

        CALLBACK_Init(&pMe->m_cb, SMSCallBack_Send, pMe);
        ISMS_SendMsg(pMe->m_pISMS, pMe->m_pISMSMsg, &pMe->m_cb, &nReturn);

        // Higher 16 bits specify error type specified as AEESMS_ERRORTYPE_XXX
        // lower  16 bits specify error specified as AEESMS_ERROR_XXX
        DBGPRINTF("ISMS_SendMsg ret 0x%x", nReturn);
    }
    break;

    case USAGE_SMS_RX_TAPI_METHOD:
    {
        // 使用TAPI的notify机制接收短信
        AEECLSID clsNotifier= AEECLSID_TAPI; // Event sender
        AEECLSID clsNotify = AEECLSID_ISMS;  // Event listener
        // Set the notify event to be NOTIFY_MASK_EVENT. This event is used
        // as an example.
        uint32 dwMask = NMASK_TAPI_SMS_TEXT;
        int nErr;

        // Register a notification
        nErr = ISHELL_RegisterNotify (pMe->a.m_pIShell, clsNotify, clsNotifier, dwMask);
        DBGPRINTF("ISHELL_RegisterNotify ret %d", nErr);
    }

    break;

    case USAGE_SMS_RX_ISMS_METHOD:
    {
        // 使用新的AEECLSID_SMSNOTIFIER 的notify机制接收短信
        AEECLSID clsNotifier= AEECLSID_SMSNOTIFIER; // Event sender
        AEECLSID clsNotify = AEECLSID_ISMS; // Event listener
        // Set the notify event to be NOTIFY_MASK_EVENT. This event is used
        // as an example.
        uint32 dwMask = ((AEESMS_TYPE_TEXT << 16) | NMASK_SMS_TYPE);
        int nErr;

        // Register a notification
        nErr = ISHELL_RegisterNotify (pMe->a.m_pIShell, clsNotify, clsNotifier, dwMask);
        DBGPRINTF("ISHELL_RegisterNotify ret %d", nErr);
    }
    break;

    case USAGE_SMS_STORE_STATUS:
    {
        CALLBACK_Cancel(&pMe->m_cb);
        CALLBACK_Init(&pMe->m_cb, OATSMS_StoreReadMsgStorageStatusCb, (void*)pMe);

        ISMSSTORAGE_GetStorageStatus(pMe->m_pISMSStorage,
                                     pMe->m_mt,
                                     pMe->m_tag,
                                     &pMe->m_cb,
                                     &pMe->m_ss,
                                     &pMe->m_dwStatus);
    }
    break;

    case USAGE_SMS_STORE_ENUM_READ:
    {
        CALLBACK_Cancel(&pMe->EnumMsgInitCb);
        CALLBACK_Init(&pMe->EnumMsgInitCb, OATSMS_EnumMsgInitCb, (void*)pMe);
        ISMSSTORAGE_EnumMsgInit(pMe->m_pISMSStorage,
                                pMe->m_mt,
                                pMe->m_tag,
                                &pMe->EnumMsgInitCb,
                                &pMe->m_dwStatus);
    }
    break;

    default:
        return;
    }

    // Display above event.
    DisplayEvent (pMe, wParam);

    return;
}