2017년 5월 7일 일요일

502 error using AI2 Web component


I'm getting a 502 error trying to reach the website www.azlyrics.com via a Web component running on a Android tablet via Wifi. I can reach this site fine from the Chrome browser on the same tablet, and I can reach other web sites with the same app and component on the tablet (like www.google.com).  Is the AppInventor server possibly blocking this site for some reason?  Any other ideas about what's causing the error?

--
is there any error text together with error 502?

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

--
Thanks for your response. Screen shot of reduced app attached - sorry I neglected that initially. 

Interestingly, on my home network I get a local Error 1101 Unable to get a response with the specified URL: http://www.azlyrics.com/  instead of the 502 I was getting this morning on my school network. However, I can still reach this URL fine with my browser on the same Android device. And every other web site (google, mit, xkcd, ...) I've tried works fine.  I'll see if I can get the 502 again tomorrow and report the responses I get back. 
--
The 502 error on the school network was being generated by our firewall, with a message of "zero length response attempting to retrieve URL www.azlyrics.com".  When I bypassed the firewall, I got the same screen Error 1101 I got at home. I added a screen error block (see attached), and the full response is:
component: com.google.appinventor.components.runtime.Web@22532eac
functionName: Get
errorNumber: 1101
message: Unable to get a response with the specified URL: http://www.azlyrics.com

It still works fine via a Chrome browser on the same device over the same wireless link.

Maybe there's something about how this specific website responds to the initial http get from the AppInventor web component that the component can't handle that was also upsetting our firewall?  How would that get be different from the one generated by Chrome which makes it through our firewall fine?  Or I am totally confused about how this works?
--
yes, I also get error 1101
probably they have some kind of protection running to avoid people downloading their lyrics?

--
Yeah, that's probably it. Wonder what they're looking at in the html or tcp headers?

--

Label reads text from .txt file on webserver (kind of Push)


Hello, during improving my application i would like to ask you if there is any possibility of what i want. (I need to say that i am pretty nooby so step by step would be appreciated)

Due to i can not find easy way of push notifications (free) i can imagine, that on screen is 1 label.
This label reads the messages from file "news.txt" on some webserver (www.here.com/news.txt.

This way i could inform users, that they should do the update and stuff. Do you have any idea how this could work? 

--

Follow the following steps:


Step-1: Make sure that you are in the same screen that contains your Label and switch to the Designer View.
Step-2: From under the "Connectivity" menu in the palette, click and drag the "web" component into the viewer.
Step-3: Now switch to the Blocks view.
Step-4: Select your screen_name from the left of the screen. From the options that you'll get, click and drag the "When screen_name.Initialize" block into the designer, where screen_name  is the name of the screen.
Step-5: Now click on the "Web1" or similar named component from the left list. (This is the one that you've recently dragged into the viewer) and select and drag the "set Web1 . Url to" into the designer and make it a "block" with "When screen_name.Initialize component. You can do this by dragging this component into the "When screen_name.Initialize" component, and set the URL to the desired one with a text string.
Step-6: Similarly, select "Web1" once again, and select "call web1.get". This sends the request to the server.
Step-7: Select "Web1" once again and choose "when Web1. GotText" from the menu that appears, and drag it into the  blocks editor. Here we can define what happens when the web component receives (gets) a text as response.
Step-8: In our case, we want to display it as the text for label. So, select that Label item from the left, and select "Set Label1. text to" (this name "Label1" depends on what you've used as a name).
Step-9: Finally, make it a block with "when Web1. GotText"  and to specify its input, hover your cursor over the "responseContent" in the frame of the "when Web1. GotText" until you get a "get responseContent" block. Drag this and make this as the input for "Set Label1. text to" (SEE PICTURE)

and you are done!

Make sure you've set the text of the label to something like "loading news..." initially, so that the time taken during the process can be covered. You have to be connected to the internet when the screen is opened, else you'll get a "1101" Error message.

--

Make a DrawCircle behave like a Ball


Hey! so I've been trying to develop a PinBall app with AppInventor but I haven't found a way to add gravity to a ball. A few days ago I found some code that made a DrawCircle with Gravity and Bounce but it doesn´t collide with any objects and I can't find a way to do so. And I can't find a way to add gravity to a ball either since most vectors only seem to work with other procedures (For example DrawCircle). so, is there a way to make the DrawCircle collide with other sprites? or to substitute the DrawCircle with a ball while adding the gravity? Thanks!

You can see in the attached file the gravity code on the right, the code that makes the pinball pads move on the top left, and what I've tried to do for the collisions on the bottom left.

--
Downloaded blocks image?

-- 
Great, forgot to attach it haha. There are the blocks


-- 
If you want collisions, switch to Ball components, or prepare yourself to do a lot
of work in your clock timer event checking every possible moving object
for proximity to every other obstacle.

See these samples ...



-- 
Regarding gravity, to add that to a sprite or ball moving under its own power
(Speed > 0), you would have to translate speed and direction into X velocity
and Y velocity, then change the Y velocity a little each clock tick,
feeding the two velocities back into the speed and direction.

-- 
Do you have a code example? I tired but I guess I failed haha

-- 
you can find several gravity examples in Scott's Developers Library here search for gravity

--

Tips and Tricks: Drag a sprite from it's center


You can drag ImageSprites and a Balls from their center points by adding a few blocks to their Dragged events.
URL to YouTube video: http://youtu.be/OQA_210FH8I
--

Drag a sprite from it's center


Bounce a circle with gravity


I am continuing my training to learn game physics to create a simple physics engine for App Inventor apps until we have support for gravity.
The current lesson deals with bouncing and gravity so this project tests these features.
The original tutorial is in javascript, but there is enough similarity for me to recreate it with App Inventor blocks.
The sliders allow you to play with the force of gravity and the bounciness of the circle.
Remember, this is not a Ball sprite we are animating, but we are using DrawCircle to draw a circle on the canvas.
Because of this, we must clear the screen each time the circle is moved to remove the old circle and draw the new one.
Challenge:
If we were using a Ball sprite we could just move it.
Try substituting a Ball sprite MoveTo x,y for the DrawCircle command then you can remove the Canvas.Clear command.
But set it's speed property to 0 as the app will set it's x,y values to move it.
Also, when testing the location of and moving the Ball sprite, you will need to subtract the radius from the x and y values as the DrawCircle block uses the center x,y point of the drawn circle whereas a Ball sprite uses the upper left corner x,y.
--

Gravity Exercise




Changes log:
2015/09/08 - bug fix -- ball could stick to canvas bottom; new version is 2
---
END of changes log
Fling anywhere on the the Canvas to see the gravity demonstration.
Try adjusting the gravity, bounciness and rolliness values to simulate different materials and bodies (earth - 1.5 vs the moon - 0.25)
How it works: 
A Clock Timer is used to update the position of a ball by applying x and y velocities and gravity.
When the ball bounces a bounciness multiplier reduces it's y velocity until it eventually stops bouncing.
When the ball rolls, a rolliness multiplier reduces it's x velocity until it eventually stops rolling.
--
Nice demo, but my ball mostly just lays there.
I may need to consult with my personal physicist.

--
Are you flinging the canvas (not the ball itself) in a upward direction?
If the ball doesn't move much, you can reduce gravity and/or increase the FlingVelocityAdjustment value to be more responsive.

If the ball sticks to the bottom of the canvas rather than bounce sometimes that (hopefully) has been corrected with a bug fix in updated version 2 which is attached here and in the Gallery.
Thanks for trying it out!

--

search for gravity


Fling anywhere on the the Canvas to see the gravity demonstration. Try adjusting the gravity, bounciness and rolliness values to simulate different ...
I am continuing my training to learn game physics to create a simple physics engine for App Inventor apps until we have support for gravity.
This is a simple study of simulating gravity with a ball. Touch the screen to launch the ball. When it starts rolling slowly enough you can pick it up and ...
Fling anywhere on the Canvas to submit an innocent drawn circle to torturous throwing, bouncing, gravitating and sliding. No Ball or ImageSprite ...
This project uses the concepts of particles and vectors to represent a planet orbiting a sun. The planet's speed and distance from the sun can be ...
The diagram below shows that if the device is laid face up on a table top, the ZAccel value from gravity will be positive. Turning the device on it's left ...
That way, if things such as gravity must be simulated, it is easy to snap together the blocks to do it. Or if I need to make two drawn circles collide, I can ...
jump velocity and gravity now adjusted to match device processor speed. * scrolling speed is now more consistent across devices by setting Intervals ...
It should also be possible to add gravity to the velocity and gravity will act only in the y direction so will not affect the XSpeed value. Add friction to stop ...


How can i print multiple sensor data on app in separately


I have made one App in mit app inventor 2. In which i have used 5 sensor and bluetooth module. I am sending multiple sensor data on app but it gives error bad list arguments.I have trouble in receiving data on separate text. would you please explain me how can i receive data on separately. 
please reply as soon as possible.


--
See the posts on using Delimiters in the Arduino/Bluetooth section of this FAQ:

For more specific help, include in your post attachments with:

Your Arduino sketch (.ino)
Downloaded blocks images 
Screen shots of your Bluetooth component options in the Designer
a .aia export
Screen shots of run time behavior

-- 
 I am Attaching below my arduino code file , block images and screenshot of run time behaviour. would you please explain me how can i remove this error. 

code

#include <SoftwareSerial.h>
#include <DHT.h>

#define DHTPIN 7      // what pin we're connected to
#define DHTTYPE DHT22   // DHT 22  (AM2302)
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor for normal 16mhz Arduino

SoftwareSerial BTserial(4, 3); // RX | TX

float t;
float h;

char Temp_data;
char Hum_data;
char buffer [10];
float Temperature ()
{
 // Read temperature as Celsius (the default)
  t = dht.readTemperature();
  return (t);
  
 }
float Humidity ()
 {
  //Read data and store it to variables hum and temp
  h = dht.readHumidity();
  return (h);
 }  

 void setup() 
{
   Serial.begin(9600);
   BTserial.begin(9600);
  // put your setup code here, to run once:
pinMode (DHTPIN, OUTPUT); // Temperature pin set as output

}

void loop() 
{
  // put your main code here, to run repeatedly:

  int temp = Temperature ();
  int hum = Humidity ();
  sprintf (buffer, "%d ,%d", temp, hum);

  Serial.println(buffer);
  BTserial.println (buffer);

  //BTserial.print ("temperature =");
  BTserial.print (temp);
  BTserial.print ("C");
  delay(1000);

 // BTserial.print ("humidity =");  
  BTserial.print (hum);  
  BTserial.print ("%");
  delay (1000);
}





-- 
You did not supply a .aia export, so diagnosis will be limited.

You are sending three different types of message from your Arduino:
1. a comma separated list of temp and humidity, ending in LF
2. temperature readings ending in "C"
3. humidity readings ending in "%"

You need to test each incoming message to see if it contains a comma, or a "C", or a "%",
so you can decide which label to put it into.

If the incoming messages contains a comma, only then should you split it into a list.

Don't make any assumptions about how many items will be on the list.
Test if length of list (list) > 1 before asking for item 2.
Test if length of list (list) > 2 before asking for item 3.
etc.

Also, you should not need 2 clocks, 1 will work for you if you do it right.

See this link for how to use println() to send separate messages,
and for how to receive them one at a time using a delimiter.

-- 
Hello Sir, I am not getting separate data in app. How can i differ it. would you please send me correct arduino code and block in my app

-- 
I am not getting separate data in app. How can i differ it. would you please send me correct arduino code and block for my app.
I am sending my app .aia file. File attach below.


--