如何使用Arduino和SIM900A GPRS / GSM模块将数据发送到Web服务器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何使用Arduino和SIM900A GPRS / GSM模块将数据发送到Web服务器相关的知识,希望对你有一定的参考价值。

在路由器上做端口映射。TP-LINK之类的家用路由器上好像有"转发规则"---“虚拟服务器”的下拉菜单。里面设置一下,将你的SIM900A所在的私有地址映射成公网IP。 参考技术A 1、通过短信.2、通过GPRS.

如何接收连接类型已更改的通知(3G、Edge、Wifi、GPRS)

【中文标题】如何接收连接类型已更改的通知(3G、Edge、Wifi、GPRS)【英文标题】:How do I receive notifications that the connection has changed type (3G, Edge, Wifi, GPRS) 【发布时间】:2011-10-07 09:10:34 【问题描述】:

有没有办法发现当前连接是 3G、Edge 还是 WiFi,并收到通知?或者只是一种发现连接是否为 WiFi 的方法?

【问题讨论】:

【参考方案1】:

你应该使用 Apple 的 Reachability 类

http://developer.apple.com/library/ios/#samplecode/Reachability/Listings/Classes_Reachability_h.html

实施后,您可以在委托中使用它:

- (void) configureTextField:  (Reachability*) curReach

    NetworkStatus netStatus = [curReach currentReachabilityStatus];
    BOOL connectionRequired= [curReach connectionRequired];
    NSString* statusString= @"non";
    switch (netStatus)
    
        case NotReachable:
        
            statusString = @"Access Not Available";

            //Minor interface detail- connectionRequired may return yes, even when the host is unreachable.  We cover that up here...
            connectionRequired= NO;  
            break;
        

        case ReachableViaWWAN:
        
            statusString = @"Reachable WWAN";


            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Cellular Data Detected" message:@"You are using Cellular data such as 3G or Edge. Downloading large amount of data may effect your cellular internet package costs. To avoid such extra cost kindly use Wifi." 
                                                           delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
            [alert release];


            break;
        
        case ReachableViaWiFi:
        
            statusString= @"Reachable WiFi";

            break;
        
    
    if(connectionRequired)
    
        statusString= [NSString stringWithFormat: @"%@, Connection Required", statusString];
    
    NSLog(@"Network= %@",statusString);
    if ([statusString isEqualToString:@"Access Not Available"])
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No Internet Connection" message:@"It seems you are not connected to the internet, the app will try to load from the last cached data - assuming this data exist." 
                                                       delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [alert show];
        [alert release];
    
    //textField.text= statusString;



- (void) updateInterfaceWithReachability: (Reachability*) curReach

    if(curReach == hostReach)
    
        //[self configureTextField: remoteHostStatusField imageView: remoteHostIcon reachability: curReach];
       // NetworkStatus netStatus = [curReach currentReachabilityStatus];
       // BOOL connectionRequired= [curReach connectionRequired];

        [self configureTextField:curReach];

       

【讨论】:

【参考方案2】:

是的,Apple 有一个示例项目可以证明这一点。 Reachability

还有here's 一个例子。

【讨论】:

以上是关于如何使用Arduino和SIM900A GPRS / GSM模块将数据发送到Web服务器的主要内容,如果未能解决你的问题,请参考以下文章

arduino 控制sim900A发送短信

基于STM32F103——SIM900A发送短信+串口打印

基于STM32F103——SIM900A发送短信+串口打印

SIM900A TCP/UDP 数据收发 , 串口调试

wifi模块型号特点

Qt : 向 GPRS 调制解调器发送 AT 命令