# Webserver socket server Websocket url ws://159.223.83.48:8080 ## Existing command ### 1. Register (you need register first in order server know the console) #### Send ```json { "topic": "free_shot", "from": "console", "to": "bay", "command": "register", "timestamp": "2019-01-01 00:00:00" } ``` #### Response ##### if device register sucessful ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "data", "msg": "Device register successful", "timestamp": "2019-01-01 00:00:00" } ``` ##### if device already register ```json { "topic": "free_shot", "from": "bay", "to": "console", "command": "error", "msg": "Device already register", "timestamp": "2019-01-01 00:00:00" } ``` ### 2. Start #### Send ```json { "topic": "free_shot", "from": "console", "to": "bay", "command": "start", "data":{ "CustomerId": "639206587039a2f22b209caf", "BaySessionToken": "8ef4df5d-42ac-4fa5-86aa-05e3d4c863fe", "ClubType": "10", "Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyYTM1MzhhYi1kMGMwLTQzOGQtODkwZS1jZjlmY2RlYTEyNTQiLCJFbWFpbCI6ImJheTFAc3ZpaW5nLmNvbSIsIlRva2VuIjoiZTRjN2MyMTctNGFlNi00OTRmLWFhNjktY2VjNjdhNDllOWNkIiwiUmVmcmVzaElkIjoiN2EyYjA3ZjAtYjU2My00MDAzLTgwMTgtMGZlMWQ3MjczMzlhIiwiZXhwIjoxNjc2MjkwNDMwfQ.PZX9EfkoAr1cBjs-qLLcDpdCwUNlxzHCxRwXNm4bYbM" }, "timestamp": "2019-01-01 00:00:00" } ``` #### Response ##### If invalid token (error) ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "error", "message": "Invalid data.Token", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ##### If not bay session token (error) ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "error", "message": "Invalid data.BaySessionToken", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ##### If invalid bay session token or invalid customer id (error) ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "error", "message": "Invalid data.CustomerId, data.BaySessionToken", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ##### If golf ball not ready ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "not_ready", "message": "golf_ball_not_ready", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ##### If golf ball is ready ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "ready", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ### 3. Save video #### Send ```json { "topic": "free_shot", "from": "console", "to": "bay", "command": "save_video", "timestamp": "2019-01-01 00:00:00" } ``` #### Response ##### Saved Successful ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "save_video", "message": "Save Video Success.", "session_id": "e471e490-abd0-11ed-8159-01234559c127", "timestamp": "2019-01-01 00:00:00" } ``` ##### If invalid token ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "save_video_error", "message": "Invalid data.Token", "message": "Invalid data.BaySessionToken", "message": "Invalid data.CustomerId, data.BaySessionToken", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ##### If not bay session token ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "save_video_error", "message": "Invalid data.BaySessionToken", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ##### If invalid bay session token or invalid customer id ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "save_video_error", "message": "Invalid data.Token", "message": "Invalid data.BaySessionToken", "message": "Invalid data.CustomerId, data.BaySessionToken", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ### 4. Ready #### Send ```json { "topic": "free_shot", "from": "console", "to": "bay", "command": "ready", "data":{ "CustomerId": "639206587039a2f22b209caf", "BaySessionToken": "8ef4df5d-42ac-4fa5-86aa-05e3d4c863fe", "ClubType": "10", "Token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIyYTM1MzhhYi1kMGMwLTQzOGQtODkwZS1jZjlmY2RlYTEyNTQiLCJFbWFpbCI6ImJheTFAc3ZpaW5nLmNvbSIsIlRva2VuIjoiZTRjN2MyMTctNGFlNi00OTRmLWFhNjktY2VjNjdhNDllOWNkIiwiUmVmcmVzaElkIjoiN2EyYjA3ZjAtYjU2My00MDAzLTgwMTgtMGZlMWQ3MjczMzlhIiwiZXhwIjoxNjc2MjkwNDMwfQ.PZX9EfkoAr1cBjs-qLLcDpdCwUNlxzHCxRwXNm4bYbM" }, "timestamp": "2019-01-01 00:00:00" } ``` #### Response ##### If invalid token (error) ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "error", "message": "Invalid data.Token", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ##### If not bay session token (error) ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "error", "message": "Invalid data.BaySessionToken", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ##### If invalid bay session token or invalid customer id (error) ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "error", "message": "Invalid data.CustomerId, data.BaySessionToken", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ##### If golf ball not ready ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "not_ready", "message": "golf_ball_not_ready", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ##### If golf ball is ready ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "ready", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ### 5. Stop #### Send ```json { "topic": "free_shot", "from": "console", "to": "bay", "command": "stop", "timestamp": "2019-01-01 00:00:00" } ``` ## Debug message(will remove in production) ### 1. Send sensor data #### Send ```json { "topic": "free_shot", "from": "send sensor data" } ``` #### Response ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "data", "message": "golf_ball_data", "timestamp": "2019-01-01 00:00:00", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "data": { "total_distance": 100, "ball_speed": 100, "club_speed": 200, "apex_height": 100, "carry_distance": 100, "closed_shot": 2, "launch_angle": 3 } } ``` ### 2. Place the golf ball #### Send ```json { "topic": "free_shot", "from": "place golf ball" } ``` #### Response ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "ready", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ### 3. Send ball flight data (abbadon) #### Send ```json { "topic": "free_shot", "from": "send golf flight data" } ``` #### Response ```jsonld ``` ### 4. Remove the golf ball #### Send ```json { "topic": "free_shot", "from": "remove golf ball" } ``` #### Response ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "not_ready", "message": "golf_ball_not_ready", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00" } ``` ### 5. Query Status - Query Device status #### Send ```json { "topic": "free_shot", "from": "console", "to": "bay", "command": "query", "timestamp": "2019-01-01 00:00:00" } ``` #### Response ```jsonld { "topic": "free_shot", "from": "bay", "to": "console", "command": "query", "msg": { "sensor": { "status": "offline", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d" }, "back": { "status": "offline" }, "front": { "status": "offline" }, "console": { "status": "online" } }, "timestamp": "2019-01-01 00:00:00" } ``` ### 6. Send golf flight data middle #### Send ```json { "topic": "free_shot", "from": "send golf flight data middle" } ``` #### Response ```jsonid { "topic": "free_shot", "from": "bay", "to": "console", "command": "data", "message": "golf_flight_data_middle", "timestamp": "2019-01-01 00:00:00", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "data": { "total_distance": 100, "time_taken": 6, "apex_height": 10, "launch_angle": 0 } } ``` ### 7. Send golf flight data left #### Send ```json { "topic": "free_shot", "from": "send golf flight data left" } ``` #### Response ```jsonid { "topic": "free_shot", "from": "bay", "to": "console", "command": "data", "message": "golf_flight_data_left", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00", "data": { "total_distance": 100, "time_taken": 6, "apex_height": 10, "launch_angle": -30 } } ``` ### 8. Send golf flight data right #### Send ```json { "topic": "free_shot", "from": "send golf flight data right" } ``` #### Response ```jsonid { "topic": "free_shot", "from": "bay", "to": "console", "command": "data", "message": "golf_flight_data_right", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00", "data": { "total_distance": 100, "time_taken": 6, "apex_height": 10, "launch_angle": 30 } } ``` ### 9. Send golf flight data high #### Send ```json { "topic": "free_shot", "from": "send golf flight data high" } ``` #### Response ```jsonid { "topic": "free_shot", "from": "bay", "to": "console", "command": "data", "message": "golf_flight_data_high", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00", "data": { "total_distance": 100, "time_taken": 6, "apex_height": 20, "launch_angle": 3 } } ``` ### 10. Send golf flight data low #### Send ```json { "topic": "free_shot", "from": "send golf flight data low" } ``` #### Response ```jsonid { "topic": "free_shot", "from": "bay", "to": "console", "command": "data", "message": "golf_flight_data_low", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00", "data": { "total_distance": 100, "time_taken": 6, "apex_height": 5, "launch_angle": -3 } } ``` ### 11. Send golf flight data long #### Send ```json { "topic": "free_shot", "from": "send golf flight data long" } ``` #### Response ```jsonid { "topic": "free_shot", "from": "bay", "to": "console", "command": "data", "message": "golf_flight_data_long", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00", "data": { "total_distance": 250, "time_taken": 8, "apex_height": 10, "launch_angle": 1 } } ``` ### 12. Send golf flight data short #### Send ```json { "topic": "free_shot", "from": "send golf flight data short" } ``` #### Response ```jsonid { "topic": "free_shot", "from": "bay", "to": "console", "command": "data", "message": "golf_flight_data_short", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00", "data": { "total_distance": 30, "time_taken": 3, "apex_height": 5, "launch_angle": -3 } } ``` ### 13. Send golf flight data fast #### Send ```json { "topic": "free_shot", "from": "send golf flight data fast" } ``` #### Response ```jsonid { "topic": "free_shot", "from": "bay", "to": "console", "command": "data", "message": "golf_flight_data_fast", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00", "data": { "total_distance": 75, "time_taken": 3, "apex_height": 10, "launch_angle": -3 } } ``` ### 14. Send golf flight data slow #### Send ```json { "topic": "free_shot", "from": "send golf flight data slow" } ``` #### Response ```jsonid { "topic": "free_shot", "from": "bay", "to": "console", "command": "data", "message": "golf_flight_data_slow", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00", "data": { "total_distance": 30, "time_taken": 3, "apex_height": 5, "launch_angle": -3 } } ``` # API API url https://flask.sviing.com ## {{sviing_server}}/run_video Trigger posture video api, websocket send you the golfer posture video #### Response ```jsonls= { "topic": "free_shot", "from": "bay", "to": "console", "command": "video_data", "timestamp": "2019-01-01 00:00:00", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "data": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAIBAQEBAQIBAQ1wXgLQX8JeJAdW039a9Y8PeAc6pdZHF1+/+y16OZuN20dWL2PHPjR8IZfA6jXtPO7Trn7pPWvPlbPIr6e/aDJ/4UV/wj3/COf8AMet9Q/tH/nhF5Do8f/Avkr5TUgHJr3ssqvE4ZNntYC8sPqeh+HfjPq3h74Ma/wDBgg/2dr11bXf/AFxuIZP9Z/7LXF0UV1pJHpkf9pL6GpKKKenQxTuXedSPpj9Kh+xN61v6D/xLdNJ9Kg01f7SIxXL7RxvbY5SHTdNBGAeavDQNUAxt/Strw9pZ/tT/AJ9R9pqn491P/iobo6YDj7V1rm55zloc3+8n2x+zD8Z/DuqaD4U+Eg8PXR1H7Nj7X/qvIi+zPv8A/H678+PfEPi/VbXxf4C8Rf8AFM6Pr/ka+f8An7ih8mZ/4P8AP/Aq+SfGPi8+DfAXhPxHpWqfZdRutI62v/LCuI8AftBeL/AngPXvCB/0kax/z9XP/kSvnVkznL2y3PF/sH/l+fYfxn+M/h3xh4e8W+PNLNra3X2q41XSLW6/55eXs+f/AHv/AEKvgTxIf7S1P+09UJwTXSeLfFx8Q/Zd2pdLXyea47VNB1EtnBr0snwiwkdXZnq5dhvqpXH/ACEfw/pWpoG3ef7UrFrZf7xr1auiR3Yndl7U+31qLXs55/4+am/4mVQc6ia5IuzucZy1WK09S0Aisz/iZV6Kkpo9W1jd0vVNKx/xM63P7LOli11MH/Ra5z/qKVq/2WdLP/IU+1Vg7CN//hHdLz/xK9U/0X/n1rD/AOJpj/iWf8e1T4P9l/2dp3jDTfH5F1p1154P2RP3/8A0zfj7jf+z1810VvyWD6jh30PsT9q7/gsp+1F+1Z4APwm1U6NoGg3/OsWugW0kUuof9dnLtlP9j86+UDr5zxWWUI6c05TkdMVtJPEOzNPq1BdC3Pq816cSrVf7YfQ/nUNFZ2RvZBRRRTGFFFFABRRRQB1Xjbwj/wjtkpHc1ytensnjb4lfDrXvFmuazoNta6M0YFvd6vFDcHzOiQWufNuPucvtYLj94w+WvMKxoXtZkxCiirkels+ltqOeBcRxf8AfQk/+IrVtIop0Va/s3Uf7hqrQncAp/7n3plFFhWLPl2f/P635Gl/s5P+gjbf99f/AFqq0UrPuMs/YD/cX/wJSnf2Hqn/AD5NVSiizAs/2XqX/QPuP/Ac1Wqx/aOo/wDP7N/30asxeKfEVqcQ63cD/gZp6i1M/e3rRvb1rW/4TPXf+fhP/AZP8K" } ``` ## {{sviing_server}}/run_live_video Trigger live video api, websocket send you the live video #### Websocket Response ```jsonls= { "topic": "free_shot", "from": "bay", "to": "console", "command": "live_video_data", "session_id": "a3280520-a9e4-11ed-b672-01234572b68d", "timestamp": "2019-01-01 00:00:00", "data": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBD" } ``` ## {{sviing_server}}/kill_live_video kill live video api #### API Response (websocket will not response you anything) ```jsonls= { "message": "kill live video", "status": "success" } ```