Skip to content

Commit

Permalink
bug fix for multiple GATT services, also transmit on standard Nordic …
Browse files Browse the repository at this point in the history
…UART TX Gatt
  • Loading branch information
b3nn0 committed Jul 6, 2024
1 parent c05b112 commit 5e63e5e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
9 changes: 7 additions & 2 deletions main/gen_gdl90.go
Original file line number Diff line number Diff line change
Expand Up @@ -1316,11 +1316,16 @@ func defaultSettings() {
{Conn: nil, Ip: "", Port: 49002, Capability: NETWORK_POSITION_FFSIM | NETWORK_AHRS_FFSIM},
}
globalSettings.BleOutputs = []bleConnection{
{
{ // SoftRF style service
Capability: NETWORK_FLARM_NMEA,
UUIDService: "FFE0", // SoftRF style service,
UUIDService: "FFE0",
UUIDGatt: "FFE1",
},
{ // "standard" nRF UART/Serial emulation
Capability: NETWORK_FLARM_NMEA,
UUIDService: "6E400001-B5A3-F393-E0A9-E50E24DCCA9E",
UUIDGatt: "6E400003-B5A3-F393-E0A9-E50E24DCCA9E",
},
}
globalSettings.DEBUG = false
globalSettings.DisplayTrafficSource = false
Expand Down
6 changes: 3 additions & 3 deletions main/gps.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,13 +308,13 @@ func initGPSSerial() bool {
device = "/dev/softrf_dongle"
globalStatus.GPS_detected_type = GPS_TYPE_SOFTRF_DONGLE
baudrates[0] = 115200
} else if _, err := os.Stat("/dev/ttyS0"); err == nil {
} else if _, err := os.Stat("/dev/serial0"); err == nil {
// ttyS0 is PL011 UART (GPIO pins 8 and 10) on all RPi.
// assume that any GPS connected to serial GPIO is ublox
device = "/dev/ttyS0"
device = "/dev/serial0"
globalStatus.GPS_detected_type = GPS_TYPE_UBX_GEN
baudrates = []int{115200, 38400, 9600}
logInf("GPS - device detected at serial port /dev/ttyS0, assuming this is an ublox device, configuring as generic ublox:")
logInf("GPS - device detected at serial port /dev/serial0, assuming this is an ublox device, configuring as generic ublox:")
logChipConfig("", "generic ublox", device, targetBaudRate, "")
logInf("GPS - consider to configure this device manually in /boot/firmware/stratux.conf for optimal performance")
} else {
Expand Down
9 changes: 5 additions & 4 deletions main/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ func refreshConnectedClients() {
}

func parseBleUuid(uuidStr string) (uuid bluetooth.UUID) {
if len(uuid) == 4 {
if len(uuidStr) == 4 {
// Assume hex 16 bit
var val uint64
val, _ = strconv.ParseUint(uuidStr, 16, 16)
Expand Down Expand Up @@ -400,7 +400,8 @@ func initBluetooth() {
addSingleSystemErrorf("BLE", "BLE Advertising failed to start: %s", err.Error())
}
// TODO: not working if we have multiple GATTs in one service
for _, conn := range globalSettings.BleOutputs {
for i := range globalSettings.BleOutputs {
conn := &globalSettings.BleOutputs[i]
err := bleAdapter.AddService(&bluetooth.Service{
UUID: parseBleUuid(conn.UUIDService),
Characteristics: []bluetooth.CharacteristicConfig {
Expand All @@ -421,8 +422,8 @@ func initBluetooth() {
continue
}
netMutex.Lock()
clientConnections[conn.GetConnectionKey()] = &conn
go connectionWriter(&conn)
clientConnections[conn.GetConnectionKey()] = conn
go connectionWriter(conn)
netMutex.Unlock()
}
}
Expand Down

0 comments on commit 5e63e5e

Please sign in to comment.