Announcement

Collapse
No announcement yet.

PHPoC Debugger screenshot for help (Thank's Khanh)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHPoC Debugger screenshot for help (Thank's Khanh)

    Hi Khanh, here is JPEG file about screenshot of PHPoC debugger

  • #2
    Dear Stéphane Mancini,

    I tested again, there maybe something missed in system file by accident.

    Could you please upgrade new system files via the below instruction:
    https://forum.phpoc.com/forum/phpoc-...phpoc-shield-1

    This also updates some new features from PHPoC Shield 2.

    After upgrading, please upload login.php file again and test it.

    Comment


    • #3
      • Hello Khanh. So, concerning the PHPoC debugger, I re-downloaded the 1.5.0 version (already installed) and copy all the files from GitHub phpoc-shield2. Concerning Arduino IDE, PHPoC library Version 1.5.0 is well installed. I use Arduino Mega board and PHPoC Shield 1 (P4S-348). Unfortunately, same issue. I have tried some PHPoC examples from Arduino IDE like WebRemotePad, Push and Slide and all three work well. Output Log from PHPoC,debugger displays only : PHPoC Shield / P4S-348 1.5.0. , nothing else. I also tried an other project find on youtube (https://www.youtube.com/watch?v=5n7WZFef4mY) with Arduino Uno, PHPoC Shield, Grove Camera and it works perfectly. I think there is no hardware issues. If you have other ideas to help me thank's. Regard's.

      Comment


      • #4
        Hello Stéphane Mancini,
        Now we can debug step by step. Firstly try to remove all camera and Google Oauth code on Arduino side

        Code:
        #include <Phpoc.h>
        #include <Arduino_JSON.h>
        
        // Replace your GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET here
        String GOOGLE_CLIENT_ID = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.app s .googleusercontent.com";
        String GOOGLE_CLIENT_SECRET = "xxxxxxxxxxxxxxxxxxxxxxxx";
        PhpocServer websocket_server(80);
        
        int buttonState;
        int lastButtonState = LOW;
        unsigned long lastDebounceTime = 0;
        unsigned long debounceDelay = 50;
        
        
        void setup(){
        Serial.begin(115200);
        while(!Serial)
        ;
        
        Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
        websocket_server.beginWebSocket("login");
        Serial.print("WebSocket server address : ");
        Serial.println(Phpoc.localIP());
        
        pinMode(2, INPUT);
        
        }
        
        void loop(){
        PhpocClient client = websocket_server.available();
        
        if (client) {
        String ws_str = client.readLine();
        
        Serial.println(ws_str);
        }
        }
        Please compile and upload that code to Arduino, and then access login page in PHPoC Shield.
        The output in Serial Monitor should be like:
        log> sppc_begin: package 1.5.0
        log> sppc_begin: WiFi INFRA phpoc_wifi ch9
        log> sppc_begin: IPv4 192.168.0.234 255.255.255.0 192.168.0.1 8.8.8.8
        log> phpoc_server : listen 2/80
        WebSocket server address : 192.168.0.234
        google
        Please tell me the result and we can do the next step of debuging

        Comment


        • #5
          Hello Khanh,

          here is my IDE Serial Monitor display after downloading the code above in my Arduino Mega Board :


          log> sppc_begin: phpoc shield, firmware 1.5.0
          log> sppc_begin: package 1.5.0
          log> sppc_begin: WiFi INFRA pacsou ch1
          log> sppc_begin: IPv4 192.168.0.29 255.255.255.0 192.168.0.254 212.27.40.241
          log> phpoc_server : listen 2/80
          WebSocket server address : 192.168.0.29

          Comment


          • Khanh
            Khanh commented
            Editing a comment
            did you access login.php on PHPoC Shield before geting the above log ?

        • #6
          Hi, yes I can access login.php but always the same page where it is written Google, Login for Arduino with a rotating icon. However, I don't have a message asking me to reload the page.

          Comment


          • #7
            If so, there is no problem with network.
            Problem might be on Camera.
            In the original code, please add a Serial.println("debug point"); right after cameraInit(CT_JPEG, PR_160x120, JR_640x480); to check if this function block other operation or not?

            PS: I made this project not for commercial, therefore, the camera library may contain bugs that blocks operation in infinitive loop

            Comment


            • #8
              Hello Khanh, "debug point" appears in the IDE Serial Monitor if Serial.println("debug point") is added right after cameraInit(CT_JPEG, PR_160x120, JR_640x480). So Camera library seems good, no infinitive loop. But, quietly, I started all over again including the connections and a miracle begins to happen. When I reload the login.php page, now, Arduino board responds. Here is the IDE Serial Monitor display :

              log> sppc_begin: phpoc shield, firmware 1.5.0
              log> sppc_begin: package 1.5.0
              log> sppc_begin: WiFi INFRA pacsou ch1
              log> sppc_begin: IPv4 192.168.0.29 255.255.255.0 192.168.0.254 212.27.40.241
              log> phpoc_server : listen 2/80
              WebSocket server address : 192.168.0.29

              log> phpoc_server: connected 2
              log> phpoc_server : listen 3/80
              log> dns: query A accounts.google.com >> 216.58.215.45
              log> phpoc_client: connectSSL 0 >> success
              Connected to server
              log> phpoc_client: close 0 >> closed
              Invalid resonse from Google
              log> phpoc_client: close 2 >> closed
              log> phpoc_server: connected 3
              log> phpoc_server : listen 2/80
              log> dns: query A accounts.google.com >> 216.58.215.45
              log> phpoc_client: connectSSL 0 >> success
              Connected to server
              log> phpoc_client: close 0 >> closed
              Invalid resonse from Google


              And if i press the button to take a photo : "access_token is invalid, please login again" is displayed.

              What do you think about that ?

              Thank's Khanh
              Last edited by Stéphane Mancini; 08-06-2020, 05:52 AM.

              Comment


              • #9
                That's great!

                Now problem is on google login.

                To find out the reason and solution, please read the following tutorials:These above article described how it work and how to do it. The first article does not use Arduino, but working principle is the same.

                And for debugging. In original Arduino code, lines 163 and 164 look like below
                Code:
                //Serial.println(response_hearder);
                //Serial.println(response_body);
                Uncomment these line to see the response from Google. You can know the reason why Google reject it, and then we can fix it.

                Comment


                • #10
                  Hi Khanh,
                  I would have liked to tell you that it works but not yet. First of all, in order to debug, if I uncomment lines 163 and 164 in the orignal Arduino code, there is nothing more displayed in the Serial Monitor IDE. However, if I uncomment lines 82 and 83 (http_resp_hearder(client) and http_resp_body(client)) , here is what the Serial Monitor displays:

                  log> sppc_begin: phpoc shield, firmware 1.5.0
                  log> sppc_begin: package 1.5.0
                  log> sppc_begin: WiFi INFRA pacsou ch1
                  log> sppc_begin: IPv4 192.168.0.29 255.255.255.0 192.168.0.254 212.27.40.241
                  log> phpoc_server : listen 2/80
                  WebSocket server address : 192.168.0.29

                  log> dns: query A accounts.google.com >> 172.217.19.237
                  log> phpoc_client: connectSSL 0 >> success
                  Connected to server
                  log> phpoc_client: close 0 >> closed
                  HTTP/1.1 401 Unauthorized
                  Cache-Control: no-cache, no-storPragma: no-cache
                  Expires: Mon, 01 Jan 1990 00:00:date: Thu, 06 Aug 2020 21:14:06 Content-Type: application/json; Vary: X-Origin
                  Vary: Referer
                  Server: ESF
                  X-XSS-Protection: 0
                  X-Frame-Options: SAMEORIGIN
                  X-Content-Type-Options: nosniff Alt-Svc: h3-29=":443"; ma=259200Accept-Ranges: none
                  Vary: Origin,Accept-Encoding
                  Connection: close
                  Transfer-Encoding: chunked

                  4e
                  {
                  "error": "invalid_client",
                  "error_description": "Invalid client type."
                  }
                  0

                  Invalid resonse from Google
                  log> phpoc_server: connected 2
                  log> phpoc_server : listen 3/80
                  log> phpoc_client: close 2 >> closed



                  Here is how I proceeded to create a Google access : First, I create a new project. Then, I open the API Library and I active Google Drive API. Then, in the credentials page, I create an OAuth client ID (application WEB selected) and download the Client ID and Client Secret. Put them in the Arduino sketch and download to the Arduino Mega Board. That's it. Perhaps I forgot something.

                  Thank's
                  Last edited by Stéphane Mancini; 08-07-2020, 06:53 AM.

                  Comment


                  • #11
                    Hello,
                    When creating Oauth Client ID, please do NOT choose "Web Application", choose "TVs and Limited Input Device" instead. See the below image:

                    Click image for larger version

Name:	google.png
Views:	32
Size:	169.2 KB
ID:	1790
                    Last edited by Khanh; 08-07-2020, 08:18 AM.

                    Comment


                    • #12
                      Hello Khanh, after selecting TVs and Limited Input devices, now in the Serial Monitor, I have a Parsing input failed!.

                      However there is better because I receive a CODE that works if I log it (https://www.google.com/device). Device is connected to my google account.


                      Unfortunately, if I press the button to take picture, "access_token is invalid, please login again" appers in the IDE Serial Monitor.

                      Any ideas ?

                      Thank's



                      log> sppc_begin: phpoc shield, firmware 1.5.0
                      log> sppc_begin: package 1.5.0
                      log> sppc_begin: WiFi INFRA pacsou ch1
                      log> sppc_begin: IPv4 192.168.0.29 255.255.255.0 192.168.0.254 212.27.40.241
                      log> phpoc_server : listen 2/80
                      WebSocket server address : 192.168.0.29

                      log> phpoc_server: connected 2
                      log> phpoc_server : listen 3/80
                      log> dns: query A accounts.google.com >> 216.58.209.237
                      log> phpoc_client: connectSSL 0 >> success
                      Connected to server
                      log> phpoc_client: close 0 >> closed
                      HTTP/1.1 200 OK
                      Expires: Mon, 01 Jan 1990 00:00:Pragma: no-cache
                      Cache-Control: no-cache, no-storDate: Fri, 07 Aug 2020 11:17:16 Content-Type: application/json; Vary: X-Origin
                      Vary: Referer
                      Server: ESF
                      X-XSS-Protection: 0
                      X-Frame-Options: SAMEORIGIN
                      X-Content-Type-Options: nosniff Alt-Svc: h3-29=":443"; ma=259200Accept-Ranges: none
                      Vary: Origin,Accept-Encoding
                      Connection: close
                      Transfer-Encoding: chunked

                      f5
                      {
                      "device_code": "AH-1Ng2KiOkZGXD6WVqgpuXH95gAfU-rrzIJFe4ooOHykhd9l4sloX206wPbHTI0IYSdV_Xv7Yuupmd_g fmEgE7FYlmXzHp04g",
                      "user_code": "FGC-BWQ-PJJ",
                      "expires_in": 1800,
                      "interval": 5,
                      "verification_url": "https://www.google.com/device"
                      }
                      0


                      Parsing input failed!
                      log> phpoc_client: close 2 >> closed

                      Comment


                      • #13
                        Hello,
                        It almost works.
                        That error is because Google changed to return data encoded in chunk. Please try changing client.println(F("POST /o/oauth2/device/code HTTP/1.1")); to client.println(F("POST /o/oauth2/device/code HTTP/1.0"));

                        If it still does not work, you can modify the code to manually remove some unnecessary characters before parsing

                        Comment


                        • #14
                          Hi Khanh,
                          effectively it's almost almost good.

                          Another little problem I need your help for. After changing HTTP/1.1 to HTTP/1.0, now I have the login.php page with the CODE display and I can connect my device to google. But, after connecting the device and come back to the login.php page, I don't have the : " Success, You are now logged in from Arduino via PHPoC Shield" .

                          On the IDE Serial Monitor, I have first a : "
                          phpoc_client: connectSSL 0 >> failed" and after : "phpoc_client: SSL socket not available"

                          thank's again.


                          Here is the complete Serial Monitor display :


                          log> sppc_begin: phpoc shield, firmware 1.5.0
                          log> sppc_begin: package 1.5.0
                          log> sppc_begin: WiFi INFRA pacsou ch1
                          log> command: head wait timeout
                          log> sppc_begin: IPv4 192.168.0.29 255.255.255.0 192.168.0.254 212.27.40.241
                          log> phpoc_server : listen 2/80
                          WebSocket server address : 192.168.0.29

                          log> dns: query A accounts.google.com >> 216.58.204.141
                          log> phpoc_client: connectSSL 0 >> success
                          Connected to server
                          log> phpoc_client: close 0 >> closed
                          HTTP/1.0 200 OK
                          Pragma: no-cache
                          Expires: Mon, 01 Jan 1990 00:00:date: Mon, 10 Aug 2020 16:16:12 Cache-Control: no-cache, no-storContent-Type: application/json; Vary: X-Origin
                          Vary: Referer
                          Server: ESF
                          X-XSS-Protection: 0
                          X-Frame-Options: SAMEORIGIN
                          X-Content-Type-Options: nosniff Alt-Svc: h3-29=":443"; ma=259200Accept-Ranges: none
                          Vary: Origin,Accept-Encoding

                          {
                          "device_code": "AH-1Ng0S2oew11rGTcFKab9pOP1B22Ah5jg8brv7ooJtbU58qfdLv 2OohjQDFyvlX9C0Wgg9aY4nvTXZ76UnkvMr0KKZMxtIdA",
                          "user_code": "JNZL-GFFM",
                          "expires_in": 1800,
                          "interval": 5,
                          "verification_url": "https://www.google.com/device"
                          }
                          Next, visit https://www.google.com/device on your desktop or smartphone and enter this code: JNZL-GFFM
                          log> phpoc_server: connected 2
                          log> phpoc_server : listen 3/80
                          log> dns: query A www.googleapis.com >> 216.58.201.234
                          log> phpoc_client: connectSSL 0 >> failed
                          log> dns: query A www.googleapis.com >> 216.58.213.74
                          log> phpoc_client: SSL socket not available
                          log> dns: query A www.googleapis.com >> 216.58.206.234
                          log> phpoc_client: SSL socket not available
                          log> dns: query A www.googleapis.com >> 216.58.201.234
                          log> phpoc_client: SSL socket not available

                          Comment


                          • #15
                            Could you please show firmware log on PHPoC when this happen?

                            Comment

                            Working...
                            X