esp8266_socket_ops
里初始化赋值时 对
int (*at_socket)(struct at_device *device, enum at_socket_type type);
这一个函数指针变量 赋值时 为 RT_NULL
。
那当创建socket时,怎么完成创建的呢?
at_socket(int domain, int type, int protocol)----> sock = alloc_socket(socket_type);---->alloc_socket_by_device(device, type);----> idx = device->class->socket_ops->at_socket(device, type);
static const struct at_socket_ops esp8266_socket_ops =
{
esp8266_socket_connect,
esp8266_socket_close,
esp8266_socket_send,
esp8266_domain_resolve,
esp8266_socket_set_event_cb,
#if defined(AT_SW_VERSION_NUM) && AT_SW_VERSION_NUM > 0x10300
RT_NULL, /*at_socket为空*/
#endif
};
/* AT socket operations function */
struct at_socket_ops
{
int (*at_connect)(struct at_socket *socket, char *ip, int32_t port, enum at_socket_type type, rt_bool_t is_client);
int (*at_closesocket)(struct at_socket *socket);
int (*at_send)(struct at_socket *socket, const char *buff, size_t bfsz, enum at_socket_type type);
int (*at_domain_resolve)(const char *name, char ip[16]);
void (*at_set_event_cb)(at_socket_evt_t event, at_evt_cb_t cb);
int (*at_socket)(struct at_device *device, enum at_socket_type type);
};
int esp8266_socket_class_register(struct at_device_class *class)
{
RT_ASSERT(class);
class->socket_num = AT_DEVICE_ESP8266_SOCKETS_NUM;
class->socket_ops = &esp8266_socket_ops;
return RT_EOK;
}
esp8266_socket_ops 里初始化赋值时 对 int (at_socket)(struct at_device device, enum at_socket_type type);这一个函数指针变量 赋值时 为 RT_NULL。
为空一定创建不了啊,你看其他地方有没有对这个函数指针赋值的地方