-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from wimaha/dev
Exposing vehicle data from BLE to the Http Proxy
- Loading branch information
Showing
8 changed files
with
509 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,46 @@ | ||
package control | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"strings" | ||
"sync" | ||
|
||
"github.com/teslamotors/vehicle-command/pkg/vehicle" | ||
) | ||
|
||
type ApiResponse struct { | ||
Wait *sync.WaitGroup | ||
Result bool | ||
Error string | ||
Response json.RawMessage | ||
} | ||
|
||
type Command struct { | ||
Command string | ||
Vin string | ||
Body map[string]interface{} | ||
Command string | ||
Vin string | ||
Body map[string]interface{} | ||
Response *ApiResponse | ||
} | ||
|
||
// 'charge_state', 'climate_state', 'closures_state', 'drive_state', 'gui_settings', 'location_data', 'charge_schedule_data', 'preconditioning_schedule_data', 'vehicle_config', 'vehicle_state', 'vehicle_data_combo' | ||
var categoriesByName = map[string]vehicle.StateCategory{ | ||
"charge_state": vehicle.StateCategoryCharge, | ||
"climate_state": vehicle.StateCategoryClimate, | ||
"drive": vehicle.StateCategoryDrive, | ||
"closures_state": vehicle.StateCategoryClosures, | ||
"charge-schedule": vehicle.StateCategoryChargeSchedule, | ||
"precondition-schedule": vehicle.StateCategoryPreconditioningSchedule, | ||
"tire-pressure": vehicle.StateCategoryTirePressure, | ||
"media": vehicle.StateCategoryMedia, | ||
"media-detail": vehicle.StateCategoryMediaDetail, | ||
"software-update": vehicle.StateCategorySoftwareUpdate, | ||
"parental-controls": vehicle.StateCategoryParentalControls, | ||
} | ||
|
||
func GetCategory(nameStr string) (vehicle.StateCategory, error) { | ||
if category, ok := categoriesByName[strings.ToLower(nameStr)]; ok { | ||
return category, nil | ||
} | ||
return 0, fmt.Errorf("unrecognized state category '%s'", nameStr) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.