1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-16 04:45:17 +03:00

Bluetooth driver added to Horus, BT_EN_GPIO_PIN was wrong on beta board (#4005)

CLI interface for Bluetooth
This commit is contained in:
Damjan Adamic 2016-11-11 19:56:36 +01:00 committed by Bertrand Songis
parent 5869b81e9c
commit 7b2d8b1f0a
10 changed files with 330 additions and 10 deletions

View file

@ -793,6 +793,45 @@ int cliGps(const char ** argv)
}
#endif
#if defined(PCBX9E) || defined(PCBHORUS)
int cliBlueTooth(const char ** argv)
{
int baudrate = 0;
if (argv[1][0] == '$') {
// send command to GPS
bluetoothWriteString(argv[1] + 1);
bluetoothWriteString("\r\n");
serialPrint("bt sent: %s", argv[1] + 1);
CoTickDelay(100); // 200ms
char buff[100];
int len = bluetoothRead(buff, 100);
buff[len] = 0;
serialPrint("bt read: %s", buff);
}
else if (!strcmp(argv[1], "read")) {
char buff[100];
int len = bluetoothRead(buff, 100);
buff[len] = 0;
serialPrint("bt read: %s", buff);
}
else if (toInt(argv, 1, &baudrate) > 0) {
if (baudrate > 0) {
bluetoothInit(baudrate);
serialPrint("BT baudrate set to %d", baudrate);
}
else {
bluetoothDone();
serialPrint("BT turned off");
}
}
else {
serialPrint("%s: Invalid arguments", argv[0]);
}
return 0;
}
#endif // #if defined(PCBX9E) || defined(PCBHORUS)
const CliCommand cliCommands[] = {
{ "beep", cliBeep, "[<frequency>] [<duration>]" },
{ "ls", cliLs, "<directory>" },
@ -818,7 +857,10 @@ const CliCommand cliCommands[] = {
{ "jitter", cliShowJitter, "" },
#endif
#if defined(INTERNAL_GPS)
{ "gps", cliGps, "<baudrate>" },
{ "gps", cliGps, "<baudrate>|$<command>|trace" },
#endif
#if defined(PCBX9E) || defined(PCBHORUS)
{ "bt", cliBlueTooth, "<baudrate>|$<command>|read" },
#endif
{ NULL, NULL, NULL } /* sentinel */
};