Statistics: Posted by koltegirish97 — Fri Oct 30, 2015 1:02 pm
Code:
void user_rf_pre_init(void)
{
}
/******************************************************************************
* FunctionName : user_init
* Description : entry of user application, init user function here
* Parameters : none
* Returns : none
*******************************************************************************/
void user_init(void)
{
os_printf("SDK version:%s\n", system_get_sdk_version());
... ...
}
Statistics: Posted by ESP_Faye — Fri Oct 30, 2015 11:46 am
Statistics: Posted by koltegirish97 — Tue Oct 27, 2015 8:38 pm
Statistics: Posted by koltegirish97 — Wed Oct 21, 2015 2:05 pm
Statistics: Posted by parmar7725274 — Tue Oct 06, 2015 2:51 am
Statistics: Posted by Lurch — Sat Jul 25, 2015 1:41 am
Statistics: Posted by kolban — Fri Jul 24, 2015 9:38 pm
Statistics: Posted by baoshi — Fri Jul 24, 2015 9:30 pm
Statistics: Posted by ESP_Faye — Fri Jul 24, 2015 3:13 pm
Code:
void user_init(void)
{
int rc;
// Configure the UART
uart_init(BIT_RATE_115200, BIT_RATE_115200);
ets_uart_printf("\n\n");
wifi_set_opmode(1); // STATION
u8 key[16]= {0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44};
u8 local[6] = {0x18, 0xfe, 0x34, 0x9c, 0x3e, 0xf0}; // This module in STATION mode
u8 remote[6] = {0x1a, 0xfe, 0x34, 0x9c, 0x3e, 0xe5}; // Another modules in SOFTAP mode
if (esp_now_init()==0)
{
ets_uart_printf("esp_now init ok\n");
esp_now_register_recv_cb(simple_cb);
ets_uart_printf("dlink send to A cur chan %d\n", wifi_get_channel());
if (rc = esp_now_set_self_role(1)) ets_uart_printf("set_self_role failed %d\r\n", rc); // CONTROLLER
if (rc = esp_now_add_peer(local, 1, key, 16)) ets_uart_printf("add_peer failed %d\r\n", rc);
if (rc = esp_now_add_peer(remote, 2, key, 16)) ets_uart_printf("add_peer failed %d\r\n", rc);
} else
{
ets_uart_printf("esp_now init failed\n");
}
// Set up a timer to send the message
os_timer_disarm(&hello_timer);
os_timer_setfn(&hello_timer, (os_timer_func_t *)hello_cb, (void *)0);
os_timer_arm(&hello_timer, DELAY, 1);
}
LOCAL void ICACHE_FLASH_ATTR hello_cb(void *arg)
{
u8 all_cnt, encrypt_cnt;
if (esp_now_get_cnt_info(&all_cnt, &encrypt_cnt))
ets_uart_printf("get_cnt_info failed\r\n");
ets_uart_printf("client:%d, encrypted client:%d\r\n", all_cnt, encrypt_cnt);
ets_uart_printf("send ");
if (esp_now_send(NULL, "Hello", 6))
ets_uart_printf("fail\r\n");
else
ets_uart_printf("ok\r\n");
}
Statistics: Posted by baoshi — Tue Jul 21, 2015 9:55 pm
Statistics: Posted by ESP_Faye — Tue Jul 21, 2015 5:21 pm
Statistics: Posted by baoshi — Tue Jul 21, 2015 2:19 pm
Statistics: Posted by nice72 — Fri Jul 17, 2015 8:43 am
Statistics: Posted by ESP_Faye — Wed Jul 15, 2015 11:05 am
Statistics: Posted by Ivan — Tue Jul 14, 2015 8:45 pm
Statistics: Posted by ESP_Faye — Tue Jul 14, 2015 5:55 pm
Statistics: Posted by Ivan — Tue Jul 14, 2015 12:11 pm
Code:
void ICACHE_FLASH_ATTR simple_cb(u8 *macaddr, u8 *data, u8 len)
{
int i;
u8 ack_buf[16];
u8 recv_buf[17];
os_printf("now from[");
for (i = 0; i < 6; i++)
os_printf("%02X, ", macaddr[i]);
os_printf(" len: %d]:", len);
os_bzero(recv_buf, 17);
os_memcpy(recv_buf, data, len<17?len:16);
show_buf2(data,len);
if (os_strncmp(data, "ACK", 3) == 0)
return;
os_sprintf(ack_buf, "ACK[%08x]", ack_count++);
esp_now_send(macaddr, ack_buf, os_strlen(ack_buf));
}
void user_init(void)
{
u8 key[16]= {0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44};
u8 da1[6] = {0x18, 0xfe, 0x34, 0x97, 0xd5, 0xb1};
u8 da2[6] = {0x1a, 0xfe, 0x34, 0x97, 0xd5, 0xb1};
if (esp_now_init()==0) {
os_printf("esp_now init ok\n");
esp_now_register_recv_cb(simple_cb);
os_printf("dlink send to A cur chan %d\n", wifi_get_channel());
esp_now_set_self_role(1);
esp_now_add_peer(da1, 1, key, 16);
esp_now_add_peer(da2, 2, key, 16)
} else {
os_printf("esp_now init failed\n");
}
}
void ICACHE_FLASH_ATTR demo_send_(u8 *data, u8 len)
{
/* the demo will send to two devices which added by esp_now_add_peer() */
esp_now_send(NULL, data, len);
}
Statistics: Posted by ESP_Faye — Mon Jul 13, 2015 5:44 pm
Statistics: Posted by kolban — Sat Jul 11, 2015 11:55 pm
Statistics: Posted by parmar7725274 — Wed Jul 08, 2015 4:09 pm
Statistics: Posted by Ivan — Mon Jul 06, 2015 9:55 am