B4J Question Call a shell command in interactive mode

Discussion in 'B4J Questions' started by Alessandra Pellegri, Aug 12, 2019.

  1. Alessandra Pellegri

    Alessandra Pellegri Active Member Licensed User

    I would like to open something like bluetoothctl and interact with it.
    For example:
    Code:
    [bluetoothctl] menu gatt
    [bluetoothctl] register-
    service 0xFFFF # (Choose yes when asked if primary service)
    [NEW] Primary 
    Service
            /org/bluez/app/service0x10e51e0
            
    0xFFFF
            Unknown
    [/org/bluez/app/service0x10e51e0] Primary (yes/no): yes
    [bluetoothctl] register-characteristic 
    0xAAAA read       # (Select a value of 1 when prompted)
    [NEW] Characteristic
            /org/bluez/app/service0x10e51e0/chrc0x10e5688
            
    0xAAAA
            Unknown
    [/org/bluez/app/service0x10e51e0/chrc0x10e5688] Enter value: 
    1
    [bluetoothctl] register-
    application # (This commits the services/characteristics and registers the profile)
    [bluetoothctl] back
    [bluetoothctl] advertise on
    So I'd need to generate an event everytime the shell writes something.

    Is it possible ?

    Thank you
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Not so simple but it is possible. You can start the process with InputStreamEnabled set to True and run it with RunWithOutputEvents. This will allow you to read the process output and write to the process input.

    Note that the output events are raised on background threads.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice