Software Archive
Read-only legacy content
17061 Discussions

How to import Chrome sockets TCP

Jean-Louis_A_
Beginner
771 Views

Hello,

I am developing a communication between an Android smartphone and a wifi unit (ESP8266) with tcp sockets. I have already done successfully with a Windows PC.

I created an HTML5 + Cordova project with the XDK environment.

I used the "Third-Party Add-Plugin" and imported "org.chromium.sockets.tcp", with "Plugin is Located in the Apache Cordova Plugins Registry".

My code:

 /* button  Create socket */
    $(document).on("click", ".uib_w_1", function(evt)
    {
        /* your code goes here */ 
        
        alert ("Creation sockets");
        
        chrome.sockets.tcp.create ({},
                                   function (createInfo)                                                                                                  {chrome.sockets.tcp.connect(createInfo.socketld,"192.168.4.1",1336,onConnected);
                                    }
                                   );
                                  
        // fin de code Create sockets
    });

In debug I get the following message:

"Uncaught ReferenceError: chrome is not defined index_user_scripts.js:18(anonymous function) index_user_scripts.js:18(anonymous function) appframework.js:2552proxyfn appframework.js:2377touchLayer.fireEvent appframework.ui.js:3415touchLayer.onTouchEnd appframework.ui.js:3358touchLayer.handleEvent"

Apparently XDK reaches not to import the Chrome plugin .

Can anyone help me?

Thanks for your help.

0 Kudos
5 Replies
Amrita_C_Intel
Employee
771 Views

Hello,

Please refer these links which might solve your problem.

I believe you need to change the order of .JS files under script tag. 

https://software.intel.com/en-us/forums/intel-xdk/topic/555056

http://stackoverflow.com/questions/2075337/uncaught-referenceerror-is-not-defined

0 Kudos
Jean-Louis_A_
Beginner
771 Views

Thank you for the answer, but after search, it appears that XDK does not support modes "Debug" and "Test" in the case of thrid party plugin,  only the "Build" mode is possible.
With "Build" it runs fine, but the development cycle has a little long time. Each time we have to build application, donwload, install  it and test on the smartphone.

0 Kudos
PaulF_IntelCorp
Employee
771 Views

Try using the EA release, it supports the use of third-party plugins with the Debug tab. Our next major release of the XDK will also support the use of third-party plugins with the Debug tab, in a few weeks.

BTW - the latest version available in the git repo is labeled 1.3.4, which is more recent than what you are getting from the plugin registry. For those CCA plugins you're probably better off getting them straight from the repo, because that project has gone quiet. To do that with the current release of the XDK you can specify the plugin as being located in a git repo and naming it like this:

https://github.com/MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcp.git#1.3.4

And since the forum is probably going to clip what I just wrote, above, because it wants to turn it into a link, I'll repeat it, below, with spaces that you need to remove to turn it into the complete URL that you need to provide to the XDK:

https: // github.com/MobileChromeApps/cordova-plugin-chrome-apps-sockets-tcp.git # 1.3.4

(remove the spaces in the line above)

See the main readme for that project: https://github.com/MobileChromeApps/mobile-chrome-apps

0 Kudos
Jean-Louis_A_
Beginner
771 Views

What is the "EA release" ?

0 Kudos
Reply