Developer Portal Community

    cancel
    Showing results for 
    Search instead for 
    Did you mean: 

    XTcpServer

    Highlighted
    Occasional Visitor

    XTcpServer

    Has anyone successfully used the Serval XTcp server to allow tcp connections to the XDK ? In a test implementation I started a listener on port 9999 and when I checked, the port was open, however when connecting (python script) and sending data I didn't see either the appSendCallback or the appRecvCallback function call (nothing from those functions was printed to the console). The port also was closed after the first connection.

    Relevant code:

    void appReceiveCallback(uint8_t sessionId, Msg_T *msg_ptr, retcode_t status) {
    	printf("appReceiveCallback entered \r\n");
    	//Get peer information from the message pointed
    	Ip_Address_T peerIpAddress;
    	uint16_t peerPort;
    	char peerIpAddressString[15];
    	Retcode_T rc = RETCODE_OK;
    	XTcp_getPeer(msg_ptr, &peerIpAddress, &peerPort);
    	// Convert address to string
    	rc = Ip_convertAddrToString(&peerIpAddress, peerIpAddressString);
    
    	if (0 > rc) {
    		printf("IP conversion to string has failed! \r\n");
    	}
    
    	printf("[TCE] : Peer IP is : %s:%d\r\n", peerIpAddressString, peerPort);
    }
    
    void appSendCallback(uint8_t sessionId, Msg_T *msg_ptr, retcode_t status) {
    	printf("Entered appSendCallback");
    }
    
    void AppController_Init(void * cmdProcessorHandle, uint32_t param2)
    {
        BCDS_UNUSED(param2);
    
        Retcode_T retcode = RETCODE_OK;
    
        if (cmdProcessorHandle == NULL)
        {
            printf("AppController_Init : Command processor handle is NULL \r\n");
            retcode = RETCODE(RETCODE_SEVERITY_ERROR, RETCODE_NULL_POINTER);
        }
        else
        {
            AppCmdProcessor = (CmdProcessor_T *) cmdProcessorHandle;
            retcode = CmdProcessor_Enqueue(AppCmdProcessor, AppControllerSetup, NULL, UINT32_C(0));
        }
    
        if (RETCODE_OK != retcode)
        {
            Retcode_RaiseError(retcode);
            assert(0); /* To provide LED indication for the user */
        }
    
        WlanConnect_SSID_T connectSSID = (WlanConnect_SSID_T) "SSID";
        WlanConnect_PassPhrase_T connectPassPhrase = (WlanConnect_PassPhrase_T) "passphrase";
        WlanConnect_Init();
        WlanConnect_WPA(connectSSID, connectPassPhrase, NULL);
        PAL_initialize();
        PAL_socketMonitorInit();
    
        if (RC_OK != XTcpServer_initialize()) {
        	printf("XTcp initialization failure \r\n");
        }
        Ip_Port_T serverPort = Ip_convertIntToPort(9999);
    
        // Start TCP Server
        if (RC_OK == XTcpServer_listen(serverPort, appSendCallback, appReceiveCallback)) {
        	printf("TCP Server Started...\r\n");
        }
        else {
        	printf("TCP Server Not Started!\r\n");
        }
    }

     

    2 REPLIES 2
    Highlighted
    Community Manager
    Community Manager

    Re: XTcpServer

    Hi willsonnate1, thanks for your question to the community, we'll also check with some xdk experts to see if they have any input!

    Highlighted
    New Poster

    Re: XTcpServer

    Hello willsonnate1,

    I have not explored the Serval XTcp Server yet. But then again, since XTcp is proprietary protocol, I would suggest you to make use of another device which runs the Serval XTcp Client to connect to the server rather than using the python script. Please note that the stack also suggest to provide proper initial delay after initiating connection to the server, as connection will not be opened immediately. The three-way handshake needs to be completed first. Will this be taken care in your python script ?

    Once if using the XTcp Client also doesn't take you further,  I would suggest you to make sure whether the AppControllerSetup is getting executed properly before starting with WlanConnect_Init().

    If still the problem persists, please feel free to post further details as it would be quite interesting to look further.

    Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist