int CGestionProxy::InitializeProxy(int trace, CString idDisp, CString ipHDHR) { m_initializedProxy = 1; //Traces are activated to save in log m_Traces->InitializeTrace(trace); if (m_Traces->IsLevelWriteable(LEVEL_TRZ_1)) { char nvl[500]; memset(nvl, 0, 500); _snprintf(nvl, 500 - 2, "Trace Level: %d\n", trace); m_Traces->WriteTrace(nvl, LEVEL_TRZ_1); m_Traces->WriteTrace("******************* Start HDHR IPTV Proxy *******************\n", LEVEL_TRZ_1); m_Traces->WriteTrace("*** Version HDHRProxyIPTV Application: v1.0.4\n", LEVEL_TRZ_1); CStringA idDispTmp(idDisp); CStringA ipHDHRTmp(ipHDHR); _snprintf(nvl, 500 - 2, "*** Device ID: %s\n", idDispTmp); m_Traces->WriteTrace(nvl, LEVEL_TRZ_1); _snprintf(nvl, 500 - 2, "*** Server IP: %s\n", ipHDHRTmp); m_Traces->WriteTrace(nvl, LEVEL_TRZ_1); _snprintf(nvl, 500 - 2, "*** Server IP: %d\n", getDiscovery()->ObtainHDHRServPort()); m_Traces->WriteTrace(nvl, LEVEL_TRZ_1); _snprintf(nvl, 500 - 2, "*** Number of Tuners configured: %d\n", m_cfgProxy->getTunersNumber()); m_Traces->WriteTrace(nvl, LEVEL_TRZ_1); _snprintf(nvl, 500 - 2, "*** Lock configured: %d\n", m_cfgProxy->getLock()); m_Traces->WriteTrace(nvl, LEVEL_TRZ_1); TCHAR sDirActual[200]; GetCurrentDirectory(200, sDirActual); CString path; path.Format(L"%s\\%s", sDirActual, _T(NAME_FILE_MAPLIST)); _snprintf(nvl, 500 - 2, "*** Mapping List File: %s\n", CStringA(path)); m_Traces->WriteTrace(nvl, LEVEL_TRZ_1); CString chans,ch; chans.Format(L"["); for (int i=0; i < m_cfgProxy->m_numChannels; i++) { ch.Format(L"%d", m_cfgProxy->m_infoChannels[i].channel); chans.Append(ch); if (i<m_cfgProxy->m_numChannels - 1) chans.Append(L";"); } chans.Append(L"]"); _snprintf(nvl, 500- 2, "*** Number of channels in Mapping List File: %d %s\n", m_cfgProxy->m_numChannels, CStringA(chans)); m_Traces->WriteTrace(nvl, LEVEL_TRZ_1); } //The first is to start phase Discovery if (!StartDiscovery(trace, idDisp, ipHDHR)) return 0; /* Control */ StartControl(trace, idDisp, ipHDHR); return 1; }
bool CWidcommHandler::DoDiscoverWMouseXPThroughDeviceList() { if(iCurDevice < iFoundDevices.GetSize()) { iDiscoveringGUID.Data1 = 0x2bc2b92e; iDiscoveringGUID.Data2 = 0x3992; iDiscoveringGUID.Data3 = 0x11dc; iDiscoveringGUID.Data4[0] = 0x83; iDiscoveringGUID.Data4[1] = 0x14; iDiscoveringGUID.Data4[2] = 0x08; iDiscoveringGUID.Data4[3] = 0x00; iDiscoveringGUID.Data4[4] = 0x20; iDiscoveringGUID.Data4[5] = 0x0c; iDiscoveringGUID.Data4[6] = 0x9a; iDiscoveringGUID.Data4[7] = 0x66; CString dsp("Discovering services on "); CWidcommFoundDevice* dev = (CWidcommFoundDevice*) iFoundDevices.GetAt(iCurDevice); dsp += dev->iName; iLabel->SetWindowText(dsp); CopyBDADDR(dev->iAddr,iDiscoveringDevice); iDiscoverCommandSent = true; Sleep(3000); // L2CAP needs at least 1 sec to clear previous discovery connection if( StartDiscovery(dev->iAddr, &iDiscoveringGUID) ) /*Sleep(2000)*/; else { if(CWMouseXPDlg::curInstance && !(CWMouseXPDlg::curInstance->iAutoConnectCommand)) MessageBox(iHwnd,"General discovery fault: Try again soon.","Discovey Fault",MB_OK | MB_ICONASTERISK); RevertToIdle(); //add hwnd, icon movement, icon animation rsc numbers, etc... return false; } iCurDevice++; return true; } else return false; }
void AppCallBack(uint32 event, void* eventParam) { #ifdef DEBUG_OUT DebugOut(event, eventParam); #endif switch(event) { case CYBLE_EVT_GAP_DEVICE_DISCONNECTED: Disconnect_LED_Write(LED_ON); case CYBLE_EVT_STACK_ON: StartScan(CYBLE_UUID_HEART_RATE_SERVICE); break; case CYBLE_EVT_GAP_DEVICE_CONNECTED: /* Send authorization request. */ apiResult = CyBle_GapAuthReq(cyBle_connHandle.bdHandle, &cyBle_authInfo); if(CYBLE_ERROR_OK != apiResult) { printf("CyBle_GapAuthReq API Error: %x \r\n", apiResult); } else { printf("Authentification request is sent \r\n"); } Disconnect_LED_Write(LED_OFF); Scanning_LED_Write(LED_OFF); break; case CYBLE_EVT_GAP_AUTH_COMPLETE: hrsConnHandle.bdHandle = cyBle_connHandle.bdHandle; StartDiscovery(); break; case CYBLE_EVT_GATTC_DISCOVERY_COMPLETE: /* Send request to read the body sensor location char. */ apiResult = HrscReadBodySensorLocation(); if(apiResult != CYBLE_ERROR_OK) { printf("HrscReadBodySensorLocation API Error: %x \r\n", apiResult); } else { printf("Body Sensor Location Read Request is sent \r\n"); } break; case CYBLE_EVT_L2CAP_CONN_PARAM_UPDATE_REQ: printf("CYBLE_EVT_L2CAP_CONN_PARAM_UPDATE_REQ: %x, %x, %x, %x \r\n", ((CYBLE_GAP_CONN_UPDATE_PARAM_T *)eventParam)->connIntvMax, ((CYBLE_GAP_CONN_UPDATE_PARAM_T *)eventParam)->connIntvMin, ((CYBLE_GAP_CONN_UPDATE_PARAM_T *)eventParam)->connLatency, ((CYBLE_GAP_CONN_UPDATE_PARAM_T *)eventParam)->supervisionTO ); /* Accepted = 0x0000, Rejected = 0x0001 */ CyBle_L2capLeConnectionParamUpdateResponse(cyBle_connHandle.bdHandle, 0u); break; default: break; } }
void CWidcommHandler::OnInquiryComplete (BOOL success, short num_responses) { StopBTInteractionTimer(); Sleep (100); if(iFoundDevices.GetSize() <=0 ) { //CString str(((CWidcommFoundDevice*) iFoundDevices.GetAt(0))->iName); //TODO: get HWND so message box can be seen this->iLabel->SetWindowText("No nearby Bluetooth devices found"); if(iRequestedCommand == ESendFileSession) { if(CWMouseXPDlg::curInstance && !(CWMouseXPDlg::curInstance->iAutoConnectCommand)) MessageBox(iHwnd,"No nearby Bluetooth devices found.\r\n\r\n- Make sure your PC's Bluetooth is plugged-in/started and ready.\r\n- Make sure your phone's Bluetooth is ON and discoverable (\"show to all\",\"Find me!\",etc.).\r\n- Try Again.\r\n- See \"Help\" for other installation methods.","No nearby devices found",MB_OK | MB_ICONASTERISK); } else { if(CWMouseXPDlg::curInstance && !(CWMouseXPDlg::curInstance->iAutoConnectCommand)) MessageBox(iHwnd,"No nearby Bluetooth devices found.\r\n\r\n- Make sure your PC's Bluetooth is plugged-in/started and ready.\r\n- Make sure your phone's Bluetooth is ON and discoverable (\"show to all\",\"Find me!\",etc.).\r\n- Try Again.","No nearby devices found",MB_OK | MB_ICONASTERISK); } RevertToIdle(); //add hwnd, icon movement, icon animation rsc numbers, etc... return; } if(iRequestedCommand == ESendFileSession) { int SelectedDev=-1; iIcon->Stop(); //let user choose from listbox CSelectPhoneDialog dlg(EWidcommStack,&iFoundDevices,SelectedDev,CWMouseXPDlg::curInstance); if(IDOK == dlg.DoModal() && SelectedDev>=0) { //do obexop to the selected device CString dsp("Discovering services on "); CWidcommFoundDevice* dev = (CWidcommFoundDevice*) iFoundDevices.GetAt(SelectedDev); dsp += dev->iName; iLabel->SetWindowText(dsp); CopyBDADDR(dev->iAddr,iDiscoveringDevice); iDiscoverCommandSent = true; iDiscoveringGUID = ObexObjectPush_guid; iIcon->UnLoad(); iIcon->Load(MAKEINTRESOURCE(iSendAnim),iAnimRscType); iIcon->Draw(); //Sleep(3000); // L2CAP needs at least 1 sec to clear previous discovery connection if( StartDiscovery(dev->iAddr, &ObexObjectPush_guid) ) /*Sleep(2000)*/; else { if(CWMouseXPDlg::curInstance && !(CWMouseXPDlg::curInstance->iAutoConnectCommand)) MessageBox(iHwnd,"General discovery fault: Try again soon.","Discovey Fault",MB_OK | MB_ICONASTERISK); RevertToIdle(); //add hwnd, icon movement, icon animation rsc numbers, etc... return; } } else { RevertToIdle(); //add hwnd, icon movement, icon animation rsc numbers, etc... return; } } else { //start discovering for WMouseXP service on all devices. iCurDevice = 0; //start going through all the devices DoDiscoverWMouseXPThroughDeviceList(); } }