adafruit / Adafruit_BluefruitLE_nRF51

Arduino library for nRF51822-based Adafruit Bluefruit LE modules
197 stars 122 forks source link

Mixing data and command modes #4

Closed carsonmcdonald closed 8 years ago

carsonmcdonald commented 9 years ago

Is there a reason that AT commands executed from the Adafruit_BLE base class shouldn't ensure command mode before being executed? I didn't realize that isConnected used an AT command and while in data mode that AT command just ends up going out to what is connected. I can construct a PR with what I'm thinking as a change but I wanted to make sure I'm not missing something.

This is what I ended up doing and it seems to work just fine but I'm using an LE micro so I don't know if there are reasons the UART version shouldn't do this for example:

  ble.setMode(BLUEFRUIT_MODE_COMMAND);
  bool isConnected = ble.isConnected();
  ble.setMode(BLUEFRUIT_MODE_DATA);

Roughly I'm thinking you shouldn't need to worry about switching, the library should just do it for you for anything that expects AT commands or executes AT commands under the covers.

pokono commented 8 years ago

+1

hathach commented 8 years ago

Already did with following "builtin" function, we can run these command while in DATA_MODE

and probably all the new one as well