26

Re: Using RemoteXY with Arduino BLE and PlatformIO

Hello,

  I tried with another Nano BLE and I had the same connection issue.
 
    @Gunner: Well, I suppose the issue here is that the manufacturer has put all its eggs on the same basket. Thus, the same serial connection is used by both the USB and the bluetooth. Just to be clear, this is not my choice but rather a specificity of the board itself.
   
     I do agree that I've sent data on the serial in the initialization, but that is the sole moment I do so. Thus, there is no more crosstalk on the serial after this moment. I'm going to check into more detail what is the messages that are exchanged between the Nano BLE and the phone. I'll post the progress here.
      My tests will include different types of setups and see if there's a correlation between the number of elements and the initialization issue.

     I'll keep you posted.

       Cheers
          Luiz

27 (edited by Gunner 2021-05-31 03:22:50)

Re: Using RemoteXY with Arduino BLE and PlatformIO

luiz.villa wrote:

I do agree that I've sent data on the serial in the initialization, but that is the sole moment I do so. Thus, there is no more crosstalk on the serial after this moment.

Yes, that is what I was referring to: Your needing to attempt multiple App connections.  Your Serial initialization and print is really an unnecessary and avoidable blip to obfuscate the testing results.  One could flash the onboard LED as a initialized notification instead.

But with those two lines in there, and depending on timing with boot and pressing the project button on the App, the GUI and Serial initialization could be happening close enough at boot to cause issues.  Something similar sometimes happens at boot with my ESP32 dual WiFi/BLE project I posted here... although in my case it is the radio that is shared.

As for the board, yes, that is all on them... and you for choosing it big_smile  JK..  I also like checking out new unique devices, but just got burned too many times with "great on paper, not so in reality" that I generally stick with the ESP32 now as it has it all, done right, and relatively cheap.

Looking forward to your results.

"And voila, which is French for.......'and then I found out.'" - Ready Player One

28

Re: Using RemoteXY with Arduino BLE and PlatformIO

luiz.villa wrote:

Hello remoteXY team,

      Thank you so much for your update. I've just implemented your changes. However I do not have the RemoteXYStream_HardwareSerial.h file. I had to manually change RemoteXY_Serial.h and serial.h.

Sorry, I wrote about the new 3.x.x beta library https://remotexy.com/en/library/
Now we are updating only this version. Soon it will be the main version.
You can use it.

What I wrote about trying to change the library is for an experiment. Thank you very much for trying!!
I'm surprised. The code compiles for your board in the same way as for a regular Nano and should work in both cases. This requires a lot of study and testing. We will not add this quick solution to the library until we understand why this is happening. This may not work for other users.

There may be a problem with the firmware of the bluetooth chip CC2540. It is the chip CC2540 that determines where to send Serial traffic. If bluetooth connected then traffic go to BLE, else to USB. Your board is similar to the dfrobot board at https://www.dfrobot.com/product-1122.html There it is possible to find some tutorial and firmware of the chip CC2540.

29

Re: Using RemoteXY with Arduino BLE and PlatformIO

Hello everyone,

       After a long pause I'm back onto the issue. I have found some interesting things. Here are my updates:

  • I have updated my library to the latest version.

  • I have written the changes to the library (Serial. instead of serial->)

        Now, here's an interesting thing. Depending on the modules I use, I actually get to connect easily to the BLE or not. When I use the following code:

// // RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,0,0,11,0,11,13,0,
  4,0,16,20,7,18,2,26 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  int8_t slider_1; // =0..100 slider position 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop) 

    I get through every single time I try to connect. This is a slider code.

    If I use this code:

// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,5,0,0,0,38,0,11,13,0,
  5,0,9,10,30,30,2,26,31,5,
  0,60,10,30,30,2,26,31,2,0,
  36,52,27,5,2,26,31,31,79,78,
  0,79,70,70,0 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  int8_t joystick_1_x; // =-100..100 x-coordinate joystick position 
  int8_t joystick_1_y; // =-100..100 y-coordinate joystick position 
  int8_t joystick_2_x; // =-100..100 x-coordinate joystick position 
  int8_t joystick_2_y; // =-100..100 y-coordinate joystick position 
  uint8_t switch_1; // =1 if switch ON and =0 if OFF 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop) 

      I never get through. This is two joysticks with an on-off button.

If I try a simpler code, just an on-off button:

// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,0,0,20,0,11,13,0,
  2,0,12,5,22,11,2,26,31,31,
  79,78,0,79,70,70,0 };
  
// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  uint8_t switch_1; // =1 if switch ON and =0 if OFF 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop) 

      I still get nothing.

    So, it seems there is a link between the coding and the correct operation of remotexy in my case. I'll keep searching.

30

Re: Using RemoteXY with Arduino BLE and PlatformIO

This code also works every single time I try to connect:

//---------------small joystick-----------------
// RemoteXY configurate  
// #pragma pack(push, 1)
// uint8_t RemoteXY_CONF[] =
//   { 255,2,0,0,0,12,0,11,13,0,
//   5,0,12,16,21,21,2,26,31 };
  
//----------------large joystick-------------------
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,2,0,0,0,12,0,11,13,0,
  5,0,23,5,52,52,2,26,31 }; 

// this structure defines all the variables and events of your control interface 
struct {

    // input variables
  int8_t joystick_2_x; // =-100..100 x-coordinate joystick position 
  int8_t joystick_2_y; // =-100..100 y-coordinate joystick position 

    // other variable
  uint8_t connect_flag;  // =1 if wire connected, else =0 

} RemoteXY;
#pragma pack(pop) 

     It is a joystick with different sizes. First small and then large. Both cases work.

31 (edited by luiz.villa 2021-06-09 23:51:32)

Re: Using RemoteXY with Arduino BLE and PlatformIO

It seems that the size of the RemoteXY_CONF is the key to understand the issue.
Here are examples that work every single time I try to connect to the BLE device:

Button

// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,0,0,13,0,11,13,0,
  1,0,40,23,12,12,2,31,88,0 };

Select

// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,0,0,11,0,11,13,0,
  3,3,54,19,8,22,2,26 }; 

Joystick

#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,2,0,0,0,12,0,11,13,0,
  5,0,36,16,30,30,2,26,31 }; 

Slider

#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,0,0,11,0,11,13,0,
  4,0,43,22,7,18,2,26 }; 

Edit field

#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,11,0,0,0,13,0,11,13,0,
  7,36,36,26,20,5,2,26,2,11 };  

RGB button

// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,3,0,0,0,11,0,11,13,0,
  6,0,38,21,20,20,2,26 };

Arc Level

#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,0,0,1,0,11,0,11,13,0,
  66,130,41,25,13,10,2,26 };

Online Graph

#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,0,0,4,0,11,0,11,13,0,
  68,17,33,22,20,20,8,36 };

And here are cases where it does not work:

ON-OFF button

// RemoteXY configurate  
#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,1,0,0,0,20,0,11,13,0,
  2,0,34,24,22,11,2,26,31,31,
  79,78,0,79,70,70,0 };

2 sliders

#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,2,0,0,0,19,0,11,13,0,
  4,0,23,20,7,18,2,26,4,0,
  46,21,7,18,2,26 };

A slider and a joystick

#pragma pack(push, 1)
uint8_t RemoteXY_CONF[] =
  { 255,3,0,0,0,20,0,11,13,0,
  4,0,20,13,5,41,2,26,5,0,
  46,9,48,48,2,26,31 }; 

The obvious different for me is the size of the message. The system works for short initialization messages. Could it be the bluetooth is "too slow"? Have you ever experienced this type of issue? Is there a way to extend the timeout?

As a reference the whole code is available here: https://github.com/luizvilla/remoteXY_BLE_nano

32

Re: Using RemoteXY with Arduino BLE and PlatformIO

Hello everyone,

     I've tested remoteXY with some students this morning (we are building an arduino-based drone). I've observed the same behavior with several different cell phones. So, the issue is not on my hardware.

      cheers
        Luiz

33

Re: Using RemoteXY with Arduino BLE and PlatformIO

luiz.villa wrote:

Hello everyone,

     I've tested remoteXY with some students this morning (we are building an arduino-based drone). I've observed the same behavior with several different cell phones. So, the issue is not on my hardware.

      cheers
        Luiz

Did I understand correctly that all the tested boards were BLE Nano from AliExpress ?
We will receive one soon and can test it.
Now I can assume that the CC2540 firmware has a small buffer for data transfer and the entire package does not fit into it. BLE protocol transmits 20 bytes at a time, if there is more data, then a buffer is required to store them.

34

Re: Using RemoteXY with Arduino BLE and PlatformIO

Hello,

Did I understand correctly that all the tested boards were BLE Nano from AliExpress ?
We will receive one soon and can test it.

    Yes, that is correct!

    I agree that when the message is smaller than 20, it works. I'll make a few measurements using LightBlue to validate that a message bigger than 20 is sent the timeout is activated. However, every once in a while (1 in every 10 to 20 tries) it actually works. So I don't know if it is a time out or a package loss.

35

Re: Using RemoteXY with Arduino BLE and PlatformIO

Hi!

we are after using an original Arduino Nano 33 BLE with RemoteXY, any one has done?
Thanks!

36

Re: Using RemoteXY with Arduino BLE and PlatformIO

Hello epson. 

In order to NOT clutter up someone else's topic, please create Your Own New Topic and supply further details about your question/issue.

Thank you.

"And voila, which is French for.......'and then I found out.'" - Ready Player One