About new ESP-NOW functions on SDK 1.2.0

Ivan
Posts: 4
Joined: Mon Jul 06, 2015 9:49 am

About new ESP-NOW functions on SDK 1.2.0

Postby Ivan » Mon Jul 06, 2015 9:55 am

Hi,

Could you please kindly provide an example on how to use the new ESP-NOW functions on SDK 1.2.0?
I think I really need this for my project but just no idea on how to use it.
Thanks!

parmar7725274
Posts: 21
Joined: Wed Jun 03, 2015 1:20 pm

Re: About new ESP-NOW functions on SDK 1.2.0

Postby parmar7725274 » Wed Jul 08, 2015 4:09 pm

Hi Ivan,

I'm also interested. Let me know if you get something.

Thanks & Regards,
Prakash P.

User avatar
kolban
Posts: 131
Joined: Tue Jun 16, 2015 1:09 pm
Location: Fort Worth, Texas, USA

Re: About new ESP-NOW functions on SDK 1.2.0

Postby kolban » Sat Jul 11, 2015 11:55 pm

I'm not sure what this capability is supposed to do? Would anyone be able to post the intent of the new function?

Neil

ESP_Faye
Posts: 1642
Joined: Mon Oct 27, 2014 11:08 am

Re: About new ESP-NOW functions on SDK 1.2.0

Postby ESP_Faye » Mon Jul 13, 2015 5:44 pm

Hi,

Here is a simple example

Code: Select all

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);

}

Ivan
Posts: 4
Joined: Mon Jul 06, 2015 9:49 am

Re: About new ESP-NOW functions on SDK 1.2.0

Postby Ivan » Tue Jul 14, 2015 12:11 pm

Hi Faye,

Thanks for your response.
When I look at the example. It seems that the destination device must be an ESP8266 wifi module. Is that true?
Can I use ESP_NOW to send something to someone which is not an ESP device? like PC or mobile phone?

ESP_Faye
Posts: 1642
Joined: Mon Oct 27, 2014 11:08 am

Re: About new ESP-NOW functions on SDK 1.2.0

Postby ESP_Faye » Tue Jul 14, 2015 5:55 pm

Hi,

Sorry that ESP-NOW only support ESP8266 device..

Thanks for your interest in ESP8266 !

Ivan
Posts: 4
Joined: Mon Jul 06, 2015 9:49 am

Re: About new ESP-NOW functions on SDK 1.2.0

Postby Ivan » Tue Jul 14, 2015 8:45 pm

Hi Faye,

Ok, got it. Thanks!
I have another question.
Can I use a broadcast mac like: u8 da1[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
as destination so I can discover an unknown ESP8266 device then add it as my peer(slave)?

ESP_Faye
Posts: 1642
Joined: Mon Oct 27, 2014 11:08 am

Re: About new ESP-NOW functions on SDK 1.2.0

Postby ESP_Faye » Wed Jul 15, 2015 11:05 am

Hi,

Sorry that ESP-NOW can not broadcast right now..

But we will think over your request, and let you know if there is any update.

Thanks for your interest in Espressif Systems and ESP8266 !

nice72
Posts: 10
Joined: Wed Nov 26, 2014 3:47 pm

Re: About new ESP-NOW functions on SDK 1.2.0

Postby nice72 » Fri Jul 17, 2015 8:43 am

Hi, All

I have two questions.

1. What is the difference between this controller mode and slave mode?

2. And, When the channel of the own and peer are not the same, esp8266 can send a packet to the peer esp8266?

3. I would like to know the meaning of the return value is 0 esp_now_is_peer_exist.
When we received the return 0, that esp8266 is going to disappear?

Thanks,

Peter.

baoshi
Posts: 23
Joined: Tue Dec 02, 2014 8:35 pm

Re: About new ESP-NOW functions on SDK 1.2.0

Postby baoshi » Tue Jul 21, 2015 2:19 pm

Hi Faye,

I tried the code you provided.

It seems I always get -4 error from esp_now_add_peer call. It there any clue what I did wrongly? (esp_now_init and esp_now_set_self_role is ok).

Also, would you please give a little explanation what is CONTROLLER role and what is SLAVE role?

Thanks

Baoshi

Who is online

Users browsing this forum: Google [Bot] and 12 guests