Skip to content

Contributed by WildboarG, organized by Ai-Thinker

[wb2] HTTP GET Application

[wb2] HTTP GET Application


🧠 What is HTTP GET?

HTTP GET is one of the most common ways of making web requests. Its purpose is to request information from a server, such as fetching a web page, querying data, or triggering a notification.

A request usually looks like this:

Click to expand full code
http
GET

/notify?title=警报&message=发现目标

HTTP/1.0

Host
:
192.168.0.233:8080

User-Agent
:
my-device

This request accesses the /notify path on 192.168.0.233:8080 and carries two parameters: title and message

📟 Application Scenarios

  • An embedded device detects an anomaly and sends an alarm via an HTTP GET request;
  • IoT devices periodically upload status;
  • Trigger automation workflows on the server side (such as notifying a bot, logging, etc.).

🛠️ MCU-side Implementation (Simplified)

Click to expand full code
c
#
define
 WEB_SERVER
"192.168.0.233"

#
define
 WEB_PORT
"8080"

#
define
 WEB_PATH
"/notify?title=警报&message=发现目标"

static

const

char
 *REQUEST =
"GET "
 WEB_PATH
" HTTP/1.0\r\n"

"Host: "
 WEB_SERVER
":"
 WEB_PORT
"\r\n"

"User-Agent: wb2-device\r\n"

"\r\n"
;

void

notify_task
(
void
 *pvParameters)
 {

// ... DNS解析 + socket连接略

  write(sock, REQUEST,
strlen
(REQUEST));

// ... 接收响应略

  close(sock);
}

🖥️ Server-side Python Example

Use Flask to quickly build an HTTP receiving service:

Click to expand full code
python
from
 flask
import
 Flask, request
app = Flask(__name__)

@app.route(
"/notify"
)

def

notify
():
    title = request.args.get(
"title"
)
    message = request.args.get(
"message"
)

print
(
f"📢 来自设备的通知:
{title}
 -
{message}
"
)

return

"OK"

app.run(host=
"0.0.0.0"
, port=
8080
)

Example output:

Click to expand full code
html
📢 来自设备的通知:警报 - 发现目标

🧪 Testing

You can enter the following directly in your browser:

Click to expand full code
c
http:
//192.168.0.14:8080/notify?title=测试&message=一切正常

Application Test


Bark is a very convenient iOS push notification tool, suitable for servers/devices to actively push messages to your phone. The principle behind it: you send a message to Bark's server via an HTTP GET request, and Bark pushes the message to your iPhone through APNs.


🔔 One-Sentence Explanation:

Bark 就是一个“网页发消息 ➜ iPhone 收通知”的桥梁。


🛠️ Usage Steps:

1. Install the Bark App (iOS)

Search for Bark in the App Store — the icon is a dog head — download and install it.

2. Get Your Push URL

After opening Bark, the app will give you a URL like this:

Click to expand full code
html
[https://api.day.app/你的设备Key](https://api.day.app/你的设备Key)

This is your exclusive push address!

3. Send a Push Message (GET Request)

Use your browser, curl, or code to request the URL below:

Click to expand full code
c
https:
//api.day.app/你的设备Key/标题/内容

For example:

Click to expand full code
c
https:
//api.day.app/AbCDefGHiJ/警报/发现异常数据

You will receive a notification on your phone immediately.

Bark needs a self-hosted server to protect data privacy. Don't worry — next I'll show you how to build a Bark server with Docker. The Docker image is only 23M in size, which is perfect for small devices. It's much smaller than the gotify server recommended before. One more pleasant surprise: Bark doesn't need to run in the background — even if it's not started, Apple's APNS push can still deliver messages to your phone in real time, which saves a lot of power.

4. Docker Installation of the bark Server

  • Pull the Docker image
Click to expand: docker pull finab/bark-server
sh
docker pull finab/bark-server
  • Start the service
Click to expand full code
c
docker run -dt \
--name bark \
-p
8080
:
8080
 \
-v /data/bark:/data \
finab/bark-server

Test it first after a successful run

Click to expand full code
c
curl http:
//0.0.0.0:8080/ping

{
"code"
:
200
,
"message"
:
"pong"
,
"timestamp"
:
1621936667
}

5. Send Messages to Your Phone from the wb2 http get Request

Based on the RD04 radar demo from last time (gotify [POST]), change the notification method to (bark [GET]) — you only need to modify the notification method in the NOTIFY code.

Click to expand full code
c
#
define
 WEB_SERVER
"192.168.0.233"

#
define
 WEB_PORT
"8080"

#
define
 WEB_PORTI 8080

#
define
 WEB_PATH
"/你的令牌/rador?call=1"

void

notify_task
(
void
 *pvParameters)
;

static

const

char
 *REQUEST =
"GET "
 WEB_PATH
" HTTP/1.0\r\n"

"Host: "
 WEB_SERVER
":"
 WEB_PORT
"\r\n"

"User-Agent: aithinker wb2\r\n"

"\r\n"
;

void

notify_task
(
void
 *pvParameters)
 {

int
 sockfd;

struct

sockaddr_in

server_addr
;

char
 response[
512
];

  sockfd = socket(AF_INET, SOCK_STREAM,
0
);

if
 (sockfd <
0
) {

printf
(
"socket failed\n"
);
    vTaskDelete(
NULL
);
  }

  server_addr.sin_family = AF_INET;
  server_addr.sin_port = htons(WEB_PORTI);
  server_addr.sin_addr.s_addr = inet_addr(WEB_SERVER);

if
 (connect(sockfd, (
struct
 sockaddr *)&server_addr,
sizeof
(server_addr)) <

0
) {

printf
(
"connect failed\n"
);
    close(sockfd);
    vTaskDelete(
NULL
);
  }

printf
(
"connected!\n"
);

  write(sockfd, REQUEST,
strlen
(REQUEST));

int
 n = read(sockfd, response,
sizeof
(response) -
1
);

if
 (n >
0
) {
    response[n] =
'\0'
;

printf
(
"Response:\n%s\n"
, response);
  }

  close(sockfd);
  vTaskDelete(
NULL
);
}

Remember to enable the sentry on the wb2 web page, otherwise the radar won't work.

6. Result

Based on the rador ?call=1 I filled in, besides the popup notification, there's also a ringing alarm.

Released under the MIT License. Build Time 2026-09-11 14:52:23