mirror of
https://github.com/pvvx/RTL00MP3.git
synced 2025-07-31 12:41:06 +00:00
add example
This commit is contained in:
parent
0cd01e4dc1
commit
5cd34b0c9f
75 changed files with 6023 additions and 217 deletions
47
RTL00_SDKV35a/component/common/example/rarp/example_rarp.c
Normal file
47
RTL00_SDKV35a/component/common/example/rarp/example_rarp.c
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include <netif/etharp.h>
|
||||
#include "wifi_conf.h"
|
||||
|
||||
|
||||
#define RARP_THREAD_STACK_SIZE 200
|
||||
|
||||
const struct eth_addr macbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};
|
||||
extern struct netif xnetif[NET_IF_NUM];
|
||||
|
||||
void rarp_retrieve(uint8_t *rarp_ip, uint8_t *rarp_mac) {
|
||||
printf("\n\rThe IP of device %02x:%02x:%02x:%02x:%02x:%02x is: %d.%d.%d.%d\r\n",
|
||||
rarp_mac[0], rarp_mac[1], rarp_mac[2], rarp_mac[3], rarp_mac[4], rarp_mac[5],
|
||||
rarp_ip[0], rarp_ip[1], rarp_ip[2], rarp_ip[3]);
|
||||
}
|
||||
|
||||
static void rarp_thread(void *param)
|
||||
{
|
||||
printf("\r\n\r\n\r\n>>>>>>>>>>>>>>>rarp example<<<<<<<<<<<<<<<<<\r\n\r\n\r\n");
|
||||
vTaskDelay(10000);
|
||||
uint8_t *mac, *ip, *netmask, *gw;
|
||||
err_t result;
|
||||
|
||||
while(wifi_is_ready_to_transceive(RTW_STA_INTERFACE) != RTW_SUCCESS){
|
||||
printf("\r\n\r\n\r\n>>>>>>>>>>>>>>Wifi is disconnected!!Please connect!!<<<<<<<<<<<<<<<<<\r\n\r\n\r\n");
|
||||
vTaskDelay(10000);
|
||||
}
|
||||
|
||||
rarp_retrieve_hook_callback(rarp_retrieve);
|
||||
|
||||
for(int i = 0; i < 3; i ++){
|
||||
printf("\n\r\n\retharp_raw: sending raw RARP packet.\n\r\n\r");
|
||||
etharp_raw(&xnetif[0], (struct eth_addr *)xnetif[0].hwaddr, &macbroadcast,
|
||||
(struct eth_addr *)xnetif[0].hwaddr, IP_ADDR_ANY,
|
||||
(struct eth_addr *)xnetif[0].hwaddr, IP_ADDR_ANY, RARP_REQUEST);
|
||||
vTaskDelay(1000);
|
||||
}
|
||||
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void example_rarp(void){
|
||||
if(xTaskCreate(rarp_thread, ((const char*)"rarp_thread"), RARP_THREAD_STACK_SIZE, NULL, 1 , NULL) != pdPASS)
|
||||
printf("\n\r%s xTaskCreate(rarp_thread) failed\n\r", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
#ifndef EXAMPLE_RARP_H
|
||||
#define EXAMPLE_RARP_H
|
||||
|
||||
void example_rarp(void);
|
||||
|
||||
|
||||
#endif /* EXAMPLE_RARP_H */
|
||||
|
||||
20
RTL00_SDKV35a/component/common/example/rarp/readme.txt
Normal file
20
RTL00_SDKV35a/component/common/example/rarp/readme.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
RARP EXAMPLE
|
||||
|
||||
Description:
|
||||
In this example, it will send rarp request for 3 times. And the rarp reply callback will print the received reply IP address.
|
||||
|
||||
Configuration:
|
||||
[platform_opts.h]
|
||||
#define CONFIG_EXAMPLE_RARP 1
|
||||
|
||||
Execution:
|
||||
You need to connect to WiFi manually by AT command. After connected the rarp request will be sent.
|
||||
|
||||
RARP server:
|
||||
For Ubuntu, you can try to setup the RARP server as doing this:
|
||||
• apt-get install rarpd
|
||||
• touch /etc/ethers
|
||||
• add “00:e0:4c:87:xx:xx(Ameba’s MAC) client” in /etc/ethers
|
||||
• add”192.168.1.xx(Ameba’s ip) client” in /etc/hosts
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue