diff --git a/.gitignore b/.gitignore index 69dcb52..2f74ca4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ # Added by goreleaser init: dist/ + +# Build artifacts +bin/ + +# Claude Code artifacts +.claude/ diff --git a/cmd/gotoMemory.go b/cmd/gotoMemory.go index 5b0fb48..df2c2c5 100644 --- a/cmd/gotoMemory.go +++ b/cmd/gotoMemory.go @@ -15,7 +15,7 @@ import ( "tinygo.org/x/bluetooth" ) -var memory_num int +var memoryNum int var j *jiecang.Jiecang var gotoMemoryCmd = &cobra.Command{ @@ -26,9 +26,9 @@ var gotoMemoryCmd = &cobra.Command{ PreRun: func(cmd *cobra.Command, args []string) { var err error // Validate that argument is an integer between 1 and 3 - memory_num, err = strconv.Atoi(args[0]) - if err != nil || memory_num < 1 || memory_num > 3 { - fmt.Fprintf(os.Stderr, "Memory number is not within boundaries (1-3): %d\n", memory_num) + memoryNum, err = strconv.Atoi(args[0]) + if err != nil || memoryNum < 1 || memoryNum > 3 { + fmt.Fprintf(os.Stderr, "Memory number is not within boundaries (1-3): %d\n", memoryNum) os.Exit(1) } @@ -55,7 +55,7 @@ var gotoMemoryCmd = &cobra.Command{ defer cancel() var err error - switch memory_num { + switch memoryNum { case 1: err = j.GoToMemory1(opCtx) case 2: @@ -64,11 +64,11 @@ var gotoMemoryCmd = &cobra.Command{ err = j.GoToMemory3(opCtx) default: // We should never reach this state as we validate this argument with PreRun hook. - fmt.Fprintf(os.Stderr, "Memory %d is not within boundaries (1-3)\n", memory_num) + fmt.Fprintf(os.Stderr, "Memory %d is not within boundaries (1-3)\n", memoryNum) os.Exit(1) } if err != nil { - fmt.Fprintf(os.Stderr, "Failed to go to memory %d: %v\n", memory_num, err) + fmt.Fprintf(os.Stderr, "Failed to go to memory %d: %v\n", memoryNum, err) os.Exit(1) } }, diff --git a/cmd/listDevices.go b/cmd/listDevices.go index f020a4b..05cc809 100644 --- a/cmd/listDevices.go +++ b/cmd/listDevices.go @@ -55,8 +55,8 @@ func onScan(adapter *bluetooth.Adapter, device bluetooth.ScanResult) { //Print results fmt.Printf("%-20s %-20s %-10s\n", "ADDRESS", "NAME", "RSSI") - for device_address, device := range results { - fmt.Printf("%-20s %-20s %-10d\n", device_address, device.LocalName(), device.RSSI) + for deviceAddr, device := range results { + fmt.Printf("%-20s %-20s %-10d\n", deviceAddr, device.LocalName(), device.RSSI) } } else { mu.Lock() diff --git a/pkg/jiecang/common.go b/pkg/jiecang/common.go index 425f482..0e06f35 100644 --- a/pkg/jiecang/common.go +++ b/pkg/jiecang/common.go @@ -17,18 +17,18 @@ func isValidData(buf []byte) bool { } // Calculate checksum and verify if its correct - data_type := int(buf[2]) - data_len := int(buf[3]) + dataType := int(buf[2]) + dataLen := int(buf[3]) // Length of the data should not exceed the length of the payload. // Last two bytes should always be the checksum and EoM (Ox7e) - if data_len+3 >= len(buf)-2 { + if dataLen+3 >= len(buf)-2 { return false } - received_checksum := int(buf[len(buf)-2]) + receivedChecksum := int(buf[len(buf)-2]) - calc_checksum := data_type + data_len - for i := 0; i < data_len; i++ { - calc_checksum += int(buf[4+i]) + calcChecksum := dataType + dataLen + for i := 0; i < dataLen; i++ { + calcChecksum += int(buf[4+i]) } - return (calc_checksum % 256) == received_checksum + return (calcChecksum % 256) == receivedChecksum } diff --git a/pkg/jiecang/jiecang.go b/pkg/jiecang/jiecang.go index 4cfdf75..8db4277 100644 --- a/pkg/jiecang/jiecang.go +++ b/pkg/jiecang/jiecang.go @@ -197,9 +197,9 @@ func (j *Jiecang) characteristicReceiver(buf []byte) { j.mu.Unlock() case 0x25, 0x26, 0x27, 0x28: // Data contains height for each memory preset (1-4). Memory 4 is currently 0 memory := int(msg[i][2] % 0x24) - memory_name := fmt.Sprintf("memory%d", memory) + memoryName := fmt.Sprintf("memory%d", memory) j.mu.Lock() - j.presets[memory_name] = readMemoryPreset(msg[i]) + j.presets[memoryName] = readMemoryPreset(msg[i]) j.mu.Unlock() case 0x0e: // Data contains units setting fmt.Printf("Unit settings: %x\n", msg[i][3])