0
votes

I have to create an application which will detect a non ios device over bluetooth which supports BTLE 4.0.

I have following doubts:

  1. Is it possible to transfer images from iphone app to non ios device using BTLE 4.0
  2. I have searched some tutorial which talks about Central and peripheral. What i understand is in this case iphone app will be peripheral and non ios device will be central? m i right
  3. Will this code will be able to fulfil all my requirements
1
You can transfer an image; an image is just a collection of bytes that are interpreted in a certain way; you can transfer bytes using BLE. Typically the iOS app would be the central. The central is the device that scans for peripheral's to connect to. The peripheral advertises. - Paulw11
@Paulw11 but i want to use my ios app as peripheral which will send an image to non ios device that will support BTLE 4.0 . is it possible? - KsK
You can send data bidirectional from central to peripheral and vice versa. But why do you want to use your iOS app as peripheral? As @Paulw11 said, you can't scan ("detect") for your non iOS device. BTW: Your attached code is written in objective C. You should use swift code... - user5357137

1 Answers

0
votes
  1. Yes, an image can be converted to data and data can be sent via bluetooth. To convert a UIImage to NSData you have to decide on what format you want it. You can use UIImageJPEGRepresentation or UIImagePNGRepresentation.
    Either one will convert a UIImage into NSData.
  2. No you are wrong. The iOS Device has a Central Manager (CBCentralManager) which find other devices (CBPeripheral). Those other devices have many services (CBService) and each service can have many characteristic (CBCharacteristic) which you connect to. Once the connection is created you can send (write) or receive (read) data.
  3. The code looks pretty good. But the main point of SENDING data doesn't seem to be there. You can send to a Bluetooth peripheral from iOS using a WRITE command - which will automatically be split up in to small packets. The size is limited to 64K and can take around a second per kilobyte - so it is pretty slow. Use the function [peripheral writeValue:data forCharacteristic: characterstic type:CBCharacteristicWriteWithResponse]; (you have to keep a reference to the peripheral and the characterstic).