problem with Phonegap connect breakout js

About Forums Forum problem with Phonegap connect breakout js

This topic contains 11 replies, has 2 voices, and was last updated by  Anonymous 3 years, 9 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1027

    Anonymous

    Hi i’m new here. Because of my semester Project, i would like use Breakout js connect my iphone and do my work. Now i just learn the example from the website. by the Hello world.html. i can already through my mac control the LED. but now i want to use my iphone to control the LED. Could you please give some advise. i have already try to replace the localhostname by ip address. But that don’t really work. If some one have idea, please give me favor. thanks!!!

    #1029

    You don’t need to use Phonegap to control the LED from your phone. Your phone needs to be on the same network as the computer the Arduino is connected to.

    Here is the code for the simple_led.html example. See the note above the host variable declaration. You can then serve this page either using the web server built into BreakoutServer or from a separate web server.

    $(document).ready(function() {
    
        // Declare these variables so you don't have
        // to type the full namespace
        var IOBoard = BO.IOBoard;
        var IOBoardEvent = BO.IOBoardEvent;
        var LED = BO.io.LED;
    
        // attach fastclick to avoid 300ms click delay on mobile devices
        FastClick.attach(document.body);
    
        // update this to the IP address of the computer the Arduino is connected to
        var host = "192.168.0.10"; 
        var arduino = new IOBoard(host, 8887);
    
        // Listen for the IOBoard READY event which indicates the IOBoard
        // is ready to send and receive data
        arduino.addEventListener(IOBoardEvent.READY, onReady);
    
        function onReady(event) {
            // Remove the event listener because it is no longer needed
            arduino.removeEventListener(IOBoardEvent.READY, onReady);
    
            // Create an LED object to interface with the LED wired
            // to the I/O board
            var led = new LED(arduino, arduino.getDigitalPin(13));
    
            // jQuery part for the button
            $('#button').click(function () {
                var btn = $(this);
    
                if (btn.text() === "LED On") {
                    btn.text("LED Off");
                } else {
                    btn.text("LED On");
                }
    
                led.toggle();
            });
        }
    });
    
    #1030

    Also if you have a firewall enabled on the computer your Arduino is attached to, make sure port 8887 (or another port if you changed the value) is open.

    #1031

    Anonymous

    thank you for your reply. could you please tell me, how can i serve this the page from a separate web server? i mean, without phone gap i can’t open my html by my phone.

    #1032

    Anonymous

    Here is my code. i think that is the same example as you send me. Now i can through the browser control the LED on and off, that can also know the status of button. but i can’t on my iphone open this example to control that.I also no idea how can i do that. Could you please tell me what should i do, if I want do control the LED on my iphone just like on mac. thank you so much!!!

    $(document).ready(function() {
        // Declare these variables so you don't have
        // to type the full namespace
        var IOBoard = BO.IOBoard;
        var IOBoardEvent = BO.IOBoardEvent;
        var LED = BO.io.LED;
        var Button = BO.io.Button;
        var ButtonEvent = BO.io.ButtonEvent;
    
        // Set to true to print debug messages to console
        BO.enableDebugging = true; 
        
        // If you are not serving this file from the same computer
        // that the Arduino board is connected to, replace
        // window.location.hostname with the IP address or hostname
        // of the computer that the Arduino board is connected to.
        var host = "88.67.48.195"; 
        //window.location.hostname;
        // if the file is opened locally, set the host to "localhost"
        if (window.location.protocol.indexOf("file:") === 0) {
            host = "localhost";
        }
    
        // attach fastclick to avoid 300ms click delay on mobile devices
        FastClick.attach(document.body);
    
        var arduino = new IOBoard(host, 8887);
        
        // Variables
        var led;
        var button;
        var $state = $('#state');
        var $schematic = $('#schematic');
    
        // Handle showing and hiding the schematic
        $('#schematicBtn').on('click', toggleSchematicView);    
    
        // Listen for the IOBoard READY event which indicates the IOBoard
        // is ready to send and receive data
        arduino.addEventListener(IOBoardEvent.READY, onReady);
    #1033

    1. Start BreakoutServer on your computer.
    2. Make sure you phone is connected to the same Wi-Fi network as your computer
    3. Open http://88.67.48.195:8887/examples in you phone web browser
    4. Tap on the simple_led example, you should be able to control the LED on the Arduino board.

    If in step 3 you don’t get the BreakoutJS examples page on your phone, check your firewall settings and make sure port 8887 can get through (google how to do this if you don’t know how) – also make sure you have the IP address of your computer.

    #1034

    Anonymous

    Thank you again!!! Just like you say, my iphone is connecting to the same Wi-Fi Network as my computer. And my Firewall will also be disable. so i think that can absolute port 8887 get through, am i right? but when i open with http://IP-adress:8887/examples, that show me nothing.(it is connected, but there are nothing in there.) I have also tried through hostname.local:8887/examples to open it, but that doesn’t work either. If i use Phonegap (port:3000) that html can open on my phone . I guess that mean, my mac has maybe no problem. Have a idea, where is the Problem, or i do something wrong?

    Thank you very much!

    #1035

    Anonymous

    I have forgot to say. My arduino is Uno. ist that ok? or Uno can totally not work with server?

    #1036

    Anonymous

    I wrote my ip address directly in code like this.

    var arduino = new IOBoard(“xxx.xxx.x.xxx”, 8887);

    I think in this way, the Arduino must through my ip address to visit the code maybe. Whatever, on this way it can perfectly work. but if I write the address in browser, i can find nothing, no matter on my laptop(Mac) or my iphone.That seems like there are no data here. btw my browser is Safari.

    thank you so much !!! T_T

    #1037

    If you open http://IP-adress:8887/examples on your computer does that work?

    Did you move any of the files that came with the Breakout download?

    Where is the BreakoutServer in relation to the Breakout folder?

    #1038

    Also read over this document if you have not already: http://breakoutjs.com/guides/using-breakout-server/#installation

    #1040

    Anonymous

    thank you very much!!!

Viewing 12 posts - 1 through 12 (of 12 total)

The forum ‘Forum’ is closed to new topics and replies.