Skip to main content

Cloud Sns Lib API

danger

this is a legacy library and thus not supported by Toradex anymore. We recommend that you use the new libraries for all Toradex modules. Please see the Toradex CE Libraries and Code Samples for up-to-date information.


Contains function declarations to be used to access AWS Cloud Sns Services Colibri Modules [PXAxxx, Tegra T20], WinCE 6.0 / 7.0 Number of Topics are restricted to 100, number of subscriptions per Topic are limited to 100. More...

Macros

#define AWS_SNS_ACCESS_ID_MAX_LENGTH   20
 AWS Account ID string Length.
 
#define AWS_SNS_SECRET_KEY_MAX_LENGTH   40
 AWS Account Secret Kay String Length.
 
#define AWS_SNS_OWNER_ID_MAX_LENGTH   12
 AWS Account Owner ID String Length.
 
#define SNS_TOPIC_NAME_MAX_LENGTH   256
 Maximum number of characters allowed in Topic Name.
 
#define SNS_DISPLAY_NAME_MAX_LENGTH   100
 Maximum number of characters allowed in Topic's Display Name.
 
#define SNS_MAX_TIME_STRING_LENGTH   24
 AWS Sns Formatted Time String Length.
 
#define AWS_SNS_SIGNATURE_HASH_LEN   32
 HMAC-SHA2 HASH Length.
 
#define AWS_SNS_SIGNATURE_STRING_LEN   44
 HMAC-SHA2 Signature String Length.
 
#define AWS_SNS_MESSAGE_SIZE_MAX   (32 * 1024)
 Maximum allowed message length 32 KB (Applicable to SnsPublish)
 
#define AWS_SNS_SUBJECT_MAX   (100)
 Maximum number of characters allowed in subject (Applicable to SnsPublish)
 
#define SNS_LIST_TOPIC_RECEIVE_CHUNK   (32 * 1024)
 Buffer Size used when receiving list of Topics.
 
#define SNS_LIST_SUBSCRIPTION_RECEIVE_CHUNK   (32 * 1024)
 Buffer Size used when receiving list of Subscriptions.
 
#define PROTOCOL_TYPE_HTTP   1
 http Protocol
 
#define PROTOCOL_TYPE_HTTPS   2
 https Protocol
 
#define PROTOCOL_TYPE_EMAIL   3
 email Protocol
 
#define PROTOCOL_TYPE_EMAIL_JSON   4
 email-json Protocol
 
#define PROTOCOL_TYPE_SMS   5
 sms Protocol
 
#define PROTOCOL_TYPE_SQS   6
 sqs Protocol
 
#define ATTRIBUTE_TYPE_POLICY   1
 Attribute Type Selection Policy.
 
#define ATTRIBUTE_TYPE_DISPLAYNAME   2
 Attribute Type Selection Display Name.
 
#define ATTRIBUTE_TYPE_DELIVERYPOLICY   3
 Attribute Type Selection Delivery Policy.
 
#define SNS_HANDLE_MEMORY_ALLOCATION_SIZE   (7 * 4)
 
#define SNS_HTTP_RESPONSE_DATA_BUFFER_SMALL   (1 * 1024)
 
#define SNS_HTTP_RESPONSE_DATA_BUFFER_LARGE   (3 * 1024)
 
#define SNS_HTTP_ARGUMENT_BUFFER_SMALL   (2 * 1024)
 
#define SNS_STRING_TO_SIGN_BUFFER_SMALL   (2 * 1024)
 
#define URL_ENCODED_TOPIC_NAME_BUFFER   1024
 
#define URL_ENCODED_TOPIC_ARN_BUFFER   1024
 
#define URL_ENCODED_SUB_ARN_BUFFER   1024
 
#define URL_ENCODED_ENDPOINT_BUFFER   1024
 
#define URL_ENCODED_SUBJECT_BUFFER   512
 
#define URL_ENCODED_ATTRIBUTE_VALUE_BUFFER   512
 
#define PROTOCOL_STRING_LENGTH   10
 
#define ATTRIBUTE_VALUE_BUFFER_SIZE   256
 

Functions

BOOL SnsOpenTopic (char *accessID, char *secretKey, char *ownerId, char *path, char *topicName, char *displayName, HSNS *snsTopicHandle)
 
BOOL SnsCloseTopic (HSNS *snsTopicHandle)
 
BOOL SnsCreateTopic (HSNS snsTopicHandle)
 
BOOL SnsPublish (HSNS snsTopicHandle, const char *subject, const char *message)
 
BOOL SnsDeleteTopic (HSNS snsTopicHandle)
 
BOOL SnsSubscribe (HSNS snsTopicHandle, char *endPoint, BYTE protocolType)
 
BOOL SnsListTopics (HSNS snsTopicHandle, char *filePath)
 
BOOL SnsUnsubscribe (HSNS snsTopicHandle, char *subArn)
 
BOOL SnsListSubscriptions (HSNS snsTopicHandle, char *filePath)
 
BOOL SnsFindTopic (const char *filePath, char *dataOut, DWORD dataOutSize, DWORD *pointerToNextTopic, DWORD fileSize)
 
BOOL SnsFindSubscriptions (const char *filePath, char *dataOut, DWORD dataOutSize, DWORD *pointerToNextSubscriptionByTopic, DWORD fileSize)
 
BOOL SnsGetSubscriptionAttribtues (HSNS snsTopicHandle, char *subArn, char *dataOut, DWORD dataOutSize)
 
BOOL SnsGetTopicAttributes (HSNS snsTopicHandle, char *dataOut, DWORD dataOutSize)
 
BOOL SnsSetTopicAttributes (HSNS snsTopicHandle, BYTE attributeType, char *attributeValue)
 

Detailed Description

Contains function declarations to be used to access AWS Cloud Sns Services Colibri Modules [PXAxxx, Tegra T20], WinCE 6.0 / 7.0 Number of Topics are restricted to 100, number of subscriptions per Topic are limited to 100.
Author
Author:
agp
Version
Rev:
1154
Date
Date:
2012-11-08 19:56:19 +0530 (Thu, 08 Nov 2012)

Function Documentation

BOOL SnsCloseTopic(HSNS * snsTopicHandle) 
Deletes already created Sns Topic Handle
Parameters
[in]snsTopicHandleHandle returned by call to SnsTopicOpen()
Return values
TRUESuccess
FALSESee GetLastError()
BOOL SnsCreateTopic(HSNS snsTopicHandle) 
Creates new Sns Topic
Parameters
[in]snsTopicHandleHandle returned by call to SnsTopicOpen()
Return values
TRUESuccess
FALSESee GetLastError()
BOOL SnsDeleteTopic(HSNS snsTopicHandle) 
Deletes already existing Sns Topic
Parameters
[in]snsTopicHandleHandle returned by call to SnsTopicOpen()
Return values
TRUESuccess
FALSESee GetLastError()
BOOL SnsFindSubscriptions(const char * filePath,
  char * dataOut,
  DWORD dataOutSize,
  DWORD * pointerToNextSubscriptionByTopic,
  DWORD fileSize 
 )  
Finds Subscription details by Topic from list of subscriptionsByTopic stored in a local file
The file must be initialized by calling SnsListSubscriptionsByTopic()
Parameters
[in]filePathFile path in which list of subscription exists
[out]dataOutPointer to the output string containing subscription details, user need to allocate memory
[in]dataOutSizeNumber of bytes allocated for dataOut
[in,out]pointerToNextSubscriptionByTopicPointer to next Subscription details from list data, to find 1st Subscription by topic Detail, put NULL
[in]fileSizeSize of the file in bytes
Return values
TRUESuccess
FALSESee GetLastError()
BOOL SnsFindTopic(const char * filePath,
  char * dataOut,
  DWORD dataOutSize,
  DWORD * pointerToNextTopic,
  DWORD fileSize 
 )  
Finds Topic Details from list of Topics stored in a local file
The file must be initialized by calling SnsListTopics()
Parameters
[in]filePathFile path in which list of subscription exists
[out]dataOutPointer to the output string containing Topic details, user need to allocate memory
[in]dataOutSizeNumber of bytes allocated for dataOut
[in,out]pointerToNextTopicPointer to next Topic details from list data, to find 1st topic details, put NULL.
[in]fileSizeSize of the file in bytes
Return values
TRUESuccess
FALSESee GetLastError()
BOOL SnsGetSubscriptionAttribtues(HSNS snsTopicHandle,
  char * subArn,
  char * dataOut,
  DWORD dataOutSize 
 )  
Gets Subscription Attributes
Parameters
[in]snsTopicHandleHandle returned by call to SnsTopicOpen()
[in]subArnSubscription Arn String
[out]dataOutPointer to the output string containing subscription attributes details, user need to allocate memory
[in]dataOutSizeNumber of bytes allocated for dataOut
Return values
TRUESuccess
FALSESee GetLastError()
BOOL SnsGetTopicAttributes(HSNS snsTopicHandle,
  char * dataOut,
  DWORD dataOutSize 
 )  
Gets Topic Attributes of Sns Topic
Parameters
[in]snsTopicHandleHandle returned by call to SnsTopicOpen()
[out]dataOutPointer to the output string containing TopicAttribute details, user need to allocate memory
[in]dataOutSizeNumber of bytes allocated for dataOut
Return values
TRUESuccess
FALSESee GetLastError()
BOOL SnsListSubscriptions(HSNS snsTopicHandle,
  char * filePath 
 )  
Lists Subscriptions by topic in an Sns Account, for a particular region (max 100)
Subscriptions by Topic are stored into a local file
Parameters
[in]snsTopicHandleHandle returned by call to SnsTopicOpen()
[in]filePathFile in which list of Subscriptions by topics will be saved, user need to delete already existing file,
else list data will be appended in the same file
Return values
TRUESuccess
FALSESee GetLastError() Number of Topics are restricted to 100, number of subscriptions per Topic are limited to 100
BOOL SnsListTopics(HSNS snsTopicHandle,
  char * filePath 
 )  
Lists topics in an Sns Account, for a particular region (max 100)
Topics are stored into a local file
Parameters
[in]snsTopicHandleHandle returned by call to SnsTopicOpen()
[in]filePathFile in which list of topics will be saved, user need to delete already existing file,
else list data will be appended in the same file
Return values
TRUESuccess
FALSESee GetLastError() Number of Topics are restricted to 100, number of subscriptions per Topic are limited to 100
BOOL SnsOpenTopic(char * accessID,
  char * secretKey,
  char * ownerId,
  char * path,
  char * topicName,
  char * displayName,
  HSNS * snsTopicHandle 
 )  
Opens handle for Sns topic, the returned snsTopicHandle is required as an input parameter to every Sns function call
Parameters
[in]accessIDAWS Access ID [20 Characters]
[in]secretKeyAWS Secret Key [40 Characters]
[in]ownerIdAWS Owner ID [12 Characters]
[in]pathAWS Sns path
[in]topicNameTopic names must be constructed using only uppercase and lowercase ASCII letters,
numbers, underscore, hyphens and must be between 1 and 256 characters long
[in]displayName[OPTIONAL] if not NULL, Display names must be constructed using only uppercase/lowercase ASCII letters,
numbers, underscore, hyphens and must be between 1 and 100 characters long
[out]snsTopicHandleStructure to hold various sns related parameters.
Return values
TRUESuccess
FALSESee GetLastError()
BOOL SnsPublish(HSNS snsTopicHandle,
  const char * subject,
  const char * message 
 )  
Publishes/Sends a message to all the subscribed endpoints of a topic. When a messageId is returned,
the message has been saved and Amazon Sns will attempt to deliver it to the topic subscribers shortly
The format of the outgoing message to each subscribed endpoint depends on the notification protocol selected
Parameters
[in]snsTopicHandleHandle returned by call to SnsTopicOpen()
[in]subjectOptional parameter to be used as the "Subject" line, when the message is delivered to e-mail endpoints, max 100 ASCII characters
[in]messageThe message you want to send to the topic. Maximum length is 32 x 1024 characters
Return values
TRUESuccess
FALSESee GetLastError()
BOOL SnsSetTopicAttributes(HSNS snsTopicHandle,
  BYTE attributeType,
  char * attributeValue 
 )  
Sets Topic Attributes
Parameters
[in]snsTopicHandleHandle returned by call to SnsTopicOpen()
[in]attributeType[1] - Policy,
[2] - DisplayName,
[3] - DeliveryPolicy
[in]attributeValueString containing respective attribute value
Return values
TRUESuccess
FALSESee GetLastError() only attributes = 2 (DisplayName) is working
BOOL SnsSubscribe(HSNS snsTopicHandle,
  char * endPoint,
  BYTE protocolType 
 )  
Subscribes an endpoint to a topic
Parameters
[in]snsTopicHandleHandle returned by call to SnsTopicOpen()
[in]endPointURL "http://", URL "https://" , Email ID, Phone number for SMS, SQS: ARN of an Amazon SQS queue, etc
[in]protocolTypeValid Values can be from 1 to 6,
[1] - "http",
[2] - "https",
[3] - "email",
[4] - "email-json",
[5] - "sms",
[6] - "sqs"
Return values
TRUESuccess
FALSESee GetLastError()
BOOL SnsUnsubscribe(HSNS snsTopicHandle,
  char * subArn 
 )  
Unsubscribes an endpoint from its subscription
Parameters
[in]snsTopicHandleHandle returned by call to SnsTopicOpen()
[in]subArnSubscription Arn String
Return values
TRUESuccess
FALSESee GetLastError()


Send Feedback!