3 Replies Latest reply on Mar 19, 2020 11:42 PM by RaktimR_11

    Wicked WiFi app write to server

    JeCr_2235141

      Hello,

       

      I purchased the cypress WiFi wiced dev kit for iot development.  The CY943907 development kit. 

      https://www.cypress.com/documentation/development-kitsboards/cyw954907aeval1f-evaluation-kit

       

       

      There is some application within our organization for remote monitoring of some tools I would like to develop.  I had intended to do this via amazon web services, however company policy is to avoid 3rd party cloud services at the moment.

       

      Instead of AWS or other cloud streaming, I would like to try to use the kit for writing to a local server.  As a first step, I would like to use the weather station tutorial and log json data onto a local server that can be accessed on demand.  We can parse the JSON data for plotting on needed basis.  I was not sure how to transition this however.  I am working on this using an XAMP server for example, and would just like to write a JSON file to the localhost.

       

      I am very new to this area, and I am having a hard time locating such kind of instruction as most tutorial are about iot streaming applications.  I think perhaps my application is more simple, and would appreciate any support you can provide.   This would include how to modify existing Scripts from ww01 git hub repository to meet this requirement.  I would then tailor our application to the needs of our engineering team, and eventually layout the pcb board for defining this product.

       

      Thanks for any input, and I would be glad to answer any questions you might have.

        • 1. Re: Wicked WiFi app write to server
          RaktimR_11

          I believe you are trying to create a .json data and send that onto your local server. WICED has two json libraries to help you with the parsing part (43xxx_Wi-Fi/libraries/utilities/cJSON, 43xxx_Wi-Fi/libraries/utilities/JSON_parser) . Maybe, you can manually create that using sprintf or a char pointer for fixed size data or use the cJSON library itself to create the JSON formatted data.

           

          • For sprintf reference, you can look at 43xxx_Wi-Fi/apps/demo/iot_gateway/gateway.c
          • For a fixed size data,

            const char* const json_string =
            "{ \
              \"cars\"
            : [\
              
            {\
              \"
            CarType\": \"BMW\",\
              \"carID\"
            : \"bmw123\"\
              
            },\
              
            {\
              \"
            CarType\": \"mercedes\",\
              \"carID\"
            : \"merc123\"\
              
            },\
              
            {\
              \"
            CarType\": \"volvo\",\
              \"carID\"
            : \"vol123r\"\
              
            },\
              
            {\
              \"
            CarType\": \"ford\",\
              \"carID\"
            : \"ford123\"\
              
            }\
             
            ]\
            }\
            ";

          • For cJSON library to create the data and print, you can refer to 43xxx_Wi-Fi/libraries/utilities/cJSON/README.md

           

          If all of the above fails, you can use some open-source third party library to create and parse json as well; e.g. 43xxx_Wi-Fi/libraries/third_party/arrow/libs/acn_sdk_c/src/json (not sure whether this is available in broad market SDK). If you are following the WICED WIFI 101 lesson, CypressAcademy_WW101_Files/Projects/ww101key/04 at master · cypresssemiconductorco/CypressAcademy_WW101_Files · GitHub, should provide you with two examples of creating and parsing json object. Once, you are comfortable with the json side of things, you can use your WICED device as a HTTP client and use something like mongoose to test it on a local PC (provided STA and the PC has to be connected to the same network)

           

          Hope this helps!

          • 2. Re: Wicked WiFi app write to server
            JeCr_2235141

            Hello,

             

            Thank-you for your time and interest in answering this question.  I would like to learn through development of application, and I appreciate this support.  Perhaps I can be more explicit.

             

            I would like to adapt the script from the following:

            CypressAcademy_WW101_Files/Projects/ww101key/08/01_weather_station_http at master · cypresssemiconductorco/CypressAcadem…

             

            This script is already assembling a JSON format file.  I would like  to write this data to an IP address, such as localhost of computer, or some other location for recording the datalog.  The data can then be parsed / plotted offline using other tools, but the important function of remotely writing data via WIFI using this template is my interest.

             

            Could you suggest edits I can make to this example to achieve this end?  This is a development project for implementing wireless monitoring in our manufacturing facility and would be quite useful.

             

            Thanks,

            • 3. Re: Wicked WiFi app write to server
              RaktimR_11

              In the mentioned example, to connect to a local server, you just need to change the following two macros:

              SERVER_HOST and SERVER_PORT based on the server ip address and the port at which it is hosted at. If you are not using TLS, you can modify HTTP_NO_SECURITY in line #672 when you are trying to connect.