Avoid more continuation confusion

This commit is contained in:
Tony Garnock-Jones 2022-03-01 11:17:24 +01:00
parent 9139fc8644
commit 6dccd4ce9e
4 changed files with 27 additions and 14 deletions

View File

@ -36,13 +36,21 @@ def main(args):
except FileNotFoundError:
pass
@dataspace.during(config, P.bind(P.quote(userSettings.Command(P.u_, P.u_))))
def handle_command(c):
c = userSettings.Command.try_decode(c)
if c is None: return
c.action._accept({
def perform_action(action):
action._accept({
'assert': assert_item,
'retract': retract_item,
})
if c.reply.VARIANT.name == 'replyWanted':
turn.publish(c.reply.value, userSettings.CommandReply())
@dataspace.during(config, P.bind(P.quote(userSettings.CommandRPC(P.u_, P.u_))))
def handle_command_rpc(c):
c = userSettings.CommandRPC.try_decode(c)
if c is None: return
perform_action(c.action)
turn.publish(c.reply, userSettings.CommandReply())
@dataspace.on_message(config, P.bind(P.quote(userSettings.CommandEvent(P.u_))))
def handle_command_event(c):
c = userSettings.CommandEvent.try_decode(c)
if c is None: return
perform_action(c.action)

View File

@ -18,6 +18,8 @@ call-state
AnswerCall´³rec´³lit³ answer-call„´³tupleµ´³named³callId´³atom³ SignedInteger„„„„„³
NumberType´³orµµ±unknown´³lit³unknown„„µ± international´³lit³ international„„µ±national´³lit³national„„µ±gsm0338´³lit³gsm0338„„„„³ PeerRinging´³rec´³lit³ peer-ringing„´³tupleµ„„„³ SmsDelivery´³rec´³lit³ sms-delivery„´³tupleµ´³named³smsc´³refµ„³Address„„´³named³peer´³refµ„³Address„„´³named³ timestamp´³refµ³time„³Stamp„„´³named³body´³atom³String„„„„„³ ModemPresent´³rec´³lit³modem„´³tupleµ´³named³type´³atom³Symbol„„´³named³
devicePath´³atom³String„„´³named³ dataspace´³embedded³any„„„„„³ PhoneRinging´³rec´³lit³ phone-ringing„´³tupleµ„„„³ ReleaseCause´³orµµ±unassignedNumber´³lit³unassignedNumber„„µ±normal´³lit³normal„„µ±busy´³lit³busy„„µ±noUserResponding´³lit³noUserResponding„„µ± callRejected´³lit³ callRejected„„µ±destinationOutOfOrder´³lit³destinationOutOfOrder„„µ±normalUnspecified´³lit³normalUnspecified„„µ±incompatibleDestination´³lit³incompatibleDestination„„„„³ Speakerphone´³rec´³lit³ speakerphone„´³tupleµ„„„³ CallDirection´³orµµ±mo´³lit³mo„„µ±mt´³lit³mt„„„„³CallIdSelector´³orµµ± specificCall´³atom³ SignedInteger„„µ±allCalls´³lit³all„„„„³CallInProgress´³rec´³lit³call-in-progress„´³tupleµ„„„³DisconnectCall´³rec´³lit³disconnect-call„´³tupleµ´³named³callId´³refµ„³CallIdSelector„„´³named³cause´³refµ„³ ReleaseCause„„„„„³SmsTransmission´³rec´³lit³sms-transmission„´³tupleµ´³named³smsc´³refµ„³Address„„´³named³peer´³refµ„³Address„„´³named³body´³atom³String„„´³named³ continuation´³embedded´³lit³ok„„„„„„„³ embeddedType€„„µ³ soundEffects„´³schema·³version³ definitions·³
AlertSound´³rec´³lit³ alert-sound„´³tupleµ´³named³data´³refµ³mime„³Value„„„„„³ContinuousSound´³rec´³lit³continuous-sound„´³tupleµ´³named³data´³refµ³mime„³Value„„„„„³AlertSoundPlaying´³rec´³lit³alert-sound-playing„´³tupleµ„„„³ContinuousSoundPlaying´³rec´³lit³continuous-sound-playing„´³tupleµ„„„„³ embeddedType€„„µ³ userSettings„´³schema·³version³ definitions·³Value´³rec´³lit³ user-setting„´³tupleµ´³named³item³any„„„„³Action´³orµµ±assert´³rec´³lit³assert„´³tupleµ´³named³item³any„„„„„µ±retract´³rec´³lit³retract„´³tupleµ´³named³item³any„„„„„„„³Command´³rec´³lit³user-settings-command„´³tupleµ´³named³action´³refµ„³Action„„´³named³reply´³refµ„³CommandContinuation„„„„„³ CommandReply´³lit³done„³CommandContinuation´³orµµ± replyWanted´³embedded´³refµ„³ CommandReply„„„µ± fireAndForget´³lit€„„„„„³ embeddedType€„„µ³usersAndGroups„´³schema·³version³ definitions·³Spec´³orµµ± userAccount´³lit³user„„µ± systemAccount´³lit³system„„µ±id´³atom³ SignedInteger„„„„³Group´³rec´³lit³grent„´³tupleµ´³dict·³gid´³named³gid´³atom³ SignedInteger„„³name´³named³name´³atom³String„„„„„„„³Account´³rec´³lit³pwent„´³tupleµ´³dict·³gid´³named³gid´³atom³ SignedInteger„„³uid´³named³uid´³atom³ SignedInteger„„³home´³named³home´³atom³String„„³info´³named³info´³atom³String„„³name´³named³name´³atom³String„„³shell´³named³shell´³atom³String„„„„„„„³ EnsureGroup´³rec´³lit³ ensure-group„´³tupleµ´³named³name´³atom³String„„´³named³spec´³refµ„³Spec„„„„„³ GroupMember´³rec´³lit³ group-member„´³tupleµ´³named³uid´³atom³ SignedInteger„„´³named³gid´³atom³ SignedInteger„„„„„³ EnsureAccount´³rec´³lit³ensure-account„´³tupleµ´³named³name´³atom³String„„´³named³spec´³refµ„³Spec„„„„„„³ embeddedType€„„µ³samsungGalaxyS7„´³schema·³version³ definitions·³ FmtPacket´³rec´³lit³fmt„´³tupleµ´³named³body´³embedded³any„„„„„³ RfsPacket´³rec´³lit³rfs„´³tupleµ´³named³body´³embedded³any„„„„„³ ModemPacket´³orµµ±in´³rec´³lit³
from-modem„´³tupleµ´³named³packet³any„„„„„µ±out´³rec´³lit³to-modem„´³tupleµ´³named³packet³any„„„„„„„³ ModemPresent´³rec´³lit³modem„´³tupleµ´³lit³samsung-galaxy-s7„´³named³
devicePath´³atom³String„„´³named³ dataspace´³embedded´³refµ„³InternalProtocol„„„„„„³ExecuteCommand´³rec´³lit³execute-command„´³tupleµ´³named³command´³refµ„³ FmtPacket„„´³named³replyTo´³refµ„³CommandContinuation„„„„„³InternalProtocol³any³CommandContinuation´³orµµ± replyWanted´³embedded´³refµ„³ FmtPacket„„„µ± fireAndForget´³lit€„„„„„³ embeddedType€„„„„
AlertSound´³rec´³lit³ alert-sound„´³tupleµ´³named³data´³refµ³mime„³Value„„„„„³ContinuousSound´³rec´³lit³continuous-sound„´³tupleµ´³named³data´³refµ³mime„³Value„„„„„³AlertSoundPlaying´³rec´³lit³alert-sound-playing„´³tupleµ„„„³ContinuousSoundPlaying´³rec´³lit³continuous-sound-playing„´³tupleµ„„„„³ embeddedType€„„µ³ userSettings„´³schema·³version³ definitions·³Value´³rec´³lit³ user-setting„´³tupleµ´³named³item³any„„„„³Action´³orµµ±assert´³rec´³lit³assert„´³tupleµ´³named³item³any„„„„„µ±retract´³rec´³lit³retract„´³tupleµ´³named³item³any„„„„„„„³
CommandRPC´³rec´³lit³user-settings-command„´³tupleµ´³named³action´³refµ„³Action„„´³named³reply´³embedded´³refµ„³ CommandReply„„„„„„³ CommandEvent´³rec´³lit³user-settings-command„´³tupleµ´³named³action´³refµ„³Action„„„„„³ CommandReply´³lit³done„„³ embeddedType€„„µ³usersAndGroups„´³schema·³version³ definitions·³Spec´³orµµ± userAccount´³lit³user„„µ± systemAccount´³lit³system„„µ±id´³atom³ SignedInteger„„„„³Group´³rec´³lit³grent„´³tupleµ´³dict·³gid´³named³gid´³atom³ SignedInteger„„³name´³named³name´³atom³String„„„„„„„³Account´³rec´³lit³pwent„´³tupleµ´³dict·³gid´³named³gid´³atom³ SignedInteger„„³uid´³named³uid´³atom³ SignedInteger„„³home´³named³home´³atom³String„„³info´³named³info´³atom³String„„³name´³named³name´³atom³String„„³shell´³named³shell´³atom³String„„„„„„„³ EnsureGroup´³rec´³lit³ ensure-group„´³tupleµ´³named³name´³atom³String„„´³named³spec´³refµ„³Spec„„„„„³ GroupMember´³rec´³lit³ group-member„´³tupleµ´³named³uid´³atom³ SignedInteger„„´³named³gid´³atom³ SignedInteger„„„„„³ EnsureAccount´³rec´³lit³ensure-account„´³tupleµ´³named³name´³atom³String„„´³named³spec´³refµ„³Spec„„„„„„³ embeddedType€„„µ³samsungGalaxyS7„´³schema·³version³ definitions·³ FmtPacket´³rec´³lit³fmt„´³tupleµ´³named³body´³embedded³any„„„„„³ RfsPacket´³rec´³lit³rfs„´³tupleµ´³named³body´³embedded³any„„„„„³
CommandRPC´³rec´³lit³execute-command„´³tupleµ´³named³command´³refµ„³ FmtPacket„„´³named³replyTo´³embedded´³refµ„³ FmtPacket„„„„„„³ ModemPacket´³orµµ±in´³rec´³lit³
from-modem„´³tupleµ´³named³packet³any„„„„„µ±out´³rec´³lit³to-modem„´³tupleµ´³named³packet³any„„„„„„„³ CommandEvent´³rec´³lit³execute-command„´³tupleµ´³named³ commandText´³refµ„³ FmtPacket„„„„„³ ModemPresent´³rec´³lit³modem„´³tupleµ´³lit³samsung-galaxy-s7„´³named³
devicePath´³atom³String„„´³named³ dataspace´³embedded´³refµ„³InternalProtocol„„„„„„³InternalProtocol³any„³ embeddedType€„„„„

View File

@ -14,5 +14,6 @@ FmtPacket = <fmt @body #!any> .
RfsPacket = <rfs @body #!any> .
; Assertion. Asks the modem to execute the given command.
ExecuteCommand = <execute-command @command FmtPacket @replyTo CommandContinuation> .
CommandContinuation = @replyWanted #!FmtPacket / @fireAndForget #f .
CommandRPC = <execute-command @command FmtPacket @replyTo #!FmtPacket> .
; Message. Asks the modem to execute the given command, but not to send back the reply.
CommandEvent = <execute-command @commandText FmtPacket> .

View File

@ -1,8 +1,10 @@
version 1 .
; Assertion.
Command = <user-settings-command @action Action @reply CommandContinuation> .
CommandContinuation = @replyWanted #!CommandReply / @fireAndForget #f .
CommandRPC = <user-settings-command @action Action @reply #!CommandReply> .
; Message.
CommandEvent = <user-settings-command @action Action> .
CommandReply = =done .
Action = <assert @item any> / <retract @item any> .