3

before I start I realize this issue has been raised before in this forum because I found the thread. However, the question was not answered.

I am building a system using iPhones as the worker machines. I phrase it like this because I want to place an emphasis on the phone not being some product of apple but as a piece of equipment which is either capable or not of performing a given task.

I have jailbroken both phones I am using and will use them exclusively to achieve a solution to the problem the system sets out to solve. My system will be used by me and me alone and so the issue of how Apple intended these devices to be used, the user experience etc is irrelevant to me.

Ok, having said all that I'll briefly outline the system. Two iPhones, one with its guts in an electronics project box nailed above my front door, camera facing visitors. Other iPhone, intact and in my pocket. I have hooked pins 1 & 11 to the door bell button and alert the phone to its being pressed by monitoring the audio route change. I need an app on my pocket phone that will be woken by a notification sent by the door phone. The door phone will also send an image once I have accepted the notification on my pocket phone. There is no internet here at all, I do however have a wifi router to which both phones are connected.

So that's the system, I have searched high and low to find code that can help me to get the door phone to generate a push notification and send it to my pocket phone, all I have found so far is this https://github.com/stefanhafeneger/PushMeBaby which is what I need only it's written for mac not iPhone and I'm new to Objective C so porting is really hard.

Please could someone give me a hand to accomplish what I am trying to do, I know Apple didn't intend for me to use its product like I am but then neither do a lot of manufacturers but hobbyists still manage to use them in ever more inventive and innovative ways irrespective. I am currently using a PC and a webcam to see who's at the door and it uses a lot of electric, the new system is far better if only I can get it to work so please, please if you have the ability/knowledge to help me then post a reply and I will be eternally grateful. Thanks you, Richard.

lorddarkangel
  • 212
  • 3
  • 21
Rick Bush
  • 81
  • 1
  • 7

2 Answers2

0

I can't think of an easy way to send a message directly from one phone to the other. (although I'm not used to jailbroken stuff, so who knows...). In any case, here's what I would do:

Set up a simple web server to interface between the two devices. You say you don't have internet, so just running Apache or whatever on a local computer on the network should do the trick. Whenever you want to send a message, the sending phone posts something to the server. Unfortunately, if you can't/don't want to use Apple's push notification service, I think the receiving phone is going to have to constantly monitor the server to see if there are any new messages. :(

numegil
  • 1,916
  • 7
  • 26
  • 38
  • Hi Numegil, thanks for the response. Unfortunately this would require a pc to be on all the time and I'm trying to avoid the use of constantly on equipment as much as prossible. I have read the process of sending a push notification here http://www.raywenderlich.com/3443 and it would appear to me that as long as I can register my pocket phones device token with the door phone then I should be able to generate a push notification using the door phone, please correct me if I'm off track here. I am having trouble understanding why if a pc can send a push notification then why can't an iphone? :( – Rick Bush Apr 19 '12 at 10:58
  • Ok, so I conceed it seems impossibl to send a push notification from one phone to another so I will have to have a pc on the network all the time. I still have no internet connection here though so my next question is, how would I go about sending a push notification from the pc to the phone without using Apples APSN servers, ie, I would like my pc to generate the notification and send it directky to my phone. I code in c# for work and so it would be great if I could have my own APNS written in c#, is this possible ? – Rick Bush Apr 20 '12 at 12:05
  • 1
    I haven't looked too far into this, so may or may not end up working for you, but it might be possible to connect via Bluetooth: see https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/GameKit_Guide/GameKitConcepts/GameKitConcepts.html and http://stackoverflow.com/questions/1427250/how-to-use-bluetooth-to-connect-two-iphone – numegil Apr 21 '12 at 03:03
0

Pair the phones with Bluetooth using GameKit.

Here's an SO question about how to bluetooth pair two iPhones: How to use bluetooth to connect two iPhone?

The easiest way is using the highly opaque GameKit. Here's an Apple example app that achieves this: http://developer.apple.com/library/ios/#samplecode/GKTank/Introduction/Intro.html

And from that example that snippet that sends packets (in TankViewController.m):

- (void)sendNetworkPacket:(GKSession *)session packetID:(int)packetID withData:(void *)data ofLength:(int)length reliable:(BOOL)howtosend {
    // the packet we'll send is resued
    static unsigned char networkPacket[kMaxTankPacketSize];
    const unsigned int packetHeaderSize = 2 * sizeof(int); // we have two "ints" for our header

    if(length < (kMaxTankPacketSize - packetHeaderSize)) { // our networkPacket buffer size minus the size of the header info
        int *pIntData = (int *)&networkPacket[0];
        // header info
        pIntData[0] = gamePacketNumber++;
        pIntData[1] = packetID;
        // copy data in after the header
        memcpy( &networkPacket[packetHeaderSize], data, length ); 

        NSData *packet = [NSData dataWithBytes: networkPacket length: (length+8)];
        if(howtosend == YES) { 
            [session sendData:packet toPeers:[NSArray arrayWithObject:gamePeerId] withDataMode:GKSendDataReliable error:nil];
        } else {
            [session sendData:packet toPeers:[NSArray arrayWithObject:gamePeerId] withDataMode:GKSendDataUnreliable error:nil];
        }
    }
}
Community
  • 1
  • 1
AlcubierreDrive
  • 3,654
  • 2
  • 29
  • 45
  • Ok, thanks for the advice. I have accepted it as the answer but bluetooth is normally turned off on my phone. However, there doesn't seem to be any way of doing this. I am not a paid up apple developer and only get to run my apps on my phone because I jailbroke it and used a tutorial to enable me to deploy to my phone from xcode. The internet limitation has been removed now as a kind neighbour has allowed me to use his wifi but even if I wanted to use Apples servers I don't think I could as I havn't paid. It all seems so convoluted when dealing with Apple. – Rick Bush May 01 '12 at 22:54