App Inventor 2: Not finding a specific block - bluetooth

In the App Inventor 2, where is the block mentioned in last item (figure) of the url: http://beta.appinventor.mit.edu/learn/reference/blocks/definition.html
I am trying to use bluetooth to connect my custom device with Android App.
The internet says:
This block provides a "dummy socket" for fitting a block that has a
plug on its left into a place where there is no socket, such as one of
the sequence of blocks in the do part of a procedure or an if block.
The block you fit in will be run, but its returned result will be
ignored. This can be useful if you define a procedure that returns a
result, but want to call it in a context that does not accept a
result.

You are looking for the evaluate but ignore result block
However in your bluetooth connecting example let me recommend you to use an if statement instead
if BluetoothClient1.connect ...
then do something
else display a message, e.g. "connection was not successful"
see also this bluetooth example
and see the documentation of the Bluetooth components
boolean Connect(text address)
Connect to the Bluetooth device with the specified address and the Serial Port Profile (SPP).
Returns true if the connection was successful.

Related

zbus connection not displayed in busctl list

I'm using the zbus crate to make a server able to get events from the dbus.
It works well my code (basically the same as the example from the documentation) is able to receive events so it's fine.
I use busctl to send an event like in the example:
busctl --user call org.zbus.MyGreeter /org/zbus/MyGreeter org.zbus.MyGreeter1 SayHello s "Maria"
And my code is able to receive the event with the parameter just fine.
The thing is I'm having some issues with udev and while I was trying to fix it I found some weird things:
If I send an event with another user it fails with Call failed: the name org.zbus.MyGreeter was not provided by any .service files while my program is running
When I do busctl list --acquired I don't see org.zbus.MyGreeter in the result
My question is: is it normal my program does not appear in the busctl list? Am I doing something wrong or do I use the wrong library to do what I want to do?
Ok it seems there are 2 busses and I was not using the system bus.
I had to replace the method session to system to indicates I want my program to run on the system bus.
Like this:
let _ = ConnectionBuilder::system()?
.name("org.zbus.MyGreeter")?
.serve_at("/org/zbus/MyGreeter", greeter)?
.build()
.await?;
Doing this is not enough because my program does not have to permission to create a service on the bus system. So I had to create a file in /usr/share/dbus-1/system.d where I did write the configuration needed.

libudev udev_device_get_sysattr_value() return NULL for idVendor/idProduct when device is removed

I'm trying to implement USB monitor service/daemon to detect specfic PID/VID device only. I can easily detect device 'add' action attrib by filtering PID/VID but when I remove ANY USB device from port then as part of 'remove' action attrib, I try to filter PID/VID same like in 'add' action ... by using
const char* vendor = udev_device_get_sysattr_value(dev, "idVendor");
const char* product = udev_device_get_sysattr_value(dev, "idProduct");
but in above two char ptr I always get NULL.
Due to this my remove action will execute for all USB device which will remove from port
Is their any other way in libudev API to detect specific device remove only ?
Once the USB device is at the "remove" action, udev_device_get_sysattr_value(dev) will return NULL in my experience. Even the prior "unbind" action is too late.
One way to detect the removal of a specific device is to store its dev node when it is inserted.
First, find the udev_device* you want to monitor by enumerating the devices (struct udev_enumerate*)(device already plugged in) and monitoring the "add" or "bind" action.
In those states, the udev_device_get_sysattr_value will return the correct strings as you have already seen. If the values match the ones for the device you want to monitor, retrieve its current dev node by calling udev_device_get_devnode(dev). Store that dev node value (strdup to make a copy of it).
In the "unbind" or "remove" action, udev_device_get_devnode(dev) will still return the proper value as opposed to udev_device_get_sysattr_value(dev, prop_name). Match the dev_node with the previously stored dev node to identify that the action applies to the device you are monitoring.
Note that the dev node will likely change every time the device is inserted.

CallKit no sound when answer second call and put first call on hold

I am facing issue with multiple calls when start using CallKit in my VOIP application.
When there is one to one VOIP call, sound is working fine. But once one party gets another VOIP call, and choose to Hold and Accept option; First call is put on hold successfully and second call is answered; But sound gets closed now. Even swapping between calls also does not work. and Dropping one call also does not work.
I am using RTP for voice.
I tried to put breakpoints and check if the AVAudioSession's category and mode are correct.
In the console I can check at my end that the device which has more than one calls, stop sending sound packets.
I am enabling VOIP just before reportNewIncomingCallWithUUID and CXStartCallAction of Provider.
Same case with GSM call. If there is one to one VOIP call with sound is ok and GSM call is received at one side and user choose to Hold and Accept option, sound in GSM call is working fine. But if user makes VOIP call as active and put GSM call on hold by swapping calls, there is no sound in VOIP call. Swapping calls and making GSM call active, sound again works fine. But no sound for VOIP call.
In this case, we are getting AVAudioSessionInterruptionTypeBegan but AVAudioSessionInterruptionTypeEnded is never called. Even after the GSM call is ended.
Has anyone run into similar issues?
Had the same issue. If I have 1 active call, then new calls is incoming, I tap hold&accept. New call works, but after using Swap in CallKit audio stopped working.
After long debug found the spot where actually audio is deactivating/activating for Swap calls via CallKit native interface - that is provider:performSetHeldCallAction: method from CXProviderDelegate protocol.
In my case I used the [audioController deactivateAudioSession] method for the call was putting in OnHold.
But I found that the same method provider:performSetHeldCallAction: was fired for other call that is being put active (from OnHold state), when tap Swap button via CallKit.
So in my case I first toggle hold for call (it put call either on hold or put it active out of hold).
Then I check what is call condition (whether hold or not) and then deactivate or activate audio respectively.
In common way it looks this way:
- (void)provider:(CXProvider *)provider performSetHeldCallAction:(CXSetHeldCallAction *)action {
SomeCallClass *call = [self.callManager callWithUUID:action.callUUID];
if (!call) {
[action fail];
return;
}
NSError *holdError;
[call toggleHold:&holdError];
if (holdError) {
[action fail];
} else {
if (call.onHold)
[self.audioController deactivateAudioSession];
else
[self.audioController activateAudioSession];
[action fulfill];
}
}
This code should be in the class that works as a CallKit provider delegate.

Lync 2013 SDK - Join Conference & Connect AVModality when "Join meeting audio from" setting set to "Do not join audio"

I'm rather new to the Lync 2013 SDK (been using it for a couple weeks now) and have been able to figure out mostly everything I need except for this...
When I'm joining a conference (using ConversationManager.JoinConference()) it joins fine. However, in certain cases (not all), I want to then connect the AVModality on the conference. Sometimes it works, sometimes it just sits in "Connecting" and never connects (even though I've called EndConnect).
What I've found is the setting in Skype's Options -> Skype Meetings -> Joining conference calls section, seems to override my code. Maybe a race condition?
When the setting is "Do not join audio" and "Before I join meetings, ask me which audio device I want to use" is NOT CHECKED (meaning I get no prompt when joining): the conference joins, the AVModality goes Disconnected -> Connecting -> Disconnected. Then my code triggers a BeginConnect and the AVModality goes Disconnected -> Connecting - and never resolves (sometimes I get a fast busy tone audio sound).
When the "Before I join meetings, ask me which audio device I want to use" IS CHECKED (meaning I get the prompt): the conference joins, the prompt asks how to connect, if I select Skype for business - it connects audio fine (expected). Interestingly, if I hang up the call using the Lync UI (AVModality goes to Disconnected), it then immediately connects back again (assuming my BeginConnect doing this).
Here's where it gets really convoluted:
If I call BeginConnect when the state is Connecting on the AVmodality within the ModalityStateChanged event handler... the following happens:
Conference joins, prompt asks me how to connect (AVmodality state is "Connecting" at this point until a decision is made on the prompt) - this means my BeginConnect fires. Then if I choose "Do not join audio" in the prompt... the AVModality status goes Connecting -> Disconnected -> Connecting -> Joining -> Connected. So - my BeginConnect is already in progress and still works in this case so long as it fires BEFORE the selection of "Do not join audio".
So I'm wondering if the "Do not join audio" selection (whether with or without the prompt) actually sets some other properties on something which prevents the AVModality from being connected after that point without doing some additional hocus pocus? If so - I'd like to know the additional hocus pocus I need to perform :)
Thanks for any and all help!
It's come down to this... whether the conference joining does join the audio or not - I've handled every scenario except one, which I still can't figure out:
1. I need the conference audio to be joined, but the user selects to NOT join the audio (either on the prompt, or from the Skype options settings).
In this case - I have added an event handler to the modality state change event, and when the NewState == Disconnected, I trigger a BeginConnect on the modality itself. This works fine. Within the callback, I have the EndConnect call. However - the AVModality state continues to stay in "Connecting" and never resolves to being connected. On the UI - it shows the audio buttons, but all grayed out (like normal when it's connecting). I'm not sure how to make it finish connecting?
Here's a snippet of code:
if (merge)
{
myHandler = delegate (object sender1, ModalityStateChangedEventArgs e1)
{
AVModality avModality = (AVModality)sender1;
Globals.ThisAddIn.confConvo = avModality.Conversation;
if (e1.NewState == ModalityState.Connected)
{
DialNumberInSkype(meetingInfo);
avModality.ModalityStateChanged -= myHandler;
}
if (e1.NewState == ModalityState.Disconnected)
{
object[] asyncState = { avModality, "CONNECT" };
avModality.BeginConnect((ar) =>
{
avModality.EndConnect(ar);
DialNumberInSkype(meetingInfo);
}, asyncState);
avModality.ModalityStateChanged -= myHandler;
}
};
}
EDIT:
For some reason, I'm not able to add a comment right now...
I tried setting the endpoint as you suggested. However, I get an ArgumentException error "Value does not fall within the expected range." So I tried hardcoding the uri value in the CreateContactEndpoint to "sip:my_login#domain.com" (except real value of course) - and got the same ArgumentException error. I added a breakpoint before this and was able to see the value for the avModality.Endpoint - and it is actually set to me the entire time... it's not null or unset when I'm trying to call BeginConnect.
When JoinConference() is invoked audio modality will be connected even without explicitly invoking BeginConnect().
When prompt asking for audio device selection is shown(when ask before join option is set in skype) conversation property ConferenceEscalationProgress will be having value AwaitingJoinDialogResponse.
Setting conversation property ConferenceJoinDialogCompleted as true will initiate Modality connection even though the prompt is not closed.
Edited
If do not join audio is selected, modality will be disconnected, at this point you are trying to invoke BeginConnect(). Try setting modality endpoint before invoking BeginConnect().
conversation.Modalities[ModalityTypes.AudioVideo].Endpoint = lyncClient.Self.Contact.CreateContactEndpoint(lyncClient.Self.Contact.Uri);

Arduino - How to read a string from the Serial Port

I just recently started working with Arduino. I just have a quick question, I tried searching for an answer but have failed for days. Basically what I wanna ask is if there is a way to read a whole line from the Serial Port. Like the line highlighted in the picture below.
What I'm trying to do is using a Bluesmirf Silver Rn-42 to search the area for a bluetooth device and trigger a signal if a matching address is found. I just cant figure out how to read messages that are already on the Serial port.
Use .readString()
Example code:
String myString;
void setup()
{
Serial.begin(9600);
}
void loop()
{
while (Serial.available())
{
myString = Serial.readString();
//do stuff with the string
}
}
If you want to read something that's already in the serial port from the Arduino end, then you need to rethink your code. Anything you produce within your code to print to the serial monitor will already be in your program ready to access if you make it available in the right way. The exemplar string you provided, is simply an array of characters that you can store in an element within an array, making it accessible whenever you need it.
Hints:
Never read back from the serial monitor, it's really slow -.-
Make all the resources you require accessible and available in memory at the time you need it to save hassel & processing power.
Never make the same mistake twice.
However, if you want to read from the COM port that the Arduino is connected to in Windows, then you'll need to work with Libusb libraries found here: http://www.libusb.org/ for C. Any other language will be library or import dependent.

Resources