Radio.c work

This commit is contained in:
Bill Sideris 2022-11-14 19:31:18 +02:00
parent 2e6dd1bf1f
commit 6ad61a3fd1
No known key found for this signature in database
GPG Key ID: 1BEF1BCEBA58EA33

View File

@ -299,10 +299,9 @@ void common_hal_wifi_radio_set_ipv4_address(wifi_radio_obj_t *self, mp_obj_t ipv
}
volatile bool ping_received;
u16_t ping_seq_num;
void ping_set_target(const ip_addr_t *ping_addr);
int ping_send(struct raw_pcb *raw, const ip_addr_t *addr);
uint16_t ping_seq_num;
uint32_t ping_time;
static u8_t
ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr) {
@ -311,7 +310,7 @@ ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr)
if ((p->tot_len >= (PBUF_IP_HLEN + sizeof(struct icmp_echo_hdr))) &&
pbuf_remove_header(p, PBUF_IP_HLEN) == 0) {
uint32_t ping_time = sys_now();
iecho = (struct icmp_echo_hdr *)p->payload;
if ((iecho->id == PING_ID) && (iecho->seqno == lwip_htons(ping_seq_num))) {
@ -331,6 +330,7 @@ ping_recv(void *arg, struct raw_pcb *pcb, struct pbuf *p, const ip_addr_t *addr)
}
mp_int_t common_hal_wifi_radio_ping(wifi_radio_obj_t *self, mp_obj_t ip_address, mp_float_t timeout) {
ping_time = sys_now();
ip_addr_t ping_addr;
ipaddress_ipaddress_to_lwip(ip_address, &ping_addr);