Closed ZavenArra closed 1 year ago
C/C++
setSensor(SensorPayload payload)
getSessor()
setActuator()
getActuator()
setupCommands(){
rust.registerCommand( ‘sensor’, ‘get’, &getSensor)
rust.registerCommand( ‘sensor’, set’, &setSensor)
}
RUST
struct SensorPayload {
warmUpTime
pinNumber
Etc….
// some or all of these can be null
// we will stuff like -1 to handle nulls
}
gotMessage( payload) {
identity = f”{payload.objectType}_{payload.commandType}”
cFunction = commandRegistery.get(identity)
// map payload to the right struct for this identity
// call the .init of this struct
// note: all these structs are FFI’d back to C and are used in the def’n of the functions that are
// passed as pointers
theObjectToPassBackToC = {
cFunction,
payloadMappedToTheRightObject
}
cExecuterFunction( theObjectToPassBackToC)
}
Leave the FFI payload struct type and mapping JSON to the right struct out of this ticket.
Function pointers corresponding to each command are registered with a tuple of (objectType, actionType)
Acceptance Criteria