INIT_DEVICE_EXPORT(ec200x_device_class_register);
开辟struct at_device_class结构体
进入at_device_class_register 怎么跳转到的static int ec200x_init(struct at_device *device)
at_device_class_registe执行完后到
INIT_APP_EXPORT(ec200x_device_register);
static int ec200x_device_register(void)
{
struct at_device_ec200x *ec200x = &_dev;
return at_device_register(&(ec200x->device),
ec200x->device_name,
ec200x->client_name,
AT_DEVICE_CLASS_EC200X,
(void *) ec200x);
}
INIT_APP_EXPORT(ec200x_device_register);
/* Initialize AT device */
ec200x_device_register—>
result = class->device_ops->init(device);---->
static int ec200x_init(struct at_device *device)---->
return ec200x_netdev_set_up(device->netdev);---->
static int ec200x_net_init(struct at_device *device)---->
rt_thread_create(“ec200x_net”, ec200x_init_thread_entry, (void *)device,
EC200X_THREAD_STACK_SIZE, EC200X_THREAD_PRIORITY, 20);---->
ec200x_init_thread_entry(用AT指令配置查询模组)—>
ec200x_netdev_set_info(查询了imei–等于网卡号 模组IP dns服务器地址)–>
void netdev_low_level_set_ipaddr(struct netdev *netdev, const ip_addr_t *ip_addr)—>
sal_check_netdev_internet_up(函数内触发)–>进入周期线程执行查询信号的函数
rt_work_init(net_work, check_netdev_internet_up_work, (void *)netdev);等不忙的时候再做–>
check_netdev_internet_up_work 这里执行"link.rt-thread.org" 网络UDP连接
/* Socket protocol types (TCP/UDP/RAW) */
#define SOCK_STREAM 1
#define SOCK_DGRAM 2
#define SOCK_RAW 3
域名解析
host = (struct hostent *) pf->netdb_ops->gethostbyname(SAL_INTERNET_HOST);
if (host == RT_NULL)
{
result = -RT_ERROR;
goto __exit;
}
发送
skt_ops->sendto(sockfd, send_data, SAL_INTERNET_BUFF_LEN, 0,
(struct sockaddr *)&server_addr, sizeof(struct sockaddr));
接收
result = skt_ops->recvfrom(sockfd, &recv_data, sizeof(recv_data), 0, (struct sockaddr *)&server_addr, &addr_len);