Skip to content

Commit 1fc1855

Browse files
authored
Add OTA API and HTTP Example Guide (#4)
- Add OTA API - Add HTTP example guide
1 parent f325e3a commit 1fc1855

32 files changed

+487
-1
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
Header OTA
2+
==========
3+
4+
.. contents::
5+
:local:
6+
:depth: 2
7+
8+
**OTA Header**
9+
--------------
10+
11+
**Description**
12+
~~~~~~~~~~~~~~~
13+
14+
A header file for OTA API.
15+
16+
**Syntax**
17+
~~~~~~~~~~
18+
19+
NA
20+
21+
**Members**
22+
~~~~~~~~~~~
23+
24+
+-----------------------------------+----------------------------------+
25+
| **Public Constructors** | |
26+
+===================================+==================================+
27+
| NA | NA |
28+
| | |
29+
| | |
30+
+-----------------------------------+----------------------------------+
31+
| **Public Methods** | |
32+
+-----------------------------------+----------------------------------+
33+
| start_OTA_threads | To begin threading tasks for OTA |
34+
| | firmware update. |
35+
+-----------------------------------+----------------------------------+
36+
37+
**start_OTA_threads**
38+
---------------------
39+
40+
**Description**
41+
~~~~~~~~~~~~~~~
42+
43+
To begin threading tasks for OTA firmware update.
44+
45+
**Syntax**
46+
~~~~~~~~~~
47+
48+
.. code-block:: c++
49+
50+
void start_OTA_threads();
51+
52+
**Parameters**
53+
~~~~~~~~~~~~~~
54+
55+
NA
56+
57+
**Returns**
58+
~~~~~~~~~~~
59+
60+
NA
61+
62+
**Example Code**
63+
~~~~~~~~~~~~~~~~
64+
65+
Example: `OTA <https://github.com/ambiot/ambpro2_arduino/blob/dev/Arduino_package/hardware/libraries/OTA/examples/OTA/OTA.ino>`_
66+
67+
.. note :: “ota_thread.h” must be included to use the function.

source/API_Documents/OTA/index.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
OTA
2+
===
3+
4+
.. toctree::
5+
:maxdepth: 1
6+
7+
Header OTA

source/API_Documents/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ API Documents
99
Multimedia/index
1010
NeuralNetwork/index
1111
NTPClient/index
12+
OTA/index
1213
USB/index
1314
Watchdog/index
1415
WiFi/index
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
HTTP Post Image and MP4
2+
=======================
3+
4+
.. contents::
5+
:local:
6+
:depth: 2
7+
8+
Materials
9+
---------
10+
11+
- `AMB82-mini <https://www.amebaiot.com/en/where-to-buy-link/#buy_amb82_mini>`_ x 1
12+
13+
- PushButton x1
14+
15+
- 220 ohm resistor x1
16+
17+
Example
18+
-------
19+
20+
In this example, we are doing a Post request with image and recorded audio file together to LLM Server. This example does not contain integration to the LLM server but integration to the HTTP server.
21+
22+
Then open “File” -> “Examples” -> “AmebaHttp” -> “Capture_Image_HTTP_Post_Image_Llava_Server”
23+
24+
|image01|
25+
26+
Connect the pushbutton and resistor to AMB82 Mini as shown below.
27+
28+
|image02|
29+
30+
Compile and run the example.
31+
32+
Set up the HTTP server by locating the python script called whisper_server_test_2_endpoints.py. Go to command prompt and go to the src folder. Execute this command python3 whisper_server_test_2_endpoints.py.
33+
34+
Please note that this server can only be run on Linux OS. Mac OS and Windows have not been supported yet.
35+
36+
Press button for 2s when you wish to take a snapshot and speak into the mic for the prompt to ask the Visual Language Model (VLM).
37+
38+
If the HTTP Post image and audio file is successful, the image and audio file will be saved at the location where this script is being run at.
39+
40+
.. |image01| image:: ../../_static/Example_Guides/HTTP/HTTP_Post_Image_and_MP4/image01.png
41+
:width: 1032 px
42+
:height: 645 px
43+
44+
.. |image02| image:: ../../_static/Example_Guides/HTTP/HTTP_Post_Image_and_MP4/image02.png
45+
:width: 988 px
46+
:height: 802 px
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
HTTP Post MP4
2+
=============
3+
4+
.. contents::
5+
:local:
6+
:depth: 2
7+
8+
Materials
9+
---------
10+
11+
- `AMB82-mini <https://www.amebaiot.com/en/where-to-buy-link/#buy_amb82_mini>`_ x 1
12+
13+
- PushButton x1
14+
15+
- 220 ohm resistor x1
16+
17+
Example
18+
-------
19+
20+
These examples illustrate how to send HTTP Post request of MP4 audio file to a HTTP server.
21+
22+
This guide will be relevant to 2 examples:
23+
24+
1) HTTP_Post_MP4_Whisper_Server
25+
26+
2) RecordMP4_HTTP_Post_Whisper_Server
27+
28+
The difference between these 2 examples is that for HTTP_Post_MP4_Whisper_Server.ino, one is expected to have an MP4 file already saved inside the SD card. Whereas for the RecordMP4_HTTP_Post_Whisper_Server.ino, it is not necessary to have a MP4 file inside the SD card.
29+
30+
This is the block diagram for the example flow.
31+
32+
|image01|
33+
34+
Connect the pushbutton and resistor to AMB82 Mini as shown below.
35+
36+
|image02|
37+
38+
Open “File”-> “Examples” -> “AmebaHTTP” -> “HTTP_Post_MP4_Whisper_Server” OR “RecordMP4_HTTP_Post_Whisper_Server”.
39+
40+
|image03|
41+
42+
Compile and run the code.
43+
44+
Set up the http server by locating the python script called “whisper_llm_server.py” in src folder. Go to command prompt and go to the src folder and execute this command: python3 whisper_llm_server.py. Follow the readme in the python script.
45+
46+
Press the push button for 2s to trigger the recording. Speak into the microphone to ask the AI. This should be the expected output on the terminal that was running the python script. Please note that if you are
47+
to use a more powerful model such as MediaTek 7B model, you will need a
48+
PC with a powerful GPU to test. Purely CPU will not be able to run that
49+
model.
50+
51+
Please note that this server can only be run on Linux OS. Mac OS and Windows have not been supported yet.
52+
53+
|image04|
54+
55+
.. |image01| image:: ../../_static/Example_Guides/HTTP/HTTP_Post_MP4/image01.png
56+
:width: 722 px
57+
:height: 255 px
58+
.. |image02| image:: ../../_static/Example_Guides/HTTP/HTTP_Post_MP4/image02.png
59+
:width: 988 px
60+
:height: 802 px
61+
.. |image03| image:: ../../_static/Example_Guides/HTTP/HTTP_Post_MP4/image03.png
62+
:width: 1032 px
63+
:height: 645 px
64+
.. |image04| image:: ../../_static/Example_Guides/HTTP/HTTP_Post_MP4/image04.png
65+
:width: 1157 px
66+
:height: 234 px
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
Retrieve HTTP webs
2+
==================
3+
4+
.. contents::
5+
:local:
6+
:depth: 2
7+
8+
Materials
9+
---------
10+
11+
- `AMB82-mini <https://www.amebaiot.com/en/where-to-buy-link/#buy_amb82_mini>`_ x 1
12+
13+
Example
14+
-------
15+
16+
| In this example, the HttpClient library is used to retrieve a webpage using the HTTP protocol.
17+
| First, make sure that the correct Ameba development board is selected in “Tools” -> “Board”.
18+
19+
Then open “File” -> “Examples” -> “AmebaHttp” -> “RetrieveHttpWebs”.
20+
21+
|image01|
22+
23+
In the sample code, modify the highlighted section to enter the information required (ssid, password, key index) to connect to your WiFi network.
24+
25+
|image02|
26+
27+
Upload the code and press the reset button on Ameba once the upload is finished. Open the serial monitor in the Arduino IDE and you can see the information retrieved from the website.
28+
29+
|image03|
30+
31+
Code Reference
32+
--------------
33+
34+
| Use WiFi.begin() to establish WiFi connection:
35+
| https://www.arduino.cc/en/Reference/WiFiBegin
36+
| To get the information of a WiFi connection:
37+
| Use WiFi.SSID() to get SSID of the current connected network.
38+
| https://www.arduino.cc/en/Reference/WiFiSSID
39+
| Use WiFi.RSSI() to get the signal strength of the connection.
40+
| https://www.arduino.cc/en/Reference/WiFiRSSI
41+
| Use WiFi.localIP() to get the IP address of Ameba.
42+
| https://www.arduino.cc/en/Reference/WiFiLocalIP
43+
| Use WiFiClient to create a client to handle the WiFi connection.
44+
| https://www.arduino.cc/en/Reference/WiFiClient
45+
| Use HTTPClient to create a client to handle the HTTP connection.
46+
47+
Use http.get() to send a GET request to the website.
48+
49+
50+
.. |image01| image:: ../../_static/Example_Guides/HTTP/Retrieve_HTTP_webs/image01.png
51+
:width: 602 px
52+
:height: 833 px
53+
.. |image02| image:: ../../_static/Example_Guides/HTTP/Retrieve_HTTP_webs/image02.png
54+
:width: 568 px
55+
:height: 565 px
56+
.. |image03| image:: ../../_static/Example_Guides/HTTP/Retrieve_HTTP_webs/image03.png
57+
:width: 752 px
58+
:height: 496 px

0 commit comments

Comments
 (0)