Socket Programming iOS to BOLT.
Hi
You are using bolt cloud then you can use standard GET REQUEST of the socket programming.
You can refer this code snippet. This code is written in objective C .
#import <Foundation/Foundation.h>
NSDictionary *headers = @{ @"content-type": @"application/x-www-form-urlencoded",
@"cache-control": @"no-cache" };
NSMutableData *postData = [[NSMutableData alloc] initWithData:[@"access-key=457833" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&auth-token=Namrepu8sDlohe6b" dataUsingEncoding:NSUTF8StringEncoding]];
[postData appendData:[@"&transaction-type=ONLINE" dataUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://cloud.boltiot.com/remote/b07d169a-0638-4b8c-944c-7115f698528h/digitalWrite?pin=0&state=HIGH&deviceName=BOLT8794983"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"GET"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
Hi,
Apart from digitalWrite which is a predefined URL call to Bolt Cloud , you cannot make / create any other commands to control the Output on any pin of Bolt
Thanks for the reply. But Im trying in socket Programming not with URL connections.
I’m trying something like this :
For example, alternative to digitalWrite( 13, HIGH ) is PORTB |= (1 << 5).
Hi,
No , that is the only way to control bolt as of now. This restriction is due to the proprietary firmware running on the ESP chip. So socket programming wont work unless the underlying firmware supported the same
oh , ok Thanks for clarity.